[Webkit-unassigned] [Bug 122996] New: [GStreamer][GTK] Add GRefPtr::outPtr()
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Oct 17 14:40:39 PDT 2013
https://bugs.webkit.org/show_bug.cgi?id=122996
Summary: [GStreamer][GTK] Add GRefPtr::outPtr()
Product: WebKit
Version: 528+ (Nightly build)
Platform: Unspecified
OS/Version: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: Platform
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: b.long at cablelabs.com
I keep getting requests in reviews to use GRefPtr in cases like this:
GstObject* x;
g_object_get(y, "some-property", &x, NULL);
/* stuff */
gst_object_unref(x);
The problem is that to use a GRefPtr, we'd need to do:
GstObject* xRawPtr;
g_object_get(y, "some-property", &xRawPtr, NULL);
GRefPtr<GstObject> x = adoptGRef(xRawPtr);
/* stuff */
Which is really awkward.
This patch adds this to GRefPtr:
T*& outPtr()
{
ASSERT(!m_ptr);
return m_ptr;
}
Which lets me do this:
GRefPtr<GstObject> x;
g_object_get(y, "some-property", &x.outPtr(), NULL);
/* stuff */
Messing with outPtr() has the same effect as adoptGRef() (no extra ref). As far as I can tell, g_object_get and related functions always ref their out parameters, so I think this is reasonably safe.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list