History

Fix broken eventBridge on tablet after Reload All Scripts.

The main issue here was the "webEventReceived" connection between the OffscreenQMLSurface and the TabletProxy object. For whatever reason, if this is not a direct Signal to Slot connection, the webEventReceived event does not propagate.

Anthony J. Thibault committed 9 years ago

Commit 8ff457a1 parent 76ef2b56 files · +89 −47Browse files

Showing the changes to libraries/script-engine/src/TabletScriptingInterface.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/TabletScriptingInterface.cpp+8−4
@@ -201,7 +201,7 @@ void TabletProxy::setToolbarMode(bool toolbarMode) { · 200 unmodified lines
201 201
202 QObject::connect(quickItem, SIGNAL(windowClosed()), this, SLOT(desktopWindowClosed()));202 QObject::connect(quickItem, SIGNAL(windowClosed()), this, SLOT(desktopWindowClosed()));
203 203
204 QObject::connect(tabletRootWindow, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant)));204 QObject::connect(tabletRootWindow, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)), Qt::DirectConnection);
205 205
206 // forward qml surface events to interface js206 // forward qml surface events to interface js
207 connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);207 connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
@@ -271,12 +271,17 @@ bool TabletProxy::isMessageDialogOpen() { · 63 unmodified lines
271 return false;271 return false;
272}272}
273 273
274void TabletProxy::emitWebEvent(QVariant msg) {
275 emit webEventReceived(msg);
276}
277
274void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {278void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
275 std::lock_guard<std::mutex> guard(_mutex);279 std::lock_guard<std::mutex> guard(_mutex);
276 _qmlOffscreenSurface = qmlOffscreenSurface;280 _qmlOffscreenSurface = qmlOffscreenSurface;
277 _qmlTabletRoot = qmlTabletRoot;281 _qmlTabletRoot = qmlTabletRoot;
278 if (_qmlTabletRoot && _qmlOffscreenSurface) {282 if (_qmlTabletRoot && _qmlOffscreenSurface) {
279 QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant)));283
284 QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)), Qt::DirectConnection);
280 285
281 // forward qml surface events to interface js286 // forward qml surface events to interface js
282 connect(dynamic_cast<OffscreenQmlSurface*>(_qmlOffscreenSurface), &OffscreenQmlSurface::fromQml, [this](QVariant message) {287 connect(dynamic_cast<OffscreenQmlSurface*>(_qmlOffscreenSurface), &OffscreenQmlSurface::fromQml, [this](QVariant message) {
@@ -398,7 +403,7 @@ void TabletProxy::popFromStack() { · 115 unmodified lines
398 auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");403 auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");
399 if (stack) {404 if (stack) {
400 QMetaObject::invokeMethod(stack, "popSource");405 QMetaObject::invokeMethod(stack, "popSource");
401 } else { 406 } else {
402 qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack";407 qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack";
403 }408 }
404 } else {409 } else {
@@ -705,4 +710,3 @@ void TabletButtonProxy::editProperties(QVariantMap properties) { · 300 unmodified lines
705}710}
706 711
707#include "TabletScriptingInterface.moc"712#include "TabletScriptingInterface.moc"
708