From 6a6a28ba8bda49a08850627261a9ba40e8a9c5e0 Mon Sep 17 00:00:00 2001 From: Hombre Date: Fri, 15 Nov 2013 05:46:50 +0100 Subject: [PATCH] Solving issue 2046: "RT crash on First run" --- rtgui/dirbrowser.cc | 9 +++++++-- rtgui/filepanel.cc | 4 ++-- rtgui/placesbrowser.cc | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rtgui/dirbrowser.cc b/rtgui/dirbrowser.cc index 24076df11..502a620a2 100644 --- a/rtgui/dirbrowser.cc +++ b/rtgui/dirbrowser.cc @@ -340,6 +340,7 @@ void DirBrowser::open (const Glib::ustring& dirname, const Glib::ustring& fileNa dirtree->collapse_all (); + // WARNING & TODO: One should test here if the directory/file has R/W access permission to avoid crash Glib::RefPtr dir = Gio::File::create_for_path(dirname); if( !dir->query_exists()) @@ -348,8 +349,12 @@ void DirBrowser::open (const Glib::ustring& dirname, const Glib::ustring& fileNa Gtk::TreePath path = expandToDir (absDirPath); dirtree->scroll_to_row (path); dirtree->get_selection()->select (path); - for (size_t i=0; idirSelected (absDirPath, Glib::build_filename (absDirPath, fileName)); + Glib::ustring absFilePath; + if (!fileName.empty()) + absFilePath = Glib::build_filename (absDirPath, fileName); + for (size_t i=0; idirSelected (absDirPath, absFilePath); + } } void DirBrowser::file_changed (const Glib::RefPtr& file, const Glib::RefPtr& other_file, Gio::FileMonitorEvent event_type, const Gtk::TreeModel::iterator& iter, const Glib::ustring& dirName) { diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 89d6e3e70..55851941e 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -144,7 +144,7 @@ void FilePanel::init () { dirBrowser->open (argv1); else { if (options.startupDir==STARTUPDIR_HOME) - dirBrowser->open (Glib::get_home_dir()); + dirBrowser->open (safe_get_user_picture_dir()); else if (options.startupDir==STARTUPDIR_CURRENT) dirBrowser->open (argv0); else if (options.startupDir==STARTUPDIR_CUSTOM || options.startupDir==STARTUPDIR_LAST) { @@ -152,7 +152,7 @@ void FilePanel::init () { dirBrowser->open (options.startupPath); else { // Fallback option if the path is empty or the folder doesn't exist - dirBrowser->open (Glib::get_home_dir()); + dirBrowser->open (safe_get_user_picture_dir()); } } } diff --git a/rtgui/placesbrowser.cc b/rtgui/placesbrowser.cc index f0d650a90..a2dc33bfe 100644 --- a/rtgui/placesbrowser.cc +++ b/rtgui/placesbrowser.cc @@ -87,7 +87,7 @@ void PlacesBrowser::refreshPlacesList () { placesModel->clear (); // append home directory - Glib::RefPtr hfile = Gio::File::create_for_path (Glib::get_home_dir ()); + Glib::RefPtr hfile = Gio::File::create_for_path (safe_get_user_home_dir()); // Will send back "My documents" on Windows now, which has no restricted access if (hfile && hfile->query_exists()) { try { Glib::RefPtr info = safe_query_file_info (hfile);