From 7b205a11d6005b6a2d2abb65b876f602d5822a4b Mon Sep 17 00:00:00 2001 From: Julian Lamb Date: Thu, 21 Aug 2008 03:08:12 +0000 Subject: [PATCH] * more leak fixes, including a stub for the HID_attribute free code... Dan? --- src/attribute.c | 6 ++++++ src/callbacks.c | 30 +++++++++++++++--------------- src/gerb_image.c | 2 +- src/gerbv.h | 4 ++++ src/project.c | 13 +++++++++++++ 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/attribute.c b/src/attribute.c index 3ea0671..1405862 100644 --- a/src/attribute.c +++ b/src/attribute.c @@ -58,6 +58,12 @@ static int * auto_uncheck_attr = NULL; static GtkWidget ** all_widgets = NULL; static int n_widgets; +void +attribute_destroy_HID_attribute (gerbv_HID_Attribute *attributeList){ + /* insert destroy code here */ + g_free (attributeList); +} + static void clear_auto() { if( auto_uncheck_needed && auto_uncheck_widget != NULL && auto_uncheck_attr != NULL) { diff --git a/src/callbacks.c b/src/callbacks.c index 72d535c..ebe6082 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -2265,24 +2265,24 @@ callbacks_drawingarea_configure_event (GtkWidget *widget, GdkEventConfigure *eve gdk_window_get_internal_paint_info (window, &drawable, &x_off, &y_off); } visual = gdk_drawable_get_visual (drawable); - if (!screen.windowSurface) { + if (screen.windowSurface) + cairo_surface_destroy ((cairo_surface_t *) + screen.windowSurface); #ifdef WIN32 - cairo_t *cairoTarget = gdk_cairo_create (GDK_WINDOW(widget->window)); - - screen.windowSurface = cairo_get_target (cairoTarget); - /* increase surface reference by one so it isn't freed when the cairo_t - is destroyed next */ - screen.windowSurface = cairo_surface_reference (screen.windowSurface); - cairo_destroy (cairoTarget); + cairo_t *cairoTarget = gdk_cairo_create (GDK_WINDOW(widget->window)); + + screen.windowSurface = cairo_get_target (cairoTarget); + /* increase surface reference by one so it isn't freed when the cairo_t + is destroyed next */ + screen.windowSurface = cairo_surface_reference (screen.windowSurface); + cairo_destroy (cairoTarget); #else - screen.windowSurface = (gpointer) cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable), - GDK_DRAWABLE_XID (drawable), - GDK_VISUAL_XVISUAL (visual), - screenRenderInfo.displayWidth, - screenRenderInfo.displayHeight); + screen.windowSurface = (gpointer) cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable), + GDK_DRAWABLE_XID (drawable), + GDK_VISUAL_XVISUAL (visual), + screenRenderInfo.displayWidth, + screenRenderInfo.displayHeight); #endif - - } #endif /* if this is the first time, go ahead and call autoscale even if we don't have a model loaded */ diff --git a/src/gerb_image.c b/src/gerb_image.c index aea5d54..65ce5e8 100644 --- a/src/gerb_image.c +++ b/src/gerb_image.c @@ -155,7 +155,7 @@ gerbv_destroy_image(gerbv_image_t *image) if (image->info) { g_free(image->info->name); g_free(image->info->type); - g_free(image->info->attr_list); + attribute_destroy_HID_attribute (image->info->attr_list); g_free(image->info); } diff --git a/src/gerbv.h b/src/gerbv.h index fffec3c..c484b15 100644 --- a/src/gerbv.h +++ b/src/gerbv.h @@ -918,3 +918,7 @@ gerbv_stats_add_layer(gerbv_stats_t *accum_stats, gerbv_stats_t *input_stats, int this_layer ); + +void +attribute_destroy_HID_attribute (gerbv_HID_Attribute *attributeList); + diff --git a/src/project.c b/src/project.c index 05605ec..6d8559f 100644 --- a/src/project.c +++ b/src/project.c @@ -423,6 +423,19 @@ read_project_file(char const* filename) } /* read_project */ +void +project_destroy_project_list (project_list_t *projectList){ + project_list_t *tempP,*tempP2; + + for (tempP = projectList; tempP != NULL; ){ + tempP2 = tempP->next; + + g_free (tempP->filename); + attribute_destroy_HID_attribute (tempP->attr_list); + tempP = tempP2; + } +} + /* * Writes a description of a project to a file * that can be parsed by read_project above -- 2.11.4.GIT