[gtk+] gdk: Unset the DrawingContext <-> cairo_t link on dispose
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Unset the DrawingContext <-> cairo_t link on dispose
- Date: Sun, 12 Jun 2016 17:59:01 +0000 (UTC)
commit 0ca59bf85a13b8dc5b516d311df9c37e43566c1f
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jun 12 18:55:34 2016 +0100
gdk: Unset the DrawingContext <-> cairo_t link on dispose
When disposing a GdkDrawingContext we should unset the association
between the instance and the Cairo context; this avoids stale pointers
in case a reference that has acquired on the Cairo context survives the
lifetime of the GdkDrawingContext.
gdk/gdkdrawingcontext.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c
index c082a15..2bf4210 100644
--- a/gdk/gdkdrawingcontext.c
+++ b/gdk/gdkdrawingcontext.c
@@ -64,6 +64,12 @@ gdk_drawing_context_dispose (GObject *gobject)
{
GdkDrawingContext *self = GDK_DRAWING_CONTEXT (gobject);
+ /* Unset the drawing context, in case somebody is holding
+ * onto the Cairo context
+ */
+ if (self->cr != NULL)
+ gdk_cairo_set_drawing_context (self->cr, NULL);
+
g_clear_object (&self->window);
g_clear_pointer (&self->clip, cairo_region_destroy);
g_clear_pointer (&self->cr, cairo_destroy);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]