[PyQt] QTextEdit crash (sometimes) when used as an ItemEditor

Dan Smith lalkabar69 at hotmail.co.uk
Wed May 12 13:57:33 BST 2010


Hey Guys, 
Got an annoying, reproducable, but inconsistant problem.

I have a property list and its been working "sweet as" for a while.
Pretty much all the items in the model are Strings so the default editor
(QLineEdit) has been used, and works fine.

Now I need to change a couple of the properties to allow more text /
multi-line entries.
Since QMultiLineEdit is no longer available / recommended I've gone with
QTextEdit

And it does "work"...
It's just "every now and again" when you tab or click OFF the QTextEdit...
python crashes.
It doesn't seem to mater whether you've made changes to the contents.. just
tabbing into and straight out of the row can do it.

It's doesn't happen every time, but if you click / tab on then off a few
times it usually does it.
The QLineEdit rows seem rock solid.

Crash Info:
Windows 7 | Python 2.6.5 | QT 4.6.2 | PyQt 4.7.3
Crash Report : Access violation (c00000005) in Qt4Core.dll

Associated Code: (Abridged)

#---------------------
class textEditorCreator(QtGui.QItemEditorCreatorBase):
    def createWidget(self, parent):
        return QtGui.QTextEdit(parent)
#---------------------

class PropertyListItemDelegate(QtGui.QStyledItemDelegate):

    #---- Create Custom Editor if required
    def createEditor( self, parent, option, index ):
        StyledItemDelegate = QtGui.QStyledItemDelegate(self)

        if need_text_editor:
	    #--- Create a new factory that uses QTextEdit for
QVariant.String items
            factory = QtGui.QItemEditorFactory()
            factory.registerEditor(QtCore.QVariant.String,
textEditorCreator())
            StyledItemDelegate.setItemEditorFactory(factory)

        return StyledItemDelegate.createEditor( parent, option, index )
    #---- 
#---------------------

Has anyone seen this behaviour before?
Can you see anything I've missed, or any mistakes in the code?

Cheers
Dan



More information about the PyQt mailing list