[nautilus: 1/2] nautilus-files-view: fix crash on search view



commit c2a0d219fd1e7b8ca468905c386cd61447611608
Author: Nelson Benítez León <nbenitezl+gnome gmail com>
Date:   Thu Oct 26 21:32:32 2017 +0500

    nautilus-files-view: fix crash on search view
    
    Fix crash caused by commit 3aba356a when switching to
    search view. Crash occured because of timeout being
    executed for a destroyed view. So we now save timeout id
    to make sure we remove timeout when its view it's being
    destroyed.
    
    https://gitlab.gnome.org/GNOME/nautilus/issues/73

 src/nautilus-files-view.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index a18cdeb88..caf1897a5 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -258,6 +258,7 @@ typedef struct
     /* Floating bar */
     guint floating_bar_set_status_timeout_id;
     guint floating_bar_loading_timeout_id;
+    guint floating_bar_set_passthrough_timeout_id;
     GtkWidget *floating_bar;
 
     /* Toolbar menu */
@@ -539,6 +540,8 @@ remove_floating_bar_passthrough (gpointer data)
     priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (data));
     gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay),
                                           priv->floating_bar, FALSE);
+    priv->floating_bar_set_passthrough_timeout_id = 0;
+
     return G_SOURCE_REMOVE;
 }
 
@@ -570,11 +573,18 @@ set_floating_bar_status (NautilusFilesView *view,
     status_data->detail_status = g_strdup (detail_status);
     status_data->view = view;
 
+    if (priv->floating_bar_set_passthrough_timeout_id != 0)
+    {
+        g_source_remove (priv->floating_bar_set_passthrough_timeout_id);
+        priv->floating_bar_set_passthrough_timeout_id = 0;
+    }
     /* Activate passthrough on the floating bar just long enough for a
      * potential double click to happen, so to not interfere with it */
     gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay),
                                           priv->floating_bar, TRUE);
-    g_timeout_add ((guint) double_click_time, remove_floating_bar_passthrough, view);
+    priv->floating_bar_set_passthrough_timeout_id = g_timeout_add ((guint) double_click_time,
+                                                                   remove_floating_bar_passthrough,
+                                                                   view);
 
     /* waiting for half of the double-click-time before setting
      * the status seems to be a good approximation of not setting it
@@ -3156,6 +3166,12 @@ nautilus_files_view_destroy (GtkWidget *object)
         priv->floating_bar_loading_timeout_id = 0;
     }
 
+    if (priv->floating_bar_set_passthrough_timeout_id != 0)
+    {
+        g_source_remove (priv->floating_bar_set_passthrough_timeout_id);
+        priv->floating_bar_set_passthrough_timeout_id = 0;
+    }
+
     g_signal_handlers_disconnect_by_func (nautilus_preferences,
                                           schedule_update_context_menus, view);
     g_signal_handlers_disconnect_by_func (nautilus_preferences,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]