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
201201
202202 QObject::connect(quickItem, SIGNAL(windowClosed()), this, SLOT(desktopWindowClosed()));
203203
204− QObject::connect(tabletRootWindow, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant)));
204+ QObject::connect(tabletRootWindow, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)), Qt::DirectConnection);
205205
206206 // forward qml surface events to interface js
207207 connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
@@ -271,12 +271,17 @@ bool TabletProxy::isMessageDialogOpen() { · 63 unmodified lines
271271 return false;
272272 }
273273
274+void TabletProxy::emitWebEvent(QVariant msg) {
275+ emit webEventReceived(msg);
276+}
277+
274278 void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
275279 std::lock_guard<std::mutex> guard(_mutex);
276280 _qmlOffscreenSurface = qmlOffscreenSurface;
277281 _qmlTabletRoot = qmlTabletRoot;
278282 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);
280285
281286 // forward qml surface events to interface js
282287 connect(dynamic_cast<OffscreenQmlSurface*>(_qmlOffscreenSurface), &OffscreenQmlSurface::fromQml, [this](QVariant message) {
@@ -398,7 +403,7 @@ void TabletProxy::popFromStack() { · 115 unmodified lines
398403 auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");
399404 if (stack) {
400405 QMetaObject::invokeMethod(stack, "popSource");
401− } else {
406+ } else {
402407 qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack";
403408 }
404409 } else {
@@ -705,4 +710,3 @@ void TabletButtonProxy::editProperties(QVariantMap properties) { · 300 unmodified lines
705710 }
706711
707712 #include "TabletScriptingInterface.moc"
708−