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 612501 - [patch] TypeError in do_simple_paint
[patch] TypeError in do_simple_paint
Status: RESOLVED FIXED
Product: pitivi
Classification: Other
Component: Timeline
Git
Other Linux
: High normal
: 0.13.5
Assigned To: Pitivi maintainers
Pitivi maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-10 20:50 UTC by Stéphane Maniaci
Modified: 2010-04-20 23:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
debug log (138.34 KB, application/x-gzip)
2010-03-20 16:44 UTC, Jean-François Fortin Tam
  Details
Patch fixing call to gtk.gdk.CairoContext.reset_clip (646 bytes, patch)
2010-04-06 17:59 UTC, Philippe Gauthier
none Details | Review

Description Stéphane Maniaci 2010-03-10 20:50:33 UTC
Original bug reported on Launchpad : https://bugs.launchpad.net/ubuntu/+source/pitivi/+bug/536624

Traceback:
 Traceback (most recent call last):
  • File "/usr/lib/pitivi/python/pitivi/ui/curve.py", line 261 in do_simple_paint
    cr.reset_clip()  TypeError: Required argument 'cr' (pos 1) not found

This happens when I add the same clip twice on the timeline and try to overlap them.

Ubuntu Lucid with PiTiVi from Git (0.13.4), PyCairo from Git. I've made some research on the reset_clip() function, and found this tutorial (http://zetcode.com/tutorials/pygtktutorial/drawingII/) containing a script using reset_clip() function, not working as well. I changed this 

-cr.reset_clip() 
+cr.reset_clip(cr, widget.window)

in that script, and it finally worked.

So before reporting a bug against PyCairo, I wanted to know if someone can reproduce that bug or if it has something to do with my installation.
Comment 1 Jean-François Fortin Tam 2010-03-17 19:01:27 UTC
Hmmm. AFAICT, transitions have been merged in pitivi git master a few days ago, and this may change a lot of stuff regarding overlapping clips... can you check if that still applies?
Comment 2 Jean-François Fortin Tam 2010-03-20 16:42:13 UTC
I can finally reproduce this. You have to have a timeline with a bunch of clips in it, and randomly seek to one of the various clips and try hitting the spacebar to play/pause. Once in a while, it won't work (the play button will stay in its previous state), and on Lucid this makes apport pop up everytime! Many users will stumble upon this and apport will annoy the hell out of them.
Comment 3 Jean-François Fortin Tam 2010-03-20 16:44:51 UTC
Created attachment 156627 [details]
debug log
Comment 4 Jean-François Fortin Tam 2010-03-20 16:52:21 UTC
Since a one-liner patch is proposed in comment #1, I'd like someone to review it and see if it makes sense.
Comment 5 Chris Ball 2010-03-26 04:46:06 UTC
No, the patch doesn't directly work for pitivi; widget.window is undefined in the pitivi codebase.  It must be a patch against the other tutorial code that was mentioned.
Comment 6 Nicolas DERIVE 2010-03-28 11:11:53 UTC
Got a traceback :
  • File "/usr/lib/pitivi/python/pitivi/ui/curve.py", line 261 in do_simple_paint
    cr.reset_clip()
TypeError: Required argument 'cr' (pos 1) not found

Comment 7 Nicolas DERIVE 2010-03-28 11:32:09 UTC
oh sorry, I hadn't seen that it was already posted.
Comment 8 Jean-François Fortin Tam 2010-03-29 17:48:12 UTC
print 'reset_clip: %r %r' % (cr, cr.reset_clip)

reveals the following:

reset_clip: <gtk.gdk.CairoContext object at 0xa739c30>
<built-in method reset_clip of gtk.gdk.CairoContext object at 0xa739c30>

Then Bilboed found this:
"Note that code meant to be reusable should not call reset_clip() as it will cause results unexpected by higher-level code which calls clip(). Consider using save() and restore()  around clip() as a more robust means of temporarily restricting the clip region."

We suspect it's a bug in pycairo, needs further investigation.
Comment 9 Philippe Gauthier 2010-03-31 17:14:36 UTC
Solution for Pitivi seems to be to call

    cr.reset_clip(cr=cr, drawable=self.get_canvas())

Also bug seems to come from pygtk, not pycairo. See my comment on Launchpad [1].

[1] https://bugs.launchpad.net/ubuntu/+source/pitivi/+bug/537619/comments/5
Comment 10 Philippe Gauthier 2010-04-06 17:59:19 UTC
Created attachment 158064 [details] [review]
Patch fixing call to gtk.gdk.CairoContext.reset_clip

The attached patch replaces the call to a gtk.gdk.CairoContext by adding the parameters by name.

If PyGtk changes to use "self" instead of requiring a "cr" parameter, it should be transparent.

I am not sure using get_canvas().window is the best way to get the GdkDrawable of the canvas. It is not very well documented, but I don't see a different solution except finding a way not to call reset_clip.
Comment 11 Brandon Lewis 2010-04-06 18:40:08 UTC
I've got a branch on my repo called simple_paint_bug_612501 which substitutes
calls to cr.save()/restore() for cr.reset_clip(). I would prefer to use this
since hopefully it won't break PiTiVi on earlier versions of pygtk.
Comment 12 Edward Hervey 2010-04-07 06:57:02 UTC
Brandon, I tried that patch. Seems to work (don't get that error and timeline seems to display correctly).

I'm having other side-issues which seem unrelated to that patch.

It would be great if someone on lucid could test that patch to confirm.
github.com/emdash/pitivi.git
Comment 13 Jean-François Fortin Tam 2010-04-11 14:24:27 UTC
I tested, and Brandon's patch fixes the issue. Merge it?
Comment 14 Chris Ball 2010-04-20 18:51:42 UTC
Also tested, also fixed the issue.  Please merge.
Comment 15 Brandon Lewis 2010-04-20 23:13:53 UTC
commit a9795568f5a0adca5a4277bf51868a5a30ff99dd
Author: Brandon Lewis <brandon_lewis@alum.berkeley.edu>
Date:   Tue Apr 6 10:59:58 2010 -0700

    pitivi/ui/curve.py: use save/restore instead of reset_clip in simple_paint
    
    closes bug 612501, as we avoid calling the improperly-wrapped
    cr.restore() method