summaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-08-12 16:56:39 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-08-12 18:28:44 -0300
commitb261ff4642d4c4cc7e33862c3ea1477e3e6d89fc (patch)
treea3c7bdabaa16eb3162425ed781e925aa05d7f7d6 /libpyside
parent01b90a3a587d6afd9ec4bf3d6ad2ea83a9548b6d (diff)
downloadpyside-b261ff4642d4c4cc7e33862c3ea1477e3e6d89fc.tar.gz
pyside-b261ff4642d4c4cc7e33862c3ea1477e3e6d89fc.tar.xz
pyside-b261ff4642d4c4cc7e33862c3ea1477e3e6d89fc.zip
Fix bug 953 - "Segfault when QObject is garbage collected after QTimer.singeShot"
Reviewer: Renato Ara├║jo <renato.filho@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/signalmanager.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp
index b24d0b9..b7b9b3d 100644
--- a/libpyside/signalmanager.cpp
+++ b/libpyside/signalmanager.cpp
@@ -323,11 +323,13 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
PyObject* pp_name = 0;
QMetaProperty mp;
PyObject* pySelf = 0;
+ int methodCount = metaObject->methodCount();
+ int propertyCount = metaObject->propertyCount();
if (call != QMetaObject::InvokeMetaMethod) {
mp = metaObject->property(id);
if (!mp.isValid())
- return id - metaObject->methodCount();
+ return id - methodCount;
Shiboken::GilState gil;
pySelf = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object);
@@ -337,7 +339,7 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
if (!pp) {
qWarning("Invalid property: %s.", mp.name());
Py_XDECREF(pp_name);
- return id - metaObject->methodCount();
+ return id - methodCount;
}
}
@@ -362,10 +364,13 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
qWarning("Unsupported meta invocation type.");
}
+ // WARNING Isn't safe to call any metaObject and/or object methods beyond this point
+ // because the object can be deleted inside the called slot.
+
if (call == QMetaObject::InvokeMetaMethod)
- id = id - metaObject->methodCount();
+ id = id - methodCount;
else
- id = id - metaObject->propertyCount();
+ id = id - propertyCount;
if (pp || pp_name) {
Shiboken::GilState gil;