From 2e654162709d6da9b5c99265911806c51d11b5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Thu, 1 Apr 2021 09:36:19 +0200 Subject: [PATCH] filechooserwidget: Reduce code duplication for disconnecting settings signal Instead of getting current display before calling settings signal removal, do it inside remove function and only if there is a signal connection to remove. --- gtk/gtkfilechooserwidget.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 2f6a2bda39..d03c796540 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -3084,14 +3084,13 @@ cancel_all_operations (GtkFileChooserWidget *impl) /* Removes the settings signal handler. It's safe to call multiple times */ static void -remove_settings_signal (GtkFileChooserWidget *impl, - GdkDisplay *display) +remove_settings_signal (GtkFileChooserWidget *impl) { if (impl->settings_signal_id) { - GtkSettings *settings; + GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (impl)); + GtkSettings *settings = gtk_settings_get_for_display (display); - settings = gtk_settings_get_for_display (display); g_signal_handler_disconnect (settings, impl->settings_signal_id); impl->settings_signal_id = 0; @@ -3115,7 +3114,7 @@ gtk_file_chooser_widget_dispose (GObject *object) location_entry_disconnect (impl); impl->external_entry = NULL; } - remove_settings_signal (impl, gtk_widget_get_display (GTK_WIDGET (impl))); + remove_settings_signal (impl); g_clear_pointer (&impl->box, gtk_widget_unparent); @@ -7856,7 +7855,7 @@ display_changed_cb (GtkWidget *wiget, GParamSpec *pspec, GtkFileChooserWidget *impl) { - remove_settings_signal (impl, gtk_widget_get_display (GTK_WIDGET (impl))); + remove_settings_signal (impl); check_icon_theme (impl); }