]> Dogcows Code - chaz/openbox/commitdiff
add a menu destructor callback.
authorDana Jansens <danakj@orodu.net>
Thu, 14 Aug 2003 06:00:38 +0000 (06:00 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 14 Aug 2003 06:00:38 +0000 (06:00 +0000)
fix a possible crasher where a callback was called with a different menu.

openbox/menu.c
openbox/menu.h

index b29594d75434c2ac0c2c67acab579008691c8571..0905cb161dcb6560ec8ab99c1aaf2b1be90a5ac1 100644 (file)
@@ -115,6 +115,8 @@ void menu_destroy_hash_value(ObMenu *self)
 {
     GList *it;
 
+    if (self->destroy) self->destroy(self);
+
     for (it = self->entries; it; it = it->next)
         menu_entry_free(it->data);
     g_list_free(self->entries);
@@ -215,7 +217,8 @@ ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
                       menu_controller_show show, menu_controller_update update,
                       menu_controller_selected selected,
                       menu_controller_hide hide,
-                      menu_controller_mouseover mouseover)
+                      menu_controller_mouseover mouseover,
+                      menu_controller_destroy destroy)
 {
     XSetWindowAttributes attrib;
     ObMenu *self;
@@ -233,6 +236,7 @@ ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
     self->invalid = TRUE;
 
     /* default controllers */
+    self->destroy = destroy;
     self->show = (show != NULL ? show : menu_show_full);
     self->hide = (hide != NULL ? hide : menu_hide);
     self->update = (update != NULL ? update : menu_render);
@@ -513,7 +517,7 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter)
                ob_rr_theme->bwidth - ob_rr_theme->menu_overlap;
 
            /* need to get the width. is this bad?*/
-           self->parent->update(self->submenu);
+           self->submenu->update(self->submenu);
 
             a = screen_physical_area_monitor(self->parent->xin_area);
 
index 1adac022e10e12d2e97992cd6eafc8a81fe2ebd1..de0929e5eb48f05623724e72a1996d86c7d8be78 100644 (file)
@@ -14,6 +14,7 @@ struct _ObParseInst;
 typedef struct _ObMenu ObMenu;
 typedef struct _ObMenuEntry ObMenuEntry;
 
+typedef void(*menu_controller_destroy)(ObMenu *self);
 typedef void(*menu_controller_show)(ObMenu *self, int x, int y,
                                     struct _ObClient *);
 typedef void(*menu_controller_update)(ObMenu *self);
@@ -54,6 +55,9 @@ struct _ObMenu
     ObMenu *open_submenu;
     GList *over;
     
+    /* destructor */
+    menu_controller_destroy destroy;
+
     /* behaviour callbacks
        TODO: Document and split code that HAS to be in the overridden callback */
     /* place a menu on screen */
@@ -142,13 +146,15 @@ void menu_noop();
 
 #define menu_new(l, n, p) \
   menu_new_full(l, n, p, menu_show_full, menu_render, menu_entry_fire, \
-                menu_hide, menu_control_mouseover)
+                menu_hide, menu_control_mouseover, NULL)
 
 ObMenu *menu_new_full(char *label, char *name, ObMenu *parent, 
-                      menu_controller_show show, menu_controller_update update,
+                      menu_controller_show show,
+                      menu_controller_update update,
                       menu_controller_selected selected,
                       menu_controller_hide hide,
-                      menu_controller_mouseover mouseover);
+                      menu_controller_mouseover mouseover,
+                      menu_controller_destroy destroy);
 
 void menu_free(char *name);
 
This page took 0.026375 seconds and 4 git commands to generate.