mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 05:23:24 +00:00
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>
This commit is contained in:
parent
410c439aef
commit
7024930530
1 changed files with 6 additions and 5 deletions
11
gtk-gui.c
11
gtk-gui.c
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue