Showing the changes to interface/src/ui/InteractiveWindow.cpp (1 of 2 files). Show all
Unified · Split
| @@ -134,14 +134,13 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 133 unmodified lines | ||
| 134 | 134 | InteractiveWindowPresentationMode presentationMode = InteractiveWindowPresentationMode::Native; |
| 135 | 135 | |
| 136 | 136 | if (properties.contains(PRESENTATION_MODE_PROPERTY)) { |
| 137 | − presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); | |
| 137 | + presentationMode = (InteractiveWindowPresentationMode)properties[PRESENTATION_MODE_PROPERTY].toInt(); | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | − if (!_interactiveWindowProxy) { | |
| 141 | − _interactiveWindowProxy = new InteractiveWindowProxy(); | |
| 142 | − QObject::connect(_interactiveWindowProxy, &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); | |
| 143 | − QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy, &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); | |
| 144 | − } | |
| 140 | + _interactiveWindowProxy = std::unique_ptr<InteractiveWindowProxy, InteractiveWindowProxyDeleter>(new InteractiveWindowProxy()); | |
| 141 | + | |
| 142 | + QObject::connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); | |
| 143 | + QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy.get(), &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); | |
| 145 | 144 | |
| 146 | 145 | if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { |
| 147 | 146 | QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); |
| @@ -161,7 +160,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 13 unmodified lines | ||
| 161 | 160 | _dockWidget = std::shared_ptr<DockWidget>(new DockWidget(title, mainWindow), dockWidgetDeleter); |
| 162 | 161 | auto quickView = _dockWidget->getQuickView(); |
| 163 | 162 | |
| 164 | − Application::setupQmlSurface(quickView->rootContext() , true); | |
| 163 | + Application::setupQmlSurface(quickView->rootContext(), true); | |
| 165 | 164 | |
| 166 | 165 | //add any whitelisted callbacks |
| 167 | 166 | OffscreenUi::applyWhiteList(sourceUrl, quickView->rootContext()); |
| @@ -201,7 +200,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 33 unmodified lines | ||
| 201 | 200 | QObject::connect(quickView.get(), &QQuickView::statusChanged, [&, this] (QQuickView::Status status) { |
| 202 | 201 | if (status == QQuickView::Ready) { |
| 203 | 202 | QQuickItem* rootItem = _dockWidget->getRootItem(); |
| 204 | − _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy); | |
| 203 | + _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy.get()); | |
| 205 | 204 | // The qmlToScript method handles the thread-safety of this call. Because the QVariant argument |
| 206 | 205 | // passed to the sendToScript signal may wrap an externally managed and thread-unsafe QJSValue, |
| 207 | 206 | // qmlToScript needs to be called directly, so the QJSValue can be immediately converted to a plain QVariant. |
| @@ -222,7 +221,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 14 unmodified lines | ||
| 222 | 221 | // Build the event bridge and wrapper on the main thread |
| 223 | 222 | offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&](QQmlContext* context, QObject* object) { |
| 224 | 223 | _qmlWindowProxy = std::shared_ptr<QmlWindowProxy>(new QmlWindowProxy(object, nullptr), qmlWindowProxyDeleter); |
| 225 | − context->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy); | |
| 224 | + context->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy.get()); | |
| 226 | 225 | if (properties.contains(ADDITIONAL_FLAGS_PROPERTY)) { |
| 227 | 226 | object->setProperty(ADDITIONAL_FLAGS_PROPERTY, properties[ADDITIONAL_FLAGS_PROPERTY].toUInt()); |
| 228 | 227 | } |
| @@ -313,10 +312,6 @@ void InteractiveWindow::close() { · 84 unmodified lines | ||
| 313 | 312 | _qmlWindowProxy->deleteLater(); |
| 314 | 313 | } |
| 315 | 314 | |
| 316 | − if (_interactiveWindowProxy) { | |
| 317 | − _interactiveWindowProxy->deleteLater(); | |
| 318 | − } | |
| 319 | − | |
| 320 | 315 | if (_dockWidget) { |
| 321 | 316 | auto window = qApp->getWindow(); |
| 322 | 317 | if (QThread::currentThread() != window->thread()) { |