GNOME Bugzilla – Bug 752790
Invalid refcounting in Gst::Element::post_message()
Last modified: 2016-10-03 14:17:33 UTC
Gst::Element::post_message() should take ownership of the passed message because gst_element_post_message() takes the message argument with transfer full convention. This leads to premature destruction of a message posted through this method. Since gstreamermm now requires C++11, maybe it's a good time to fix it using rvalue reference arguments?
Created attachment 308003 [details] [review] Gst::Element: fix refcounting in post_message()
Review of attachment 308003 [details] [review]: ::: tools/m4/convert_gst.m4 @@ +193,3 @@ _CONVERSION(`GstMessage*',`Glib::RefPtr<const Gst::Message>',`Glib::wrap($3)') _CONVERSION(`const Glib::RefPtr<Gst::Message>&',`GstMessage*', `Glib::unwrap($3)') +_CONVERSION(`Glib::RefPtr<Gst::Message>&&',`GstMessage*',`Gst::unwrap_rvalue(std::move($3))') RefPtr class contains release(), which should be used in unwrap_rvalue. However, as far as we use unwrap_rvalue only in conversion methods, we'd replace it with inline code, something like that: (($3) ? $3.release()->gobj() : nullptr).
I pushed your patch (slightly modified).
Why `($3) ? $3.release()->gobj() : nullptr' is better than `Gst::unwrap_rvalue(std::move($3))'? Doesn't the second one improve readability? I wanted to replace all these trynary-inline-conversion with unwrap_rvalue.
(In reply to Tomasz from comment #4) > Why `($3) ? $3.release()->gobj() : nullptr' is better than > `Gst::unwrap_rvalue(std::move($3))'? > > Doesn't the second one improve readability? I wanted to replace all these > trynary-inline-conversion with unwrap_rvalue. Sure, we can do that.