diff options
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 3d72990..122c3e5 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -20,6 +20,7 @@ #include "qscriptvalue_p.h" #include "qscriptvalueiterator.h" #include "qscriptclass.h" +#include "qdebug.h" #include <QtCore/qstringlist.h> #include <QtCore/qmetaobject.h> @@ -868,6 +869,7 @@ QScriptEnginePrivate::QScriptEnginePrivate() QScriptEnginePrivate::~QScriptEnginePrivate() { + detachAllRegisteredScriptValues(); qDeleteAll(m_qobjectData); qDeleteAll(m_typeInfos); } @@ -1198,6 +1200,18 @@ bool QScriptEnginePrivate::scriptDisconnect(JSC::JSValue signal, JSC::JSValue re #endif +void QScriptEnginePrivate::detachAllRegisteredScriptValues() +{ + //make copy of attachedScriptValues (orignal set will be modified) + QSet<QScriptValuePrivate*> tmpSet(attachedScriptValues); + QSet<QScriptValuePrivate*>::const_iterator i = tmpSet.begin(); + while (i != tmpSet.end()) { + //this will autmagicly remove *i from attachedScriptValues + (*i)->detachEngine(); + i++; + } +} + QScriptEnginePrivate *QScriptEnginePrivate::get(QScriptEngine *q) { if (!q) |