Re: [PyQt] assertion failure in sip

2011-09-16 Thread Phil Thompson
On Fri, 16 Sep 2011 22:28:24 +0200, Erik Janssens
 wrote:
> Hi,
> 
> I'm seeing an assertion failure in sip, stacktrace
> attached.
> 
> It happens consistently, but only after long stress
> tests of a large application.
> 
> Any suggestions on what might be causing this
> failure, so I can try to isolate the case ?

It looks like there might be a race condition when the Python object
wrapping the QWidget is being garbage collected and the QWidget itself is
still calling it's virtual methods.

This is supposed to be taken care of by the "if (sipSelf == NULL)" test
earlier in the function. This test is done without the GIL. The pointer
being tested is set in dealloc_QWidget() (with the GIL).

Therefore if the Python object is in the process of being garbage
collected but before dealloc_QWidget() gets a chance to reset the pointer,
and then QWidget::changeEvent() gets called then there might be a problem.

The fix would be to do the test with the GIL but that requires a change to
the signature of sip_api_is_py_method() to pass a pointer to the pointer
being tested rather than the pointer itself.

Watch this space...

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] TypeError object of type int has no len issue

2011-09-16 Thread Muhammad Bashir Al-Noimi

  
  
On 13/09/2011 06:03 م, Baz Walter
  wrote: 
On
  13/09/11 15:14, ad...@mbnoimi.net wrote: 
  
  the signature for showSplash is: 
  
      def showSplash(self, delay, messages, alignment, color): 
  
  but you're calling it with: 
  
      splash.showSplash(0,  50, messages,  QColor(255,  255,  0)) 
  
  you could have debugged this easily by adding the following line
  before the offending for loop: 
  
      print type(messages), repr(messages) 
  
  also, if the for loop would be much better written as: 
  
      for message in messages: 
  # do stuff with message 
  
  or, if you need the index: 
  
      for index, message in enumerate(messages): 
  # do stuff with index and message 
Thanks, 


I fixed the class and now it's working well. You can find it in
  the attachment.
 
  

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class TeSplashScreen(QFrame):
"""
Splash doc
"""
 
app = QApplication(sys.argv)
sPixmap = QPixmap(10,  10)
sMessage = QString("")
sAlignment = 0
sColor = QColor(255,  255,  0)
   
def __init__(self,  pixmap):
super(QFrame,  self).__init__()
self.sPixmap =  pixmap
self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setFixedSize(pixmap.size())
   
def clearMessage(self):
self.sMessage.clear()
self.repaint()
   
def showMessage(self,  theMessage, theAlignment, theColor):
self.sMessage  = theMessage
self.sAlignment = theAlignment
self.sColor  = theColor
self.repaint()
   
def paintEvent(self, pe):
aTextRect = QRect(self.rect())
aTextRect.setRect(aTextRect.x()+5, aTextRect.y()+5, 
aTextRect.width()-10, aTextRect.height()-10)
aPainter = QPainter(self)
aPainter.drawPixmap(self.rect(), self.sPixmap)
aPainter.setPen(self.sColor)
aPainter.drawText(aTextRect, self.sAlignment, self.sMessage)
   
def showSplash(self,  delay, messages, alignment, color):
class SleeperThread(QThread):
msecs = 0
QThread.msleep(msecs)
aSplashScreen = TeSplashScreen(self.sPixmap)
aSplashScreen.show()
for i in range(len(messages)):
aSplashScreen.showMessage(messages[i], self.sAlignment, color)
SleeperThread.msleep(delay)

def showSplash(self,  delaies, defaultDelay,  messages, alignment, color):
class SleeperThread(QThread):
msecs = 0
QThread.msleep(msecs)
aSplashScreen = TeSplashScreen(self.sPixmap)
aSplashScreen.show()
for i in range(len(messages)):
aSplashScreen.showMessage(messages[i], self.sAlignment, color)
if i___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] assertion failure in sip

2011-09-16 Thread Erik Janssens
Hi,

I'm seeing an assertion failure in sip, stacktrace
attached.

It happens consistently, but only after long stress
tests of a large application.

Any suggestions on what might be causing this
failure, so I can try to isolate the case ?

Thanks,

Erik
Program terminated with signal 11, Segmentation fault.
#0  0xb56623d6 in sip_api_is_py_method (gil=0xbfa65e08, pymc=0xc4ebde7 "", 
sipSelf=0x1057092c, cname=0x0, mname=0xb6c21297 "changeEvent") at siplib.c:7598
7598assert(PyTuple_Check(mro));
(gdb) 
(gdb) 
(gdb) 
(gdb) 
(gdb) 
(gdb) bt
#0  0xb56623d6 in sip_api_is_py_method (gil=0xbfa65e08, pymc=0xc4ebde7 "", 
sipSelf=0x1057092c, cname=0x0, mname=0xb6c21297 "changeEvent") at siplib.c:7598
#1  0xb6bf762c in sipQWidget::changeEvent (this=0xc4ebdb0, a0=0xc164920) at 
sipQtGuiQWidget.cpp:967
#2  0xb5b3a514 in QWidget::event (this=0xc4ebdb0, event=0xc164920) at 
kernel/qwidget.cpp:8529
#3  0xb6bf6425 in sipQWidget::event (this=0xc4ebdb0, a0=0xc164920) at 
sipQtGuiQWidget.cpp:473
#4  0xb5addb26 in QApplicationPrivate::notify_helper (this=0xa41a618, 
receiver=0xc4ebdb0, e=0xc164920) at kernel/qapplication.cpp:4462
#5  0xb5add865 in QApplication::notify (this=0xa260fd0, receiver=0xc4ebdb0, 
e=0xc164920) at kernel/qapplication.cpp:4427
#6  0xb6ba6af2 in sipQApplication::notify (this=0xa260fd0, a0=0xc4ebdb0, 
a1=0xc164920) at sipQtGuiQApplication.cpp:312
#7  0xb57eaf9e in QCoreApplication::notifyInternal (this=0xa260fd0, 
receiver=0xc4ebdb0, event=0xc164920) at kernel/qcoreapplication.cpp:731
#8  0xb5acfab5 in QCoreApplication::sendEvent (receiver=0xc4ebdb0, 
event=0xc164920) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#9  0xb57ebf92 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, 
event_type=0, data=0xa349770) at kernel/qcoreapplication.cpp:1372
#10 0xb57ebc89 in QCoreApplication::sendPostedEvents (receiver=0x0, 
event_type=0) at kernel/qcoreapplication.cpp:1265
#11 0xb5b93b7e in QCoreApplication::sendPostedEvents () at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:220
#12 0xb5b9e90c in QEventDispatcherX11::processEvents (this=0xa34db70, 
flags=...) at kernel/qeventdispatcher_x11.cpp:75
#13 0xb57eb397 in QCoreApplication::processEvents (flags=...) at 
kernel/qcoreapplication.cpp:923
#14 0xb519d577 in meth_QCoreApplication_processEvents (sipArgs=0xb748b02c, 
sipKwds=0x0) at sipQtCoreQCoreApplication.cpp:667
#15 0xb7700ed8 in PyCFunction_Call (func=0xeefb84c, arg=0xb748b02c, kw=0x0) at 
Objects/methodobject.c:85

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt