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
This commit is contained in:
Aaron J. Seigo 2010-08-06 19:34:59 +00:00
parent 7500244520
commit 0c929d525d
3 changed files with 8 additions and 1 deletions

View File

@ -228,7 +228,7 @@ QScriptValue JavaScriptDataEngine::serviceCtor(QScriptContext *context, QScriptE
JavaScriptService *service = new JavaScriptService(serviceName, iFace); JavaScriptService *service = new JavaScriptService(serviceName, iFace);
if (service->wasFound()) { if (service->wasFound()) {
QScriptValue v = engine->newQObject(service, QScriptEngine::ScriptOwnership); QScriptValue v = engine->newQObject(service, QScriptEngine::QtOwnership);
service->setScriptValue(v); service->setScriptValue(v);
return v; return v;
} }
@ -301,6 +301,7 @@ Plasma::Service *JavaScriptDataEngine::serviceForSource(const QString &source)
if (service->destination().isEmpty()) { if (service->destination().isEmpty()) {
service->setDestination(source); service->setDestination(source);
} }
return service; return service;
} else { } else {
delete rv.toQObject(); delete rv.toQObject();

View File

@ -31,6 +31,11 @@ JavaScriptService::JavaScriptService(const QString &serviceName, JavaScriptDataE
setName(serviceName); setName(serviceName);
} }
JavaScriptService::~JavaScriptService()
{
// kDebug();
}
void JavaScriptService::setScriptValue(QScriptValue &v) void JavaScriptService::setScriptValue(QScriptValue &v)
{ {
m_scriptValue = v; m_scriptValue = v;

View File

@ -38,6 +38,7 @@ class JavaScriptService : public Plasma::Service
public: public:
JavaScriptService(const QString &serviceName, JavaScriptDataEngine *engine); JavaScriptService(const QString &serviceName, JavaScriptDataEngine *engine);
~JavaScriptService();
bool wasFound() const; bool wasFound() const;
void setScriptValue(QScriptValue &v); void setScriptValue(QScriptValue &v);