From 560956d61af6e9d7b842ec0de6c9a144280ccd63 Mon Sep 17 00:00:00 2001 From: "Jesper K. Pedersen" Date: Tue, 7 May 2013 16:07:31 +0200 Subject: change ownership so the object will be propertly destructed Change-Id: I958f4811c477b6d1a25af9b36ae4b576666e2a8b Reviewed-by: Nicolas Arnaud-Cormos --- scriptrunner.cpp | 2 ++ scriptwrappers.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scriptrunner.cpp b/scriptrunner.cpp index a3ab9d2..c75a90d 100644 --- a/scriptrunner.cpp +++ b/scriptrunner.cpp @@ -132,6 +132,8 @@ ErrorMessage ScriptRunner::runScript(const QString fileName) if (editorManager->currentEditor()) editorManager->currentEditor()->widget()->setFocus(Qt::OtherFocusReason); + m_engine->collectGarbage(); + if (failed) return ErrorMessage(errorFileName, m_engine->uncaughtExceptionLineNumber(), result.toString()); diff --git a/scriptwrappers.h b/scriptwrappers.h index ae4c104..9d29a91 100644 --- a/scriptwrappers.h +++ b/scriptwrappers.h @@ -17,7 +17,7 @@ void registerWrappers(QScriptEngine* engine ); template static QScriptValue qObjectToScriptValue(QScriptEngine *engine, SomeQObject * const &qo) { - return engine->newQObject(qo, QScriptEngine::QtOwnership, QScriptEngine::ExcludeChildObjects); + return engine->newQObject(qo, QScriptEngine::AutoOwnership); } // Convert Scriptvalue back to a class derived from QObject via QScriptValue::toQObject() -- cgit v1.2.3