summaryrefslogtreecommitdiffstats
path: root/src/script/bridge
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-01-19 10:16:36 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-01-19 10:24:13 (GMT)
commited5fed36f38b9de0452cc427db679266d249f216 (patch)
treedff3381c84823d8db8d505c52ba307c1f20cf014 /src/script/bridge
parent3214e477ccc3eae5c61b357696095f1f460fafbb (diff)
downloadQt-ed5fed36f38b9de0452cc427db679266d249f216.zip
Qt-ed5fed36f38b9de0452cc427db679266d249f216.tar.gz
Qt-ed5fed36f38b9de0452cc427db679266d249f216.tar.bz2
Remove QtScript connection when receiver QObject has been deleted
We don't want to have to listen to the destroyed() signal for every receiver object of a connection, and likewise we don't want to create a QObject to handle each connection; instead, remove the connection lazily at signal emission time after we've detected that the receiver has been deleted. Task-number: QTBUG-7313 Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/script/bridge')
-rw-r--r--src/script/bridge/qscriptqobject.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 3f4f6bb..db312bc 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -2220,7 +2220,14 @@ void QObjectConnectionManager::execute(int slotIndex, void **argv)
JSC::call(exec, slot, callType, callData, thisObject, jscArgs);
if (exec->hadException()) {
- engine->emitSignalHandlerException();
+ if (slot.inherits(&QtFunction::info) && !static_cast<QtFunction*>(JSC::asObject(slot))->qobject()) {
+ // The function threw an error because the target QObject has been deleted.
+ // The connections list is stale; remove the signal handler and ignore the exception.
+ removeSignalHandler(sender(), signalIndex, receiver, slot);
+ exec->clearException();
+ } else {
+ engine->emitSignalHandlerException();
+ }
}
}