More binding friendly API for SugarPreview.
Fix a leak.
This commit is contained in:
parent
cd0e6aa101
commit
411879e9de
2
NEWS
2
NEWS
@ -1,3 +1,5 @@
|
||||
* #4768 Fix memory leak when switching between activities. (marco)
|
||||
|
||||
Snapshot 9d28557bbd
|
||||
|
||||
* Fix randr. (marco)
|
||||
|
@ -39,16 +39,22 @@ sugar_preview_get_pixbuf(SugarPreview *preview)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (preview->pixbuf != NULL) {
|
||||
return preview->pixbuf;
|
||||
}
|
||||
|
||||
if (preview->image == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_image(NULL, preview->image, NULL,
|
||||
0, 0, 0, 0,
|
||||
preview->image->width,
|
||||
preview->image->height);
|
||||
preview->pixbuf = gdk_pixbuf_get_from_image(NULL, preview->image, NULL,
|
||||
0, 0, 0, 0,
|
||||
preview->image->width,
|
||||
preview->image->height);
|
||||
g_object_unref(G_OBJECT(preview->image));
|
||||
preview->image = NULL;
|
||||
|
||||
return pixbuf;
|
||||
return preview->pixbuf;
|
||||
}
|
||||
|
||||
void
|
||||
@ -58,6 +64,10 @@ sugar_preview_clear(SugarPreview *preview)
|
||||
g_object_unref(G_OBJECT(preview->image));
|
||||
preview->image = NULL;
|
||||
}
|
||||
if (preview->pixbuf != NULL) {
|
||||
g_object_unref(G_OBJECT(preview->pixbuf));
|
||||
preview->pixbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -104,4 +114,5 @@ static void
|
||||
sugar_preview_init(SugarPreview *preview)
|
||||
{
|
||||
preview->image = NULL;
|
||||
preview->pixbuf = NULL;
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ struct _SugarPreview {
|
||||
GObject base_instance;
|
||||
|
||||
GdkImage *image;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user