summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2015-04-17 13:07:16 +0200
committerTomasz Sterna <tomek@xiaoka.com>2015-04-17 13:11:32 +0200
commitdc899d978eaf0ad2afc2768ab8b731974b791966 (patch)
tree1e1a20cb0330ea98a321f92351b5534f9571cd04
parent1eac0ebec1db39c74fdd998ce07246ed3f576cbe (diff)
Better JSKit memory management
Attach context objects as _engine children, so they get destroyed by parent when engine is deleted.
-rw-r--r--daemon/appmsgmanager.cpp6
-rw-r--r--daemon/jskitmanager.cpp16
-rw-r--r--daemon/jskitobjects.cpp16
-rw-r--r--daemon/jskitobjects.h8
4 files changed, 22 insertions, 24 deletions
diff --git a/daemon/appmsgmanager.cpp b/daemon/appmsgmanager.cpp
index 1a4a424..3bc7922 100644
--- a/daemon/appmsgmanager.cpp
+++ b/daemon/appmsgmanager.cpp
@@ -24,9 +24,13 @@ AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *p
case WatchConnector::appmsgPUSH:
handleLauncherPushMessage(data);
break;
+
+ // TODO we ignore those for now.
case WatchConnector::appmsgACK:
+ qCDebug(l) << "Watch accepted application launch";
+ break;
case WatchConnector::appmsgNACK:
- // TODO we ignore those for now.
+ qCDebug(l) << "Watch denied application launch";
break;
}
diff --git a/daemon/jskitmanager.cpp b/daemon/jskitmanager.cpp
index a5be709..2da1986 100644
--- a/daemon/jskitmanager.cpp
+++ b/daemon/jskitmanager.cpp
@@ -132,12 +132,12 @@ void JSKitManager::startJsApp()
}
_engine = new QJSEngine(this);
- _jspebble = new JSKitPebble(_curApp, this);
- _jsconsole = new JSKitConsole(this);
- _jsstorage = new JSKitLocalStorage(_curApp.uuid(), this);
- _jsgeo = new JSKitGeolocation(this);
+ _jspebble = new JSKitPebble(_curApp, this, _engine);
+ _jsconsole = new JSKitConsole(_engine);
+ _jsstorage = new JSKitLocalStorage(_curApp.uuid(), _engine);
+ _jsgeo = new JSKitGeolocation(this, _engine);
- qCDebug(l) << "starting JS app";
+ qCDebug(l) << "starting JS app" << _curApp.shortName();
QJSValue globalObj = _engine->globalObject();
@@ -196,10 +196,4 @@ void JSKitManager::stopJsApp()
_engine->deleteLater();
_engine = 0;
- _jsstorage->deleteLater();
- _jsstorage = 0;
- _jsgeo->deleteLater();
- _jsgeo = 0;
- _jspebble->deleteLater();
- _jspebble = 0;
}
diff --git a/daemon/jskitobjects.cpp b/daemon/jskitobjects.cpp
index 9c09f27..01a7e20 100644
--- a/daemon/jskitobjects.cpp
+++ b/daemon/jskitobjects.cpp
@@ -10,8 +10,8 @@
static const char *token_salt = "0feeb7416d3c4546a19b04bccd8419b1";
-JSKitPebble::JSKitPebble(const AppInfo &info, JSKitManager *mgr)
- : QObject(mgr), l(metaObject()->className()), _appInfo(info), _mgr(mgr)
+JSKitPebble::JSKitPebble(const AppInfo &info, JSKitManager *mgr, QObject *parent)
+ : QObject(parent), l(metaObject()->className()), _appInfo(info), _mgr(mgr)
{
}
@@ -167,8 +167,8 @@ void JSKitPebble::invokeCallbacks(const QString &type, const QJSValueList &args)
}
}
-JSKitConsole::JSKitConsole(JSKitManager *mgr)
- : QObject(mgr), l(metaObject()->className())
+JSKitConsole::JSKitConsole(QObject *parent)
+ : QObject(parent), l(metaObject()->className())
{
}
@@ -177,8 +177,8 @@ void JSKitConsole::log(const QString &msg)
qCDebug(l) << msg;
}
-JSKitLocalStorage::JSKitLocalStorage(const QUuid &uuid, JSKitManager *mgr)
- : QObject(mgr), _storage(new QSettings(getStorageFileFor(uuid), QSettings::IniFormat, this))
+JSKitLocalStorage::JSKitLocalStorage(const QUuid &uuid, QObject *parent)
+ : QObject(parent), _storage(new QSettings(getStorageFileFor(uuid), QSettings::IniFormat, this))
{
_len = _storage->allKeys().size();
}
@@ -517,8 +517,8 @@ void JSKitXMLHttpRequest::handleAuthenticationRequired(QNetworkReply *reply, QAu
}
}
-JSKitGeolocation::JSKitGeolocation(JSKitManager *mgr)
- : QObject(mgr), l(metaObject()->className()),
+JSKitGeolocation::JSKitGeolocation(JSKitManager *mgr, QObject *parent)
+ : QObject(parent), l(metaObject()->className()),
_mgr(mgr), _source(0), _lastWatchId(0)
{
}
diff --git a/daemon/jskitobjects.h b/daemon/jskitobjects.h
index 1477fc6..43e1c30 100644
--- a/daemon/jskitobjects.h
+++ b/daemon/jskitobjects.h
@@ -14,7 +14,7 @@ class JSKitPebble : public QObject
QLoggingCategory l;
public:
- explicit JSKitPebble(const AppInfo &appInfo, JSKitManager *mgr);
+ explicit JSKitPebble(const AppInfo &appInfo, JSKitManager *mgr, QObject *parent=0);
Q_INVOKABLE void addEventListener(const QString &type, QJSValue function);
Q_INVOKABLE void removeEventListener(const QString &type, QJSValue function);
@@ -47,7 +47,7 @@ class JSKitConsole : public QObject
QLoggingCategory l;
public:
- explicit JSKitConsole(JSKitManager *mgr);
+ explicit JSKitConsole(QObject *parent=0);
Q_INVOKABLE void log(const QString &msg);
};
@@ -59,7 +59,7 @@ class JSKitLocalStorage : public QObject
Q_PROPERTY(int length READ length NOTIFY lengthChanged)
public:
- explicit JSKitLocalStorage(const QUuid &uuid, JSKitManager *mgr);
+ explicit JSKitLocalStorage(const QUuid &uuid, QObject *parent=0);
int length() const;
@@ -173,7 +173,7 @@ class JSKitGeolocation : public QObject
struct Watcher;
public:
- explicit JSKitGeolocation(JSKitManager *mgr);
+ explicit JSKitGeolocation(JSKitManager *mgr, QObject *parent=0);
enum PositionError {
PERMISSION_DENIED = 1,