From f09ea9aec5b97ed530d43c3872d968734b2d5ec2 Mon Sep 17 00:00:00 2001 From: Theo Linkspfeifer Date: Sat, 15 Feb 2020 17:34:46 +0100 Subject: [PATCH] Prevent crash when renaming file (Bug #10805) --- thunar/thunar-dialogs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index c6ac70ab..94eb2814 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -173,6 +173,10 @@ thunar_dialogs_show_rename_file (gpointer parent, /* resize the dialog to make long names fit as much as possible */ gtk_window_set_default_size (GTK_WINDOW (dialog), CLAMP (layout_width, 300, parent_width), -1); + /* automatically close the dialog when the file is destroyed */ + g_signal_connect_swapped (G_OBJECT (file), "destroy", + G_CALLBACK (gtk_widget_destroy), dialog); + /* run the dialog */ response = gtk_dialog_run (GTK_DIALOG (dialog)); if (G_LIKELY (response == GTK_RESPONSE_OK)) @@ -192,7 +196,8 @@ thunar_dialogs_show_rename_file (gpointer parent, } /* cleanup */ - gtk_widget_destroy (dialog); + if (G_LIKELY (response != GTK_RESPONSE_NONE)) + gtk_widget_destroy (dialog); return job; } -- 2.25.0