Merge lp:~azzar1/unity/fix-806485 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1268
Proposed branch: lp:~azzar1/unity/fix-806485
Merge into: lp:unity
Diff against target: 11 lines (+1/-0)
1 file modified
plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp (+1/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-806485
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+67052@code.launchpad.net

Description of the change

In PanelIndicatorObjectEntryView.cpp we have:
================================================================
GdkPixbuf* make_pixbuf(int image_type, std::string const& image_data)
{
  GdkPixbuf* ret = NULL;

  if (image_type == GTK_IMAGE_PIXBUF)
  {
    gsize len = 0;
    guchar* decoded = g_base64_decode(image_data.c_str(), &len);

    GInputStream* stream = g_memory_input_stream_new_from_data(decoded,
                                                               len, NULL);

    ret = gdk_pixbuf_new_from_stream(stream, NULL, NULL);

    g_free(decoded);
    g_input_stream_close(stream, NULL, NULL);
  }
  ...
==================================================================

This is leaking since g_input_stream_close doesn't unref the stream... I've just added a g_object_unref(stream).
We could remove g_input_stream_close since «Streams will be automatically closed when the last reference is dropped, but you might want to call this function to make sure resources are released as early as possible.» (http://developer.gnome.org/gio/stable/GInputStream.html#g-input-stream-close)

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

On Thu, 07 Jul 2011 02:45:55 you wrote:
> The proposal to merge lp:~andyrock/unity/fix-806485 into lp:unity has been
> updated.
>
> Description changed to:
>
> In PanelIndicatorObjectEntryView.cpp we have:
> ================================================================
> GdkPixbuf* make_pixbuf(int image_type, std::string const& image_data)
> {
> GdkPixbuf* ret = NULL;
>
> if (image_type == GTK_IMAGE_PIXBUF)
> {
> gsize len = 0;
> guchar* decoded = g_base64_decode(image_data.c_str(), &len);
>
> GInputStream* stream = g_memory_input_stream_new_from_data(decoded,
> len, NULL);
>
> ret = gdk_pixbuf_new_from_stream(stream, NULL, NULL);
>
> g_free(decoded);
> g_input_stream_close(stream, NULL, NULL);
> }
> ...
> ==================================================================
>
> This is leaking since g_input_stream_close doesn't unref the stream... I've
> just added a g_object_unref(stream). We could remove g_input_stream_close
> since «Streams will be automatically closed when the last reference is
> dropped, but you might want to call this function to make sure resources
> are released as early as possible.»
> (http://developer.gnome.org/gio/stable/GInputStream.html#g-input-stream-cl
> ose)
>
> For more details, see:
> https://code.launchpad.net/~andyrock/unity/fix-806485/+merge/67052

 merge approved

I think it'd be nice to remove the g_input_stream_close method if it isn't
needed.

Tim

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp'
2--- plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp 2011-06-29 15:40:49 +0000
3+++ plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp 2011-07-06 14:42:39 +0000
4@@ -459,6 +459,7 @@
5
6 g_free(decoded);
7 g_input_stream_close(stream, NULL, NULL);
8+ g_object_unref(stream);
9 }
10 else if (image_type == GTK_IMAGE_STOCK ||
11 image_type == GTK_IMAGE_ICON_NAME)