python segfaulting, MemoryError (PyQt)

Phil Thompson phil at riverbankcomputing.com
Tue Apr 28 10:29:07 CEST 2009


On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" <no at spam.com> wrote:
> Hello,
> 
> I'm experiencing odd errors on both windows and linux with the following 
> code:
> 
> import sys
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> 
> class Options(QDialog):
>     def __init__(self, values):
>         QDialog.__init__(self)
> 
>         self.values = values
> 
>         fooEdit = QLineEdit(values['foo'])
>         self.connect(fooEdit, SIGNAL('textChanged(QString)'),
>                      lambda value: self.optionChanged('foo', value))
> 
>         barEdit = QLineEdit(values['bar'])
>         self.connect(barEdit, SIGNAL('textChanged(QString)'),
>                      lambda value: self.optionChanged('bar', value))
> 
>         layout = QVBoxLayout()
>         layout.addWidget(fooEdit)
>         layout.addWidget(barEdit)
> 
>         self.setLayout(layout)
> 
>     def optionChanged(self, option, value):
>         self.values[option] = value
>         print self.values
> 
> def main(args):
>     app = QApplication(args)
>     values = dict(foo='', bar='')
>     dialog = Options(values)
>     dialog.show()
>     app.exec_()
> 
> if __name__ == '__main__':
>     main(sys.argv)
> 
> 
> If I type a character in fooEdit, another character in barEdit, and then 
> delete the character from barEdit I get an unhandled win32 exception
> occured 
> in python.exe on windows and segfault on linux.
> 
> If I type a character in fooEdit, delete it, and then type a character in

> barEdit I get:
> 
> {'foo': PyQt4.QtCore.QString(u'a'), 'bar': ''}
> {'foo': PyQt4.QtCore.QString(u''), 'bar': ''}
> {'foo': Traceback (most recent call last):
>   File "L:\home\dev\python\test.py", line 17, in <lambda>
>     lambda value: self.optionChanged('bar', value))
>   File "L:\home\dev\python\test.py", line 27, in optionChanged
>     print self.values
> MemoryError
> 
> I'm using Python 2.5.4 and PyQt 4.4.3-1
> 
> Thanks in advance for any help.

Works fine for me with current versions.

Phil



More information about the Python-list mailing list