From 0ae3388b6a6cef0f33f26369ccc3cdd5687ea930 Mon Sep 17 00:00:00 2001 From: Dave Foster Date: Thu, 20 Sep 2007 22:36:52 -0400 Subject: [PATCH] Button proper freeing/newing. --- obrender/button.c | 35 ++++++++++++++++++++++++----------- obrender/button.h | 3 --- obrender/render.c | 2 -- obrender/render.h | 3 --- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/obrender/button.c b/obrender/button.c index 5d3f9203..399888dc 100644 --- a/obrender/button.c +++ b/obrender/button.c @@ -6,15 +6,12 @@ #include #include -static void RrButtonFreeReal(RrButton* b); - RrButton *RrButtonNew (const RrInstance *inst) { RrButton *out = NULL; out = g_new(RrButton, 1); out->inst = inst; - out->ref = 1; /* no need to alloc colors, set them null (for freeing later) */ out->focused_unpressed_color = NULL; @@ -60,14 +57,7 @@ RrButton *RrButtonNew (const RrInstance *inst) return out; } -void RrButtonFree(RrButton *b) -{ - b->ref--; - if (b->ref <= 0) - RrButtonFreeReal(b); -} - -void RrButtonFreeReal(RrButton* b) +void RrButtonFree(RrButton* b) { /* colors */ if (b->focused_unpressed_color) @@ -100,4 +90,27 @@ void RrButtonFreeReal(RrButton* b) RrColorFree(b->toggled_unfocused_unpressed_color); /* masks */ + if (mask) RrPixmapMaskFree(mask); + if (pressed_mask) RrPixmapMaskFree(pressed_mask); + if (disabled_mask) RrPixmapMaskFree(disabled_mask); + if (hover_mask) RrPixmapMaskFree(hover_mask); + if (toggled_mask) RrPixmapMaskFree(toggled_mask); + if (toggled_hover_mask) RrPixmapMaskFree(toggled_hover_mask); + if (toggled_pressed_mask) RrPixmapMaskFree(toggled_pressed_mask); + + /* appearances */ + RrAppearanceFree(a_focused_unpressed); + RrAppearanceFree(a_unfocused_unpressed); + RrAppearanceFree(a_focused_pressed); + RrAppearanceFree(a_unfocused_pressed); + RrAppearanceFree(a_disabled_focused); + RrAppearanceFree(a_disabled_unfocused); + RrAppearanceFree(a_hover_focused); + RrAppearanceFree(a_hover_unfocused); + RrAppearanceFree(a_toggled_focused_unpressed); + RrAppearanceFree(a_toggled_unfocused_unpressed); + RrAppearanceFree(a_toggled_focused_pressed); + RrAppearanceFree(a_toggled_unfocused_pressed); + RrAppearanceFree(a_toggled_hover_focused); + RrAppearanceFree(a_toggled_hover_unfocused); } diff --git a/obrender/button.h b/obrender/button.h index 75459642..59d04f94 100644 --- a/obrender/button.h +++ b/obrender/button.h @@ -10,9 +10,6 @@ struct _RrButton { const RrInstance *inst; - /* reference count */ - gint ref; - /* colors */ RrColor *focused_unpressed_color; RrColor *unfocused_unpressed_color; diff --git a/obrender/render.c b/obrender/render.c index 7a342042..cb698d6b 100644 --- a/obrender/render.c +++ b/obrender/render.c @@ -204,7 +204,6 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex) out = g_slice_new0(RrAppearance); out->inst = inst; - out->ref = 1; out->textures = numtex; out->surface.bevel_light_adjust = 128; out->surface.bevel_dark_adjust = 64; @@ -247,7 +246,6 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) RrAppearance *copy = g_slice_new(RrAppearance); copy->inst = orig->inst; - copy->ref = 1; spo = &(orig->surface); spc = &(copy->surface); diff --git a/obrender/render.h b/obrender/render.h index a8a8fe36..dad3c540 100644 --- a/obrender/render.h +++ b/obrender/render.h @@ -222,8 +222,6 @@ struct _RrTexture { struct _RrAppearance { const RrInstance *inst; - gint ref; - RrSurface surface; gint textures; RrTexture *texture; @@ -317,7 +315,6 @@ gulong RrColorPixel (const RrColor *c); GC RrColorGC (RrColor *c); RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex); -RrAppearance *RrAppearanceCopyShallow (RrAppearance *a); RrAppearance *RrAppearanceCopy (RrAppearance *a); void RrAppearanceFree (RrAppearance *a); void RrAppearanceRemoveTextures(RrAppearance *a);