After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726856 - cairo is unusable from unbound 'draw' signal (in gstreamer)
cairo is unusable from unbound 'draw' signal (in gstreamer)
Status: RESOLVED DUPLICATE of bug 694604
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-03-22 01:11 UTC by Allison Karlitskaya (desrt)
Modified: 2015-02-07 16:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Allison Karlitskaya (desrt) 2014-03-22 01:11:52 UTC
Here's an example program:

from gi.repository import cairo
from gi.repository import Gst

print Gst.version()

def draw_overlay(overlay, cr, timestamp, duration):
    cr.move_to(0,0)

Gst.init([])

pl = Gst.parse_launch('filesrc location=test.png ! pngdec ! videoconvert ! cairooverlay name=overlay ! videoconvert ! pngenc ! filesink location=out.png')
overlay = pl.get_by_name('overlay')
overlay.connect('draw', draw_overlay)

pl.set_state(Gst.State.PLAYING)
pl.get_bus().timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS | Gst.MessageType.ERROR)
pl.set_state(Gst.State.NULL)


When you run it, this happens:

(1L, 3L, 0L, 1L)
Traceback (most recent call last):
  • File "testcase.py", line 9 in draw_overlay
    cr.move_to(0,0)
AttributeError: 'Context' object has no attribute 'move_to'


If you remove the "import cairo" at the top then it says:

AttributeError: 'gobject.GBoxed' object has no attribute 'move_to'


Printing out the 'cr' from the callback shows this:

<CairoContext at 0x7fa65c019400>

whereas a similar Gtk program (with the 'draw' signal on a GtkWindow) shows this:

<cairo.Context object at 0x7ffda9629310>


GStreamer doesn't install header files for its various elements and therefore there is no corresponding .gir verbiage for the GstCairoOverlay object, which might be the source of this problem.

Gtk's .gir file has this bit, meanwhile:

      <glib:signal name="draw" when="last" version="3.0">
        <doc xml:space="preserve">

--snip--

        </doc>
        <return-value transfer-ownership="none">
          <doc xml:space="preserve">%TRUE to stop other handlers from being invoked for the event.
   % %FALSE to propagate the event further.</doc>
          <type name="gboolean" c:type="gboolean"/>
        </return-value>
        <parameters>
          <parameter name="cr" transfer-ownership="none">
            <doc xml:space="preserve">the cairo context to draw to</doc>
            <type name="cairo.Context"/>
          </parameter>
        </parameters>
      </glib:signal>


Both objects define their signals in similar ways in C:

GtkWidget:

  widget_signals[DRAW] =
    g_signal_new (I_("draw"),
                   G_TYPE_FROM_CLASS (gobject_class),
                   G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GtkWidgetClass, draw),
                   _gtk_boolean_handled_accumulator, NULL,
                   gtk_widget_draw_marshaller,
                   G_TYPE_BOOLEAN, 1,
                   CAIRO_GOBJECT_TYPE_CONTEXT);

gstreamer cairo overlay (part of gst-plugins-good):

  gst_cairo_overlay_signals[SIGNAL_DRAW] =
      g_signal_new ("draw",
      G_TYPE_FROM_CLASS (klass),
      0,
      0,
      NULL,
      NULL,
      g_cclosure_marshal_generic,
      G_TYPE_NONE, 3, CAIRO_GOBJECT_TYPE_CONTEXT, G_TYPE_UINT64, G_TYPE_UINT64);

ie: they are both using CAIRO_GOBJECT_TYPE_CONTEXT -- not a boxed type.


I'm really not sure what's going on here but given the similar signal declarations, it seems that it is surely an issue in either gobject-introspection or pygobject -- possibly related to the lack of an explicit .gir description of the GstCairoOverlay object.
Comment 1 Allison Karlitskaya (desrt) 2014-03-22 04:28:46 UTC

*** This bug has been marked as a duplicate of bug 694604 ***
Comment 2 André Klapper 2015-02-07 16:46:33 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]