Bug 71042 - Don't use GOwnPtr for ref-counted objects
Summary: Don't use GOwnPtr for ref-counted objects
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-27 11:37 PDT by Jonathon Jongsma (jonner)
Modified: 2011-10-31 17:29 PDT (History)
4 users (show)

See Also:


Attachments
patch to use GRefPtr instead (11.28 KB, patch)
2011-10-27 11:37 PDT, Jonathon Jongsma (jonner)
no flags Details | Formatted Diff | Diff
[GStreamer] Don't use GOwnPtr for ref-counted objects https://bugs.webkit.org/show_bug.cgi?id=71042 (11.75 KB, patch)
2011-10-27 12:08 PDT, Jonathon Jongsma (jonner)
no flags Details | Formatted Diff | Diff
Patch (10.79 KB, patch)
2011-10-31 13:26 PDT, Jonathon Jongsma (jonner)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathon Jongsma (jonner) 2011-10-27 11:37:16 PDT
Created attachment 112716 [details]
patch to use GRefPtr instead

In a few places in the gstreamer media player implementation, GOwnPtr is used with ref-counted objects (GstElement, etc).  The implementation is basically correct, but the semantics are confusing because a GOwnPtr is meant to indicate exclusive ownership of memory, whereas ref-counted objects have shared ownership by definition.  Changing to use GRefPtr makes things a bit more verbose (due to not having the outPtr() method), but I think it is more correct and less confusing.
Comment 1 WebKit Review Bot 2011-10-27 11:44:00 PDT
Attachment 112716 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/CMakeListsEfl.txt', u'Sourc..." exit_code: 1

Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp:91:  Declaration has space between type name and * in GstElement *p  [whitespace/declaration] [3]
Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp:91:  Use 0 instead of NULL.  [readability/null] [5]
Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp:163:  Declaration has space between type name and * in GstElement *p  [whitespace/declaration] [3]
Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp:163:  Use 0 instead of NULL.  [readability/null] [5]
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1013:  Declaration has space between type name and * in GstElement *p  [whitespace/declaration] [3]
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1013:  Use 0 instead of NULL.  [readability/null] [5]
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1026:  Declaration has space between type name and * in GstElement *p  [whitespace/declaration] [3]
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1026:  Use 0 instead of NULL.  [readability/null] [5]
Source/WebCore/ChangeLog:1:  ChangeLog entry has no bug number  [changelog/bugnumber] [5]
Total errors found: 9 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 2 Jonathon Jongsma (jonner) 2011-10-27 12:08:33 PDT
Created attachment 112723 [details]
[GStreamer] Don't use GOwnPtr for ref-counted objects https://bugs.webkit.org/show_bug.cgi?id=71042

Reviewed by NOBODY (OOPS!).

* CMakeListsEfl.txt:
* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.pro:
* platform/graphics/gstreamer/GOwnPtrGStreamer.cpp: Removed.
* platform/graphics/gstreamer/GOwnPtrGStreamer.h: Removed.
* platform/graphics/gstreamer/GStreamerGWorld.cpp:
(WebCore::GStreamerGWorld::enterFullscreen):
(WebCore::GStreamerGWorld::exitFullscreen):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::updateAudioSink):
(WebCore::MediaPlayerPrivateGStreamer::sourceChanged):
Comment 3 Martin Robinson 2011-10-27 12:36:16 PDT
Comment on attachment 112723 [details]
[GStreamer] Don't use GOwnPtr for ref-counted objects https://bugs.webkit.org/show_bug.cgi?id=71042

View in context: https://bugs.webkit.org/attachment.cgi?id=112723&action=review

Thanks for the cleanup. Just a nit below.

> Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp:91
> +    GstElement* p = 0;

We typically use full words for variable names in WebKit. If you want you call this videoSinkPtr or maybe we can consider adding a adoptOutPtr method to GRefPtr.

> Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp:163
> +    GstElement* p = 0;

Ditto.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1013
> +    GstElement* p = 0;

Ditto.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1026
> +    GstElement* p = 0;

Ditto.
Comment 4 Jonathon Jongsma (jonner) 2011-10-27 12:41:23 PDT
(In reply to comment #3)
> We typically use full words for variable names in WebKit. 

Indeed, will fix that.

> If you want you call this videoSinkPtr or maybe we can consider adding a adoptOutPtr method to GRefPtr.

I considered adding a method to GRefPtr but decided against it since it has a lot of potential for misuse.  It would basically only ever be safe to use that method when the GRefPtr is NULL.  so I chose the more verbose approach instead.
Comment 5 Martin Robinson 2011-10-27 14:21:47 PDT
(In reply to comment #4)

> I considered adding a method to GRefPtr but decided against it since it has a lot of potential for misuse.  It would basically only ever be safe to use that method when the GRefPtr is NULL.  so I chose the more verbose approach instead.

This could be handled either via a deref of the old value or an ASSERT, but it's fine to avoid doing that for now, I think.
Comment 6 Jonathon Jongsma (jonner) 2011-10-31 13:26:10 PDT
Created attachment 113078 [details]
Patch
Comment 7 WebKit Review Bot 2011-10-31 17:29:31 PDT
Comment on attachment 113078 [details]
Patch

Clearing flags on attachment: 113078

Committed r98924: <http://trac.webkit.org/changeset/98924>
Comment 8 WebKit Review Bot 2011-10-31 17:29:36 PDT
All reviewed patches have been landed.  Closing bug.