[SF#900] taskbutton: detach menu from widget before widget is destroyed
authorMamoru TASAKA <mtasaka@fedoraproject.org>
Sun, 4 Mar 2018 14:15:51 +0000 (23:15 +0900)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Mon, 5 Mar 2018 14:06:10 +0000 (16:06 +0200)
Although GTK+ 2 version doxygen lacks such information,
https://developer.gnome.org/gtk3/stable/GtkMenu.html#gtk-menu-attach-to-widget
says that the attached menu is to be destroyed when the widget is destroyed.

So to "reuse" created menu, menu must be detached before the widget is to
be destroyed,

plugins/task-button.c

index 3e99068..9e8c398 100644 (file)
@@ -1538,7 +1538,15 @@ void task_button_update_windows_list(TaskButton *button, Window *list, gint n)
         l = next; /* go next details */
     }
     if (button->details == NULL) /* all windows were deleted */
+    {
+        GList *menu_list = gtk_menu_get_for_attach_widget(GTK_WIDGET(button));
+        for (; menu_list; menu_list = menu_list->next)
+        {
+            GtkMenu *menu = GTK_MENU(menu_list->data);
+            gtk_menu_detach(menu);
+        }
         gtk_widget_destroy(GTK_WIDGET(button));
+    }
     else if (has_removed && task_update_visibility(button))
         task_redraw_label(button);
     // FIXME: test if need to update menu