[nautilus] pathbar: Fix crash when right clicking



commit 4cff0387f0521f0bce20ad3c3840e7b260e36857
Author: Corey Berla <corey berla me>
Date:   Mon Apr 4 17:41:25 2022 -0700

    pathbar: Fix crash when right clicking
    
    button_data_free() was destroying the button_menu_popover because it
    was set as a child of the button previously.
    
    This means that the next time one right clicks a parent folder, we
    use a pointer to a destroyed object, crashing the application.
    
    Reparent to the pathbar before the button is destroyed.

 src/nautilus-pathbar.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index aeb909f47..65ac67e7b 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -367,6 +367,15 @@ get_dir_name (ButtonData *button_data)
 static void
 button_data_free (ButtonData *button_data)
 {
+    NautilusPathBar *self;
+    self = button_data->path_bar;
+    if (self != NULL && self->button_menu_popover != NULL)
+    {
+        g_object_ref (self->button_menu_popover);
+        gtk_widget_unparent (self->button_menu_popover);
+        gtk_widget_set_parent (self->button_menu_popover, GTK_WIDGET (self));
+        g_object_unref (self->button_menu_popover);
+    }
     g_object_unref (button_data->path);
     g_free (button_data->dir_name);
     if (button_data->file != NULL)


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