Crash when launching RT after last directory selected has been deleted. Issue #131
For some strange reason Gio exceptions are not catched well: inserted a test to verify file existence before accessing it.
This commit is contained in:
@@ -214,7 +214,7 @@ void CacheManager::deleteDir (const Glib::ustring& dirName) {
|
|||||||
std::string CacheManager::getMD5 (const Glib::ustring& fname) {
|
std::string CacheManager::getMD5 (const Glib::ustring& fname) {
|
||||||
|
|
||||||
Glib::RefPtr<Gio::File> file = Gio::File::create_for_path (fname);
|
Glib::RefPtr<Gio::File> file = Gio::File::create_for_path (fname);
|
||||||
if (file) {
|
if (file && file->query_exists()) {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (file);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (file);
|
||||||
if (info)
|
if (info)
|
||||||
return Glib::Checksum::compute_checksum (Glib::Checksum::CHECKSUM_MD5, Glib::ustring::compose ("%1%2", fname, info->get_size()));
|
return Glib::Checksum::compute_checksum (Glib::Checksum::CHECKSUM_MD5, Glib::ustring::compose ("%1%2", fname, info->get_size()));
|
||||||
|
@@ -265,7 +265,6 @@ void DirBrowser::addDir (const Gtk::TreeModel::iterator& iter, const Glib::ustri
|
|||||||
child->set_value (1, closedfolder);
|
child->set_value (1, closedfolder);
|
||||||
Glib::ustring fullname = Glib::build_filename (iter->get_value (dtColumns.dirname), dirname);
|
Glib::ustring fullname = Glib::build_filename (iter->get_value (dtColumns.dirname), dirname);
|
||||||
child->set_value (dtColumns.dirname, fullname);
|
child->set_value (dtColumns.dirname, fullname);
|
||||||
Glib::RefPtr<Gio::File> f = Gio::File::create_for_path (fullname);
|
|
||||||
Gtk::TreeModel::iterator fooRow = dirTreeModel->append(child->children());
|
Gtk::TreeModel::iterator fooRow = dirTreeModel->append(child->children());
|
||||||
fooRow->set_value (dtColumns.filename, Glib::ustring("foo"));
|
fooRow->set_value (dtColumns.filename, Glib::ustring("foo"));
|
||||||
}
|
}
|
||||||
@@ -339,7 +338,11 @@ void DirBrowser::open (const Glib::ustring& dirname, const Glib::ustring& fileNa
|
|||||||
|
|
||||||
dirtree->collapse_all ();
|
dirtree->collapse_all ();
|
||||||
|
|
||||||
Glib::ustring absDirPath = Gio::File::create_for_path(dirname)->get_parse_name ();
|
|
||||||
|
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(dirname);
|
||||||
|
if( !dir->query_exists())
|
||||||
|
return;
|
||||||
|
Glib::ustring absDirPath = dir->get_parse_name ();
|
||||||
Gtk::TreePath path = expandToDir (absDirPath);
|
Gtk::TreePath path = expandToDir (absDirPath);
|
||||||
dirtree->scroll_to_row (path);
|
dirtree->scroll_to_row (path);
|
||||||
dirtree->get_selection()->select (path);
|
dirtree->get_selection()->select (path);
|
||||||
|
@@ -792,8 +792,10 @@ void FileCatalog::on_dir_changed (const Glib::RefPtr<Gio::File>& file, const Gli
|
|||||||
|
|
||||||
void FileCatalog::checkAndAddFile (Glib::RefPtr<Gio::File> file) {
|
void FileCatalog::checkAndAddFile (Glib::RefPtr<Gio::File> file) {
|
||||||
|
|
||||||
if (!file)
|
if (!file )
|
||||||
return;
|
return;
|
||||||
|
if( !file->query_exists())
|
||||||
|
return;
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info(file);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info(file);
|
||||||
if (info && info->get_file_type() != Gio::FILE_TYPE_DIRECTORY && (!info->is_hidden() || !options.fbShowHidden)) {
|
if (info && info->get_file_type() != Gio::FILE_TYPE_DIRECTORY && (!info->is_hidden() || !options.fbShowHidden)) {
|
||||||
int lastdot = info->get_name().find_last_of ('.');
|
int lastdot = info->get_name().find_last_of ('.');
|
||||||
@@ -807,8 +809,10 @@ void FileCatalog::checkAndAddFile (Glib::RefPtr<Gio::File> file) {
|
|||||||
void FileCatalog::addAndOpenFile (const Glib::ustring& fname) {
|
void FileCatalog::addAndOpenFile (const Glib::ustring& fname) {
|
||||||
|
|
||||||
Glib::RefPtr<Gio::File> file = Gio::File::create_for_path (fname);
|
Glib::RefPtr<Gio::File> file = Gio::File::create_for_path (fname);
|
||||||
if (!file)
|
if (!file )
|
||||||
return;
|
return;
|
||||||
|
if( !file->query_exists())
|
||||||
|
return;
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info(file);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info(file);
|
||||||
if( !info )
|
if( !info )
|
||||||
return;
|
return;
|
||||||
|
@@ -81,7 +81,7 @@ void PlacesBrowser::refreshPlacesList () {
|
|||||||
|
|
||||||
// append home directory
|
// append home directory
|
||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (Glib::get_home_dir ());
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (Glib::get_home_dir ());
|
||||||
if (hfile) {
|
if (hfile && hfile->query_exists()) {
|
||||||
try {
|
try {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
||||||
if (info) {
|
if (info) {
|
||||||
@@ -97,7 +97,7 @@ void PlacesBrowser::refreshPlacesList () {
|
|||||||
|
|
||||||
// append pictures directory
|
// append pictures directory
|
||||||
hfile = Gio::File::create_for_path (Glib::get_user_special_dir (G_USER_DIRECTORY_PICTURES));
|
hfile = Gio::File::create_for_path (Glib::get_user_special_dir (G_USER_DIRECTORY_PICTURES));
|
||||||
if (hfile) {
|
if (hfile && hfile->query_exists()) {
|
||||||
try {
|
try {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
||||||
if (info) {
|
if (info) {
|
||||||
@@ -191,7 +191,7 @@ void PlacesBrowser::refreshPlacesList () {
|
|||||||
}
|
}
|
||||||
for (int i=0; i<options.favoriteDirs.size(); i++) {
|
for (int i=0; i<options.favoriteDirs.size(); i++) {
|
||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (options.favoriteDirs[i]);
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (options.favoriteDirs[i]);
|
||||||
if (hfile) {
|
if (hfile && hfile->query_exists()) {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
||||||
if (info) {
|
if (info) {
|
||||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||||
@@ -274,7 +274,7 @@ void PlacesBrowser::addPressed () {
|
|||||||
|
|
||||||
// append
|
// append
|
||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (lastSelectedDir);
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (lastSelectedDir);
|
||||||
if (hfile) {
|
if (hfile && hfile->query_exists()) {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
||||||
if (info) {
|
if (info) {
|
||||||
options.favoriteDirs.push_back (hfile->get_parse_name ());
|
options.favoriteDirs.push_back (hfile->get_parse_name ());
|
||||||
|
Reference in New Issue
Block a user