diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-30 11:50:26 +1100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-30 12:07:13 +1100 |
commit | 702493053063688e6341fc1cfc3f9450c120b4ba (patch) | |
tree | 59812751b99a9e2a1ee361ab24daf66d0ee38151 | |
parent | 410c439aef09a72fe828f6c7b8a69558684c67f4 (diff) | |
download | subsurface-702493053063688e6341fc1cfc3f9450c120b4ba.tar.gz |
Properly destroy the cairo context when we're done with it
Henrik reports that on OSX, not destroying the cairo context results in
a corrupted profile display. It seems to just leak memory on Linux.
For gtk3, the cairo context is embedded in the GtkDrawable, for gtk2 we
need to create and destroy it appropriately. Although maybe we could
just make it static instead of creating/destroying it all the time.
Anyway, this goes back to the old cairo destroy logic for gtk2.
Reported-and-analyzed-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | gtk-gui.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1692,7 +1692,7 @@ static gboolean profile_tooltip (GtkWidget *widget, gint x, gint y, static double zoom_factor = 1.0; static int zoom_x = -1, zoom_y = -1; -static gboolean common_drawing_function(GtkWidget *widget, struct graphics_context *gc) +static void common_drawing_function(GtkWidget *widget, struct graphics_context *gc) { int i = 0; struct dive *dive = current_dive; @@ -1724,8 +1724,6 @@ static gboolean common_drawing_function(GtkWidget *widget, struct graphics_conte tooltips = 0; plot(gc, dive, SC_SCREEN); } - - return FALSE; } #if GTK_CHECK_VERSION(3,0,0) @@ -1742,7 +1740,8 @@ static gboolean draw_callback(GtkWidget *widget, cairo_t *cr, gpointer data) gc.drawing_area.height = height; gc.cr = cr; - return common_drawing_function(widget, &gc); + common_drawing_function(widget, &gc); + return FALSE; } #else /* gtk2 */ @@ -1759,7 +1758,9 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer gc.drawing_area.height = allocation.height; gc.cr = gdk_cairo_create(gtk_widget_get_window(widget)); - return common_drawing_function(widget, &gc); + common_drawing_function(widget, &gc); + cairo_destroy(gc.cr); + return FALSE; } #endif |