RESOLVED FIXED 71042
Don't use GOwnPtr for ref-counted objects
https://bugs.webkit.org/show_bug.cgi?id=71042
Summary Don't use GOwnPtr for ref-counted objects
Jonathon Jongsma (jonner)
Reported 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.
Attachments
patch to use GRefPtr instead (11.28 KB, patch)
2011-10-27 11:37 PDT, Jonathon Jongsma (jonner)
no flags
[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
Patch (10.79 KB, patch)
2011-10-31 13:26 PDT, Jonathon Jongsma (jonner)
no flags
WebKit Review Bot
Comment 1 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.
Jonathon Jongsma (jonner)
Comment 2 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):
Martin Robinson
Comment 3 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.
Jonathon Jongsma (jonner)
Comment 4 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.
Martin Robinson
Comment 5 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.
Jonathon Jongsma (jonner)
Comment 6 2011-10-31 13:26:10 PDT
WebKit Review Bot
Comment 7 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>
WebKit Review Bot
Comment 8 2011-10-31 17:29:36 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.