[gstreamer-bugs] [Bug 539108] gst_ghost_pad_new() does more than call g_object_new()
GStreamer (bugzilla.gnome.org)
bugzilla-daemon at bugzilla.gnome.org
Sat Jun 28 21:45:37 PDT 2008
If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
http://bugzilla.gnome.org/show_bug.cgi?id=539108
GStreamer | gstreamer (core) | Ver: HEAD CVS
------- Comment #10 from José Alburquerque 2008-06-29 04:45 UTC -------
(In reply to comment #9)
> if you just call g_object_new()
> you could create broken object instances as g_object_new() can't fail.
>
I know the question is not at me, but I think I should answer what is relevant
as to this case, though Murray may want to address other things: As I think
you already know, in C++, objects can inherit from parent classes, etc. In
this case, Gst::GhostPad inherits from Gst::Pad which inherits from Gst::Object
(GstObject) which in the gstreamermm C++ bindings inherits from the
Glib::Object class for convenience (This is all pretty much as what happens
with GObjects in C).
In the C++ bindings, when developers want to create a ghost pad, for example,
they would use a create() method (with the appropriate parameters) which
instantiates the object (using a C++ new statement) and returns the object
"embedded" in a Glib::RefPtr class (which handles automatic object
referencing/unreferencing and object destruction when the reference reaches
zero).
When the object is instantiated, the constructors of the classes that the
object inherits from, starting from the base class (in this case Glib;:Object)
and ending with its most derived constructor (in this case Gst::GhostPad), are
called. (Please note that a class, like Gst::GhostPad, can have more than one
constructor and they are distinguished by the parameter list they use.)
In these C++ bindings, all GObjects are ultimately created in the Glib::Object
constructor with a call to g_object_newv() and kept in the derived object
itself (in this case the Gst::GhostPad object).
In this particular case, with the patch I provided, once the GObject is created
and stored in the Gst::GhostPad, the appropriate Gst::GhostPad constructor uses
one of the gst_ghost_pad_construct*() functions to appropriately "construct"
the GObject as valid GStreamer GstGhostPad. If the construction fails (the
gboolean return), the constructor provides a warning to the developer, though
the C++ object still exists without a valid GstGhostPad GObject. The
developers can then debug their code because it's probably an error in the way
they tried to create the Gst::GhostPad. I hope this all makes sense.
--
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.
You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=539108.
More information about the Gstreamer-bugs
mailing list