There is an exception that occurs when items are painted, but not immediately reported. On my system (PyQt 4.5.1, Python 2.6), no exceptions are reported when I deactivate a patch in the following way:
def drawItems(painter, items, options): print len(items) for idx, i in enumerate(items): print idx, i if idx > 5: raise ValueError()
Output:
45 0 <PyQt4.QtGui.QGraphicsPathItem object at 0x3585270> 1 <PyQt4.QtGui.QGraphicsSimpleTextItem object at 0x356ca68> 2 <PyQt4.QtGui.QGraphicsSimpleTextItem object at 0x356ce20> 3 <PyQt4.QtGui.QGraphicsSimpleTextItem object at 0x356cc88> 4 <PyQt4.QtGui.QGraphicsSimpleTextItem object at 0x356cc00> 5 <PyQt4.QtGui.QGraphicsSimpleTextItem object at 0x356caf0> 6 <PyQt4.QtGui.QGraphicsSimpleTextItem object at 0x356cb78>
However, as soon as I close the application, the following method prints:
Exception ValueError: ValueError() in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
I tried printing threading.currentThread() , but it returns the same thread, regardless of whether it called inside or outside the drawItems method with the monkey.
In your code, this is most likely due to the fact that you are passing options (which is a list of style options objects) to the individual elements, and not to the corresponding option object. Using this code should give the correct results:
def drawItems(self, painter, items, options): for item, option in zip(items, options): print "Processing", item
Also, you say that self.target is a scene object. The documentation for paint() reads:
This function, which is usually called by QGraphicsView, draws the contents of the element in local coordinates .... The widget argument is optional. If provided, it points to the widget that is drawn; otherwise it is 0. For cached painting, the widget is always 0.
and type QWidget* . QGraphicsScene inherits from QObject and is not widgets, so this is probably wrong too.
However, the fact that the exception is not reported at all or does not immediately suggest some kind of dishonest game, you should contact the attendant.