gtk: Fix memleaks

It turns out, some simple getters - such as
gdk_drawing_context_get_clip() - love copying things before returning
them.

I guess somebody has to burn cycles...
This commit is contained in:
Benjamin Otte 2016-12-14 00:06:01 +01:00
parent dd1cf1ac0f
commit 3d5173d4ac
2 changed files with 9 additions and 2 deletions

View File

@ -15616,6 +15616,7 @@ gtk_widget_render (GtkWidget *widget,
GtkSnapshot snapshot; GtkSnapshot snapshot;
GskRenderer *renderer; GskRenderer *renderer;
GskRenderNode *root; GskRenderNode *root;
cairo_region_t *clip;
/* We only render double buffered on native windows */ /* We only render double buffered on native windows */
if (!gdk_window_has_native (window)) if (!gdk_window_has_native (window))
@ -15626,11 +15627,13 @@ gtk_widget_render (GtkWidget *widget,
return; return;
context = gsk_renderer_begin_draw_frame (renderer, region); context = gsk_renderer_begin_draw_frame (renderer, region);
clip = gdk_drawing_context_get_clip (context);
gtk_snapshot_init (&snapshot, gtk_snapshot_init (&snapshot,
renderer, renderer,
gdk_drawing_context_get_clip (context), clip,
"Render<%s>", G_OBJECT_TYPE_NAME (widget)); "Render<%s>", G_OBJECT_TYPE_NAME (widget));
cairo_region_destroy (clip);
gtk_widget_snapshot (widget, &snapshot); gtk_widget_snapshot (widget, &snapshot);
root = gtk_snapshot_finish (&snapshot); root = gtk_snapshot_finish (&snapshot);
if (root != NULL) if (root != NULL)
@ -15646,5 +15649,6 @@ gtk_widget_render (GtkWidget *widget,
gsk_render_node_unref (root); gsk_render_node_unref (root);
} }
gsk_renderer_end_draw_frame (renderer, context); gsk_renderer_end_draw_frame (renderer, context);
} }

View File

@ -461,11 +461,13 @@ gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
{ {
GtkInspectorRecording *recording; GtkInspectorRecording *recording;
GdkFrameClock *frame_clock; GdkFrameClock *frame_clock;
cairo_region_t *clip;
if (!gtk_inspector_recorder_is_recording (recorder)) if (!gtk_inspector_recorder_is_recording (recorder))
return; return;
frame_clock = gtk_widget_get_frame_clock (widget); frame_clock = gtk_widget_get_frame_clock (widget);
clip = gdk_drawing_context_get_clip (context);
recording = gtk_inspector_render_recording_new (gdk_frame_clock_get_frame_time (frame_clock), recording = gtk_inspector_render_recording_new (gdk_frame_clock_get_frame_time (frame_clock),
gsk_renderer_get_profiler (renderer), gsk_renderer_get_profiler (renderer),
@ -473,10 +475,11 @@ gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
gdk_window_get_width (window), gdk_window_get_width (window),
gdk_window_get_height (window) }, gdk_window_get_height (window) },
region, region,
gdk_drawing_context_get_clip (context), clip,
node); node);
gtk_inspector_recorder_add_recording (recorder, recording); gtk_inspector_recorder_add_recording (recorder, recording);
g_object_unref (recording); g_object_unref (recording);
cairo_region_destroy (clip);
} }
// vim: set et sw=2 ts=2: // vim: set et sw=2 ts=2: