]> Dogcows Code - chaz/openbox/commitdiff
fix a bunch of memleaks from valgrind and stuff
authorDana Jansens <danakj@orodu.net>
Thu, 28 Aug 2003 19:10:36 +0000 (19:10 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 28 Aug 2003 19:10:36 +0000 (19:10 +0000)
openbox/menu.c
openbox/menuframe.c
openbox/openbox.c
openbox/prop.c
openbox/screen.c
render/color.c
render/font.c
render/theme.c

index 4ffcca0d397adf6eb4ddf7cb5f1b5432e5d27f0e..2847b508a48fb303e8292e53da29fbbea91208a1 100644 (file)
@@ -190,6 +190,7 @@ void menu_parse()
         parse_register(menu_parse_inst, "separator",
                        parse_menu_separator, &parse_state);
         parse_tree(menu_parse_inst, doc, node->xmlChildrenNode);
+        xmlFreeDoc(doc);
     }
 }
 
index 56dbc647c48b1702f6f1f8eb1a331780fa56b0c1..6615660d94e6a40dbd9f67d6c72d307b0ac211ec 100644 (file)
@@ -170,6 +170,8 @@ void menu_frame_move_on_screen(ObMenuFrame *self)
 
         for (f = self; f; f = f->parent)
             menu_frame_move(f, f->area.x + dx, f->area.y + dy);
+        for (f = self->child; f; f = f->child)
+            menu_frame_move(f, f->area.x + dx, f->area.y + dy);
         XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy);
     }
 }
@@ -424,6 +426,11 @@ static void menu_frame_update(ObMenuFrame *self)
 
 void menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent)
 {
+    GList *it;
+
+    if (g_list_find(menu_frame_visible, self))
+        return;
+
     if (parent) {
         if (parent->child)
             menu_frame_hide(parent->child);
@@ -437,14 +444,20 @@ void menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent)
         grab_keyboard(TRUE);
     }
 
-    if (!g_list_find(menu_frame_visible, self)) {
-        menu_frame_visible = g_list_prepend(menu_frame_visible, self);
-
+    /* determine if the underlying menu is already visible */
+    for (it = menu_frame_visible; it; it = g_list_next(it)) {
+        ObMenuFrame *f = it->data;
+        if (f->menu == self->menu)
+            break;
+    }
+    if (!it) {
         if (self->menu->update_func)
             self->menu->update_func(self, self->menu->data);
-        menu_frame_update(self);
     }
 
+    menu_frame_visible = g_list_prepend(menu_frame_visible, self);
+    menu_frame_update(self);
+
     menu_frame_move_on_screen(self);
 
     XMapWindow(ob_display, self->window);
@@ -452,7 +465,12 @@ void menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent)
 
 void menu_frame_hide(ObMenuFrame *self)
 {
-    menu_frame_visible = g_list_remove(menu_frame_visible, self);
+    GList *it = g_list_find(menu_frame_visible, self);
+
+    if (!it)
+        return;
+
+    menu_frame_visible = g_list_delete_link(menu_frame_visible, it);
 
     if (self->child)
         menu_frame_hide(self->child);
index 165d7229730c79859e2d854c0a1ef504a156db25..8e61fa86f729fa0fa96551eec2bc19da8d937446 100644 (file)
@@ -235,6 +235,7 @@ int main(int argc, char **argv)
         if (parse_load_rc(&doc, &node))
             parse_tree(i, doc, node->xmlChildrenNode);
         /* we're done with parsing now, kill it */
+        xmlFreeDoc(doc);
         parse_shutdown(i);
 
         menu_parse();
@@ -291,6 +292,10 @@ int main(int argc, char **argv)
     session_shutdown();
     g_free(ob_sm_id);
 
+#ifdef USE_LIBSN
+    sn_display_unref(ob_sn_display);
+#endif
+
     XCloseDisplay(ob_display);
 
     if (restart) {
index 186cc133c9c6af2b056cf6fbf78532d9f0fa9719..b3349e323414d2d456613b70b2787cb3fdbb8d0e 100644 (file)
@@ -392,6 +392,7 @@ void prop_set_strings_utf8(Window win, Atom prop, char **strs)
     }
     XChangeProperty(ob_display, win, prop, prop_atoms.utf8, 8,
                     PropModeReplace, (guchar*)str->str, str->len);
+    g_string_free(str, TRUE);
 }
 
 void prop_erase(Window win, Atom prop)
index ac0889bf3b7cbc4bd6bbe90f3309eab9d07f1c7a..f80f0c2dcbbc2812972fd68fc82ce0733d6a07f4 100644 (file)
@@ -67,6 +67,7 @@ static gboolean replace_wm()
 
     wm_sn = g_strdup_printf("WM_S%d", ob_screen);
     wm_sn_atom = XInternAtom(ob_display, wm_sn, FALSE);
+    g_free(wm_sn);
 
     current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom);
     if (current_wm_sn_owner) {
index d16bbf0cdd93b8e06cc2eee2664f2f6ea2fe5edf..37ef5532dd952b63cc8872e24ea611d2fc5af2b8 100644 (file)
@@ -59,6 +59,8 @@ RrColor *RrColorNew(const RrInstance *inst, gint r, gint g, gint b)
 void RrColorFree(RrColor *c)
 {
     if (c) {
+        if (c->pixel) XFreeColors(RrDisplay(c->inst), RrColormap(c->inst),
+                                  &c->pixel, 1, 0);
         if (c->gc) XFreeGC(RrDisplay(c->inst), c->gc);
         g_free(c);
     }
index 94d9fa2db47e48f2805cf29c41d021b247f782f3..a099c0930812a01bffb2b0be794a817a6f2e43cc 100644 (file)
@@ -226,5 +226,7 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     XftDrawStringUtf8(d, &c, t->font->xftfont, x,
                       t->font->xftfont->ascent + y,
                       (FcChar8*)text->str, l);
+
+    g_string_free(text, TRUE);
     return;
 }
index 26f67c4d379b961a7b03bbef780b7c9f813bc07f..2db767e6d1f9c2f2a99b2a2ba0044333a344c8d1 100644 (file)
@@ -506,14 +506,20 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
                          "window.button.toggled.focus",
                         theme->a_toggled_focused_max,
                          TRUE))
+    {
+        RrAppearanceFree(theme->a_toggled_focused_max);
         theme->a_toggled_focused_max =
             RrAppearanceCopy(theme->a_focused_pressed_max);
+    }
     if (!read_appearance(db, inst,
                          "window.button.toggled.unfocus",
                         theme->a_toggled_unfocused_max,
                          TRUE))
+    {
+        RrAppearanceFree(theme->a_toggled_unfocused_max);
         theme->a_toggled_unfocused_max =
             RrAppearanceCopy(theme->a_unfocused_pressed_max);
+    }
     if (!read_appearance(db, inst,
                          "window.button.focus",
                         theme->a_focused_unpressed_max,
@@ -528,14 +534,20 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
                          "window.button.hover.focus",
                         theme->a_hover_focused_max,
                          TRUE))
+    {
+        RrAppearanceFree(theme->a_hover_focused_max);
         theme->a_hover_focused_max =
             RrAppearanceCopy(theme->a_focused_unpressed_max);
+    }
     if (!read_appearance(db, inst,
                          "window.button.hover.unfocus",
                         theme->a_hover_unfocused_max,
                          TRUE))
+    {
+        RrAppearanceFree(theme->a_hover_unfocused_max);
         theme->a_hover_unfocused_max =
             RrAppearanceCopy(theme->a_unfocused_unpressed_max);
+    }
 
     theme->a_disabled_focused_close =
         RrAppearanceCopy(theme->a_disabled_focused_max);
@@ -877,6 +889,7 @@ void RrThemeFree(RrTheme *theme)
         RrColorFree(theme->menu_title_color);
         RrColorFree(theme->menu_disabled_color);
         RrColorFree(theme->menu_hilite_color);
+        RrColorFree(theme->menu_bullet_color);
 
         RrPixmapMaskFree(theme->max_mask);
         RrPixmapMaskFree(theme->max_toggled_mask);
This page took 0.030544 seconds and 4 git commands to generate.