diff --git a/thunar/thunar-browser.c b/thunar/thunar-browser.c index c005c772b1f9fbafa552924ea07b3068596c4bc3..557b60ae7e7cb65d355497bfe0e810073b66caaf 100644 --- a/thunar/thunar-browser.c +++ b/thunar/thunar-browser.c @@ -249,17 +249,18 @@ thunar_browser_poke_mountable_finish (GObject *object, if (error == NULL) { - thunar_file_reload (poke_data->file); - - location = thunar_file_get_target_location (poke_data->file); + if (thunar_file_reload (poke_data->file)) + { + location = thunar_file_get_target_location (poke_data->file); - /* resolve the ThunarFile for the target location asynchronously - * and defer cleaning up the poke data until that has finished */ - thunar_file_get_async (location, NULL, - thunar_browser_poke_mountable_file_finish, - poke_data); + /* resolve the ThunarFile for the target location asynchronously + * and defer cleaning up the poke data until that has finished */ + thunar_file_get_async (location, NULL, + thunar_browser_poke_mountable_file_finish, + poke_data); - g_object_unref (location); + g_object_unref (location); + } } else { @@ -311,7 +312,13 @@ thunar_browser_poke_file_finish (GObject *object, } if (error == NULL) - thunar_file_reload (poke_data->file); + { + if (thunar_file_reload (poke_data->file) == FALSE) + { + thunar_browser_poke_file_data_free (poke_data); + return; + } + } if (poke_data->location_func != NULL) { diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 49b48bd5ccfb35cb0d9d8d03cbfa341825446c4a..e147650696b3e440b35ac1c58d60831e5475a8ac 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -791,6 +791,7 @@ thunar_file_monitor (GFileMonitor *monitor, { ThunarFile *file = THUNAR_FILE (user_data); ThunarFile *other_file; + gboolean reload_ok = TRUE; _thunar_return_if_fail (G_IS_FILE_MONITOR (monitor)); _thunar_return_if_fail (G_IS_FILE (event_path)); @@ -829,11 +830,11 @@ thunar_file_monitor (GFileMonitor *monitor, other_file = thunar_file_cache_lookup (other_path); if (other_file) - thunar_file_reload (other_file); + reload_ok = thunar_file_reload (other_file); else other_file = thunar_file_get (other_path, NULL); - if (other_file != NULL) + if (reload_ok && other_file != NULL) { /* notify the thumbnail cache that we can now also move the thumbnail */ thunar_file_move_thumbnail_cache_file (event_path, other_path); @@ -3961,9 +3962,7 @@ thunar_file_unwatch (ThunarFile *file) * You must be able to handle the case that @file is * destroyed during the reload call. * - * Return value: As this function can be used as a callback function - * for thunar_file_reload_idle, it will always return FALSE to prevent - * being called repeatedly. + * Return value: TRUE on success, FALSE otherwise **/ gboolean thunar_file_reload (ThunarFile *file) @@ -3983,6 +3982,15 @@ thunar_file_reload (ThunarFile *file) /* ... and tell others */ thunar_file_changed (file); + return TRUE; +} + + + +gboolean +thunar_file_reload_cb_once (ThunarFile *file) +{ + thunar_file_reload (file); return FALSE; } @@ -3992,7 +4000,7 @@ thunar_file_reload (ThunarFile *file) * thunar_file_reload_idle: * @file : a #ThunarFile instance. * - * Schedules a reload of the @file by calling thunar_file_reload + * Schedules a single reload of the @file by calling thunar_file_reload * when idle. * **/ @@ -4001,7 +4009,7 @@ thunar_file_reload_idle (ThunarFile *file) { _thunar_return_if_fail (THUNAR_IS_FILE (file)); - g_idle_add ((GSourceFunc) thunar_file_reload, file); + g_idle_add ((GSourceFunc) thunar_file_reload_cb_once, file); } diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c index 128572f7a6c4a63f1a879f748c1d69ef7e542e54..6e7af454fc0aa2dad6ef0edfa1738717b501036d 100644 --- a/thunar/thunar-folder.c +++ b/thunar/thunar-folder.c @@ -582,13 +582,14 @@ thunar_folder_finished (ExoJob *job, /* schedule a reload of the file information of all files if requested */ if (folder->reload_info) { + folder->reload_info = FALSE; for (lp = folder->files; lp != NULL; lp = lp->next) thunar_file_reload (lp->data); /* reload folder information too */ - thunar_file_reload (folder->corresponding_file); + if (thunar_file_reload (folder->corresponding_file)) + return; - folder->reload_info = FALSE; } /* we did it, the folder is loaded */ @@ -810,19 +811,20 @@ thunar_folder_monitor (GFileMonitor *monitor, file = thunar_file_get(other_file, NULL); if (file != NULL && THUNAR_IS_FILE (file)) { - thunar_file_reload (file); - - /* if source and target folders are different, also tell - the target folder to reload for the changes */ - if (thunar_file_has_parent (file)) + if (thunar_file_reload (file)) { - other_parent = thunar_file_get_parent (file, NULL); - if (other_parent && - !g_file_equal (thunar_file_get_file(folder->corresponding_file), - thunar_file_get_file(other_parent))) + /* if source and target folders are different, also tell + the target folder to reload for the changes */ + if (thunar_file_has_parent (file)) { - thunar_file_reload (other_parent); - g_object_unref (other_parent); + other_parent = thunar_file_get_parent (file, NULL); + if (other_parent && + !g_file_equal (thunar_file_get_file(folder->corresponding_file), + thunar_file_get_file(other_parent))) + { + thunar_file_reload (other_parent); + g_object_unref (other_parent); + } } }