summaryrefslogtreecommitdiff
path: root/daemon/manager.cpp
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-12-08 19:51:53 +0100
committerJavier <dev.git@javispedro.com>2014-12-08 19:51:53 +0100
commit132c349727bf8c0a0ce6dd5725e48e5a060d69bb (patch)
treee048499fdc2d75bd8594bfb331fd4c04418e2ad2 /daemon/manager.cpp
parentfe08705333690db42ac758e55776f94c667d0194 (diff)
fix a crash within the lambda that captures appOpenUrl
Diffstat (limited to 'daemon/manager.cpp')
-rw-r--r--daemon/manager.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index 469e92b..dcf9c16 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -454,14 +454,17 @@ QString PebbledProxy::StartAppConfiguration(const QString &uuid)
{
Q_ASSERT(calledFromDBus());
const QDBusMessage msg = message();
+ QDBusConnection conn = connection();
if (manager()->currentAppUuid != uuid) {
+ logger()->warn() << "Called StartAppConfiguration but the uuid" << uuid << "is not running";
sendErrorReply(msg.interface() + ".Error.AppNotRunning",
"The requested app is not currently opened in the watch");
return QString();
}
if (!manager()->js->isJSKitAppRunning()) {
+ logger()->warn() << "Called StartAppConfiguration but the uuid" << uuid << "is not a JS app";
sendErrorReply(msg.interface() + ".Error.JSNotActive",
"The requested app is not a PebbleKit JS application");
return QString();
@@ -474,25 +477,32 @@ QString PebbledProxy::StartAppConfiguration(const QString &uuid)
setDelayedReply(true);
// Set up a signal handler to catch the appOpenUrl signal.
- QMetaObject::Connection c = connect(manager()->js, &JSKitManager::appOpenUrl,
- [this,msg,c](const QUrl &url) {
- // Workaround: due to a GCC bug we can't capture the uuid parameter, but we can extract
+ QMetaObject::Connection *c = new QMetaObject::Connection;
+ *c = connect(manager()->js, &JSKitManager::appOpenUrl,
+ this, [this,conn,msg,c](const QUrl &url) {
+ // Workaround: due to a GCC crash we can't capture the uuid parameter, but we can extract
// it again from the original message arguments.
- QString uuid = msg.arguments().at(0).toString();
+ // Suspect GCC bug# is 59195, 61233, or 61321.
+ // TODO Possibly fixed in 4.9.0
+ const QString uuid = msg.arguments().at(0).toString();
+
if (manager()->currentAppUuid != uuid) {
// App was changed while we were waiting for the script..
QDBusMessage reply = msg.createErrorReply(msg.interface() + ".Error.AppNotRunning",
"The requested app is not currently opened in the watch");
- connection().send(reply);
+ conn.send(reply);
} else {
QDBusMessage reply = msg.createReply(QVariant::fromValue(url.toString()));
- connection().send(reply);
+ conn.send(reply);
}
- disconnect(c);
+ disconnect(*c);
+ delete c;
});
+
// TODO: JS script may fail, never call OpenURL, or something like that
- // In those cases we may leak the above connection
+ // In those cases we WILL leak the above connection.
+ // (at least until the next appOpenURL event comes in)
// So we need to also set a timeout or similar.
manager()->js->showConfiguration();