From 0c929d525d74b512914d74049a7bcfbb141d60e3 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Fri, 6 Aug 2010 19:34:59 +0000 Subject: [PATCH] Qt ownership of the service object: they are owned by the caller, and so must be deleted by them svn path=/trunk/KDE/kdebase/runtime/; revision=1160005 --- scriptengines/javascript/dataengine/javascriptdataengine.cpp | 3 ++- scriptengines/javascript/dataengine/javascriptservice.cpp | 5 +++++ scriptengines/javascript/dataengine/javascriptservice.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scriptengines/javascript/dataengine/javascriptdataengine.cpp b/scriptengines/javascript/dataengine/javascriptdataengine.cpp index f1e01f450..e4743331e 100644 --- a/scriptengines/javascript/dataengine/javascriptdataengine.cpp +++ b/scriptengines/javascript/dataengine/javascriptdataengine.cpp @@ -228,7 +228,7 @@ QScriptValue JavaScriptDataEngine::serviceCtor(QScriptContext *context, QScriptE JavaScriptService *service = new JavaScriptService(serviceName, iFace); if (service->wasFound()) { - QScriptValue v = engine->newQObject(service, QScriptEngine::ScriptOwnership); + QScriptValue v = engine->newQObject(service, QScriptEngine::QtOwnership); service->setScriptValue(v); return v; } @@ -301,6 +301,7 @@ Plasma::Service *JavaScriptDataEngine::serviceForSource(const QString &source) if (service->destination().isEmpty()) { service->setDestination(source); } + return service; } else { delete rv.toQObject(); diff --git a/scriptengines/javascript/dataengine/javascriptservice.cpp b/scriptengines/javascript/dataengine/javascriptservice.cpp index b41bca32d..a76b70164 100644 --- a/scriptengines/javascript/dataengine/javascriptservice.cpp +++ b/scriptengines/javascript/dataengine/javascriptservice.cpp @@ -31,6 +31,11 @@ JavaScriptService::JavaScriptService(const QString &serviceName, JavaScriptDataE setName(serviceName); } +JavaScriptService::~JavaScriptService() +{ +// kDebug(); +} + void JavaScriptService::setScriptValue(QScriptValue &v) { m_scriptValue = v; diff --git a/scriptengines/javascript/dataengine/javascriptservice.h b/scriptengines/javascript/dataengine/javascriptservice.h index 64deb20ca..04f73fb62 100644 --- a/scriptengines/javascript/dataengine/javascriptservice.h +++ b/scriptengines/javascript/dataengine/javascriptservice.h @@ -38,6 +38,7 @@ class JavaScriptService : public Plasma::Service public: JavaScriptService(const QString &serviceName, JavaScriptDataEngine *engine); + ~JavaScriptService(); bool wasFound() const; void setScriptValue(QScriptValue &v);