python segfaulting, MemoryError (PyQt)

Discussion in 'Python' started by Denis L, Apr 28, 2009.

  1. Denis L

    Denis L Guest

    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.

    Denis
     
    Denis L, Apr 28, 2009
    #1
    1. Advertising

  2. Denis L schrieb:
    > 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


    As the documentation of pyqt clearly states, connecting signals doesn't
    increment the refcount on a passed slot, thus
    you need to keep a reference to your slots around.

    Diez
     
    Diez B. Roggisch, Apr 28, 2009
    #2
    1. Advertising

  3. On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" <> 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
     
    Phil Thompson, Apr 28, 2009
    #3
  4. On Tue, 28 Apr 2009 09:35:31 +0200, "Diez B. Roggisch"
    <>
    wrote:
    > Denis L schrieb:
    >> 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

    >
    > As the documentation of pyqt clearly states, connecting signals doesn't
    > increment the refcount on a passed slot, thus
    > you need to keep a reference to your slots around.


    But it does increase the refcount for lambda slots.

    Phil
     
    Phil Thompson, Apr 28, 2009
    #4
  5. >> As the documentation of pyqt clearly states, connecting signals doesn't
    >> increment the refcount on a passed slot, thus
    >> you need to keep a reference to your slots around.

    >
    > But it does increase the refcount for lambda slots.


    Has that changed? It has been a while, but I've been bitten by this before,
    so I was pretty sure about my answer.

    Diez
     
    Diez B. Roggisch, Apr 28, 2009
    #5
  6. On Tue, 28 Apr 2009 11:18:31 +0200, "Diez B. Roggisch"
    <>
    wrote:
    >>> As the documentation of pyqt clearly states, connecting signals doesn't
    >>> increment the refcount on a passed slot, thus
    >>> you need to keep a reference to your slots around.

    >>
    >> But it does increase the refcount for lambda slots.

    >
    > Has that changed? It has been a while, but I've been bitten by this

    before,
    > so I was pretty sure about my answer.


    Support for lambda slots was add in PyQt v4.1.1 (released December 2006).

    Phil
     
    Phil Thompson, Apr 28, 2009
    #6
  7. Denis L

    Denis L Guest

    "Phil Thompson" <> wrote in message
    news:...
    > On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" <> 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


    I have noticed that if I do "self.values[option] = QString(value)"
    instead of "self.values[option] = value" in optionChanged I don't get any
    errors.

    Is it perhaps not safe to keep the reference to the lambda QString argument?
     
    Denis L, Apr 28, 2009
    #7
  8. On Tue, 28 Apr 2009 14:54:41 +0200, "Denis L" <> wrote:
    > "Phil Thompson" <> wrote in message
    > news:...
    >> On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" <> 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

    >
    > I have noticed that if I do "self.values[option] = QString(value)"
    > instead of "self.values[option] = value" in optionChanged I don't get any


    > errors.
    >
    > Is it perhaps not safe to keep the reference to the lambda QString
    > argument?


    It shouldn't make any difference.

    Phil
     
    Phil Thompson, Apr 28, 2009
    #8
  9. Phil Thompson wrote:

    > On Tue, 28 Apr 2009 11:18:31 +0200, "Diez B. Roggisch"
    > <>
    > wrote:
    >>>> As the documentation of pyqt clearly states, connecting signals doesn't
    >>>> increment the refcount on a passed slot, thus
    >>>> you need to keep a reference to your slots around.
    >>>
    >>> But it does increase the refcount for lambda slots.

    >>
    >> Has that changed? It has been a while, but I've been bitten by this

    > before,
    >> so I was pretty sure about my answer.

    >
    > Support for lambda slots was add in PyQt v4.1.1 (released December 2006).


    Unfortunately after I had the chance to play with PyQt for the last time.
    Thanks for clarifying!

    Diez
     
    Diez B. Roggisch, Apr 28, 2009
    #9
  10. Denis L

    Denis L Guest

    "Phil Thompson" <> wrote in message
    news:...
    > On Tue, 28 Apr 2009 14:54:41 +0200, "Denis L" <> wrote:
    >> "Phil Thompson" <> wrote in message
    >> news:...
    >>> On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" <> 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

    >>
    >> I have noticed that if I do "self.values[option] = QString(value)"
    >> instead of "self.values[option] = value" in optionChanged I don't get any

    >
    >> errors.
    >>
    >> Is it perhaps not safe to keep the reference to the lambda QString
    >> argument?

    >
    > It shouldn't make any difference.
    >
    > Phil


    Last idea, C++ declaration of textChanged signal is this:

    void textChanged (const QString&text)

    would self.values[option] = value store the reference to QString? And if so
    is that safe, to access that object after my slot returns?

    As far as I can see C++ equivalent would be

    QString* pointer = &text; then derferencing that pointer later in the code.
    I can see how this could cause problems.

    Btw you are using PyQt 4.4.4 correct? What version of python?
     
    Denis L, Apr 28, 2009
    #10
  11. On Tue, 28 Apr 2009 17:10:51 +0200, "Denis L" <> wrote:
    > "Phil Thompson" <> wrote in message
    > news:...
    >> On Tue, 28 Apr 2009 14:54:41 +0200, "Denis L" <> wrote:
    >>> "Phil Thompson" <> wrote in message
    >>> news:...
    >>>> On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" <> 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
    >>>
    >>> I have noticed that if I do "self.values[option] = QString(value)"
    >>> instead of "self.values[option] = value" in optionChanged I don't get
    >>> any

    >>
    >>> errors.
    >>>
    >>> Is it perhaps not safe to keep the reference to the lambda QString
    >>> argument?

    >>
    >> It shouldn't make any difference.
    >>
    >> Phil

    >
    > Last idea, C++ declaration of textChanged signal is this:
    >
    > void textChanged (const QString&text)
    >
    > would self.values[option] = value store the reference to QString? And if

    so
    >
    > is that safe, to access that object after my slot returns?
    >
    > As far as I can see C++ equivalent would be
    >
    > QString* pointer = &text; then derferencing that pointer later in the

    code.
    >
    > I can see how this could cause problems.


    If there was a bug with lambda slots it's been fixed by now.

    > Btw you are using PyQt 4.4.4 correct? What version of python?


    PyQt v4.5 snapshot, Python v2.6.2 and v3.0.1.

    Phil
     
    Phil Thompson, Apr 28, 2009
    #11
  12. Denis L

    Denis L Guest

    "Phil Thompson" <> wrote in message
    news:...

    > If there was a bug with lambda slots it's been fixed by now.


    I just tried it and I'm getting the same errors with regular functions.

    Could you try running the code bellow? What output you are getting when
    barTextChanged is called?

    On my system self.foo and text point to the same QString object.

    import sys
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *

    class Options(QDialog):
    def __init__(self):
    QDialog.__init__(self)

    fooEdit = QLineEdit()
    self.connect(fooEdit, SIGNAL('textChanged(QString)'),
    self.fooTextChanged)

    barEdit = QLineEdit()
    self.connect(barEdit, SIGNAL('textChanged(QString)'),
    self.barTextChanged)

    layout = QVBoxLayout()
    layout.addWidget(fooEdit)
    layout.addWidget(barEdit)
    self.setLayout(layout)

    def fooTextChanged(self, text):
    self.foo = text

    def barTextChanged(self, text):
    print self.foo, text, id(self.foo), id(text)

    def main(args):
    app = QApplication(args)
    dialog = Options()
    dialog.show()
    app.exec_()

    if __name__ == '__main__':
    main(sys.argv)
     
    Denis L, Apr 28, 2009
    #12
  13. On Tue, 28 Apr 2009 19:07:30 +0200, "Denis L" <> wrote:
    > "Phil Thompson" <> wrote in message
    > news:...
    >
    >> If there was a bug with lambda slots it's been fixed by now.

    >
    > I just tried it and I'm getting the same errors with regular functions.
    >
    > Could you try running the code bellow? What output you are getting when
    > barTextChanged is called?
    >
    > On my system self.foo and text point to the same QString object.


    I see different objects.

    Phil
     
    Phil Thompson, Apr 28, 2009
    #13
  14. Denis L

    Denis L Guest

    "Phil Thompson" <> wrote in message
    news:...
    > On Tue, 28 Apr 2009 19:07:30 +0200, "Denis L" <> wrote:
    >> "Phil Thompson" <> wrote in message
    >> news:...
    >>
    >>> If there was a bug with lambda slots it's been fixed by now.

    >>
    >> I just tried it and I'm getting the same errors with regular functions.
    >>
    >> Could you try running the code bellow? What output you are getting when
    >> barTextChanged is called?
    >>
    >> On my system self.foo and text point to the same QString object.

    >
    > I see different objects.
    >
    > Phil


    So it really was a PyQt bug. Thanks for your help.
     
    Denis L, Apr 29, 2009
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Rodriguez
    Replies:
    4
    Views:
    440
    Jeff Rodriguez
    Nov 17, 2003
  2. Geoffrey Clements

    Eric3 segfaulting

    Geoffrey Clements, Jul 5, 2003, in forum: Python
    Replies:
    1
    Views:
    313
    Geoffrey Clements
    Jul 5, 2003
  3. ulysses
    Replies:
    4
    Views:
    777
    Werner Schiendl
    Oct 22, 2003
  4. Fernando Perez
    Replies:
    3
    Views:
    331
    Fernando Perez
    Jan 25, 2005
  5. Tim Chase
    Replies:
    4
    Views:
    456
    Magnus Lycka
    Feb 28, 2006
Loading...

Share This Page