# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1614605038 0 # Node ID 594111e84e896446315d4541f3e3c6654e450f94 # Parent addbd7db1e5c679fd41a23a9218e6c32a3f70adb GTK4: Save pointer to the activate popup menu for a window. Clear the pointer when it is destroyed, either popup or bar. Should theoretically be able to destroy an active popup now. diff -r addbd7db1e5c -r 594111e84e89 gtk4/dw.c --- a/gtk4/dw.c Mon Mar 01 12:12:31 2021 +0000 +++ b/gtk4/dw.c Mon Mar 01 13:23:58 2021 +0000 @@ -2747,14 +2747,20 @@ { GtkWidget *window = NULL; - /* If it is a menu bar, try to delete the reference to it */ - if(GTK_IS_POPOVER_MENU_BAR(*menu) && + /* If it is attached to a window, try to delete the reference to it */ + if((GTK_IS_POPOVER_MENU_BAR(*menu) || GTK_IS_POPOVER_MENU(*menu)) && (window = GTK_WIDGET(g_object_get_data(G_OBJECT(*menu), "_dw_window")))) - g_object_set_data(G_OBJECT(window), "_dw_menubar", NULL); + { + if(GTK_IS_POPOVER_MENU_BAR(*menu)) + g_object_set_data(G_OBJECT(window), "_dw_menubar", NULL); + else + g_object_set_data(G_OBJECT(window), "_dw_menu_popup", NULL); + } /* Actually destroy the menu */ if(GTK_IS_WIDGET(*menu) && window) { GtkWidget *box = GTK_WIDGET(g_object_get_data(G_OBJECT(window), "_dw_grid")); + if(box && GTK_IS_GRID(box)) gtk_grid_remove(GTK_GRID(box), GTK_WIDGET(*menu)); else @@ -3116,6 +3122,7 @@ { gtk_grid_attach(GTK_GRID(box), tmp, 65535, 65535, 1, 1); g_object_set_data(G_OBJECT(tmp), "_dw_window", (gpointer)parent); + g_object_set_data(G_OBJECT(parent), "_dw_menu_popup", (gpointer)tmp); } } else