Igors - 2013-12-01

Hi

python
dlg = QDialog()
btOk = QPushButton("Ok", dlg)
btOk.released.connect(dlg.accept)
del dlg

With any python-style connect (released.connect here) the "del" removes python variable but destructor ~QDialog is NOT called. Same effect if use removeVariable instead. If I add btOk.released.disconnect, then all is fine, dialog destroyed, but it's inconvenoent to roll back all connects. I've modified code as following

bool PythonQtSignalReceiver::addSignalHandler(const char signal, PyObject callable)
{
bool flag = false;
int sigId = getSignalIndex(signal);
if (sigId>=0) {
// create PythonQtMethodInfo from signal
QMetaMethod meta = _obj->metaObject()->method(sigId);
const PythonQtMethodInfo* signalInfo = PythonQtMethodInfo::getCachedMethodInfo(meta, _objClassInfo);
PythonQtSignalTarget t(sigId, signalInfo, _slotCount, callable);
_targets.append(t);

//II placing in _target incremented callable refcount
Py_DECREF(callable);
//
// now connect to ourselves with the new slot id
QMetaObject::connect(_obj, sigId, this, _slotCount, Qt::AutoConnection, 0);

Please suggest/advice a better solution
Thx

 

Last edit: Igors 2013-12-01