From fe1fd6fdfeda6dc1d4bcf3f8d334d1a54e1df1fd Mon Sep 17 00:00:00 2001 From: rim Date: Mon, 20 May 2019 03:45:59 +0300 Subject: [PATCH] Fix crash on refresh after dir removed: use thunar_file_reload() with care. --- thunar/thunar-folder.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c index 76f5ab5..2afe77c 100644 --- a/thunar/thunar-folder.c +++ b/thunar/thunar-folder.c @@ -294,8 +294,9 @@ thunar_folder_finalize (GObject *object) /* cancel the pending job (if any) */ if (G_UNLIKELY (folder->job != NULL)) { - g_signal_handlers_disconnect_matched (folder->job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder); - g_object_unref (folder->job); + exo_job_cancel (EXO_JOB (folder->job)); + g_signal_handlers_disconnect_matched (G_OBJECT (folder->job), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder); + g_object_unref (G_OBJECT (folder->job)); folder->job = NULL; } @@ -482,6 +483,7 @@ thunar_folder_finished (ExoJob *job, _thunar_return_if_fail (THUNAR_IS_FOLDER (folder)); _thunar_return_if_fail (THUNAR_IS_JOB (job)); + _thunar_return_if_fail (!exo_job_is_cancelled(job)); _thunar_return_if_fail (THUNAR_IS_FILE (folder->corresponding_file)); _thunar_return_if_fail (folder->monitor == NULL); _thunar_return_if_fail (folder->content_type_idle_id == 0); @@ -561,13 +563,15 @@ 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); - - folder->reload_info = FALSE; + /* folder can be destroyed here, avoid use it. */ + if (exo_job_is_cancelled(job)) + return; /* folder destroyed, stop process it. */ } /* we did it, the folder is loaded */ @@ -815,6 +819,8 @@ thunar_folder_monitor (GFileMonitor *monitor, /* reload the folder of the source file */ thunar_file_reload (folder->corresponding_file); + /* folder can be destroyed here, avoid use it. */ + restart = FALSE; } else { @@ -840,6 +846,7 @@ thunar_folder_monitor (GFileMonitor *monitor, else { thunar_file_reload (folder->corresponding_file); + /* folder can be destroyed here, avoid use it. */ } } } -- libgit2 0.28.1