History

changing raw pointer to unique pointer with custom deleter

amer cerkic committed 7 years ago

Commit b2e07fd1 parent 4dc67b52 files · +17 −15Browse files

Showing the changes to interface/src/ui/InteractiveWindow.cpp (1 of 2 files). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t