[PyQt] RuntimeError: underlying C/C++ object has been deleted

Alexandr N Zamaraev tonal at promsoft.ru
Thu Apr 23 11:12:39 BST 2009


Os Windows Vista Home Ru + sp1
g++ (GCC) 3.4.5 (mingw-vista special r3)
Qt 4.5 (self build)
sip-4.7.9 (self build)
PyQt-win-gpl-4.4.4.zip (self build)

I was unable to allocate a minimum example. Here is pseudocode situations:
[code]

class BaseData(QObject):
   def save(self, obj):
     self.emit(QtCore.SIGNAL('datat_change'), obj)

class Model(QAbstractItemModel):
   def __init__(self, data):
     #  data Mast be derived from BaseData
     self.connect(
       data, QtCore.SIGNAL('data_change'), self.__data_changes)

   def __data_changes(self, arg):
     row = self.__getRowForArg(arg)
     ind = self.createIndex(row, 0, self.objects[row]) #!!! RuntimeError

class Mixin(object):
   data = None #Mast be derived from BaseData
   result = None #Setup brfore accept()
   def __init__(self, ...):
     ...
   def initUi(self):
     ui = self.__ui = Ui_DlgFrame()
     ui.setupUi(self)
     model = self.__model = self.Model(self.dataCls.singleton())
     ui.tableView.setModel(model)

class DlgFrame(QDialog, Mixin):
   def __init__(self, data, parent=None, ...):
     QDialog.__init__(self, parent)
     Mixin.__init__(self, ...)
     self.initUi()

   @classmethod
   def getRes(cls, parent ...):
     frm = cls(parent, ...)
     if frm.exec_() == QtGui.QDialog.Accepted:
       return frm._result
     return None

class FinalDlg(DlgFrame, ...):
   # This class generated by function 'type'
   dataCls = FinalData #Derived from BaseData

class Main(QMainWindow):
   def __init__(self):
     data = FinalData.singleton()

   @QtCore.pyqtSignature('')
   def on_btGetRes_clicked(self):
     self.res = FinalDlg.getRes(self, ...)

   @QtCore.pyqtSignature('')
   def on_btSaveRes_clicked(self):
     self.data.save(self.res)
[/code]
Scenario for reproduction:
start Application
press btGetRes
press btSaveRes

In PyQt-win-gpl-4.5-snapshot-20090419.zip error also.


More information about the PyQt mailing list