From 74b878a276778960d01f20d6650bafdff9743fe0 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 25 Jan 2017 17:48:58 +1300 Subject: [PATCH] Fix threading of message box updates --- .../src/scripting/WindowScriptingInterface.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 7cfbfb174e..fbeddf41e0 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -253,6 +253,16 @@ int WindowScriptingInterface::createMessageBox(QString title, QString text, int void WindowScriptingInterface::updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton) { auto messageBox = _messageBoxes.value(id); if (messageBox) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "updateMessageBox", + Q_ARG(int, id), + Q_ARG(QString, title), + Q_ARG(QString, text), + Q_ARG(int, buttons), + Q_ARG(int, defaultButton)); + return; + } + messageBox->setProperty("title", title); messageBox->setProperty("text", text); messageBox->setProperty("buttons", buttons); @@ -263,6 +273,12 @@ void WindowScriptingInterface::updateMessageBox(int id, QString title, QString t void WindowScriptingInterface::closeMessageBox(int id) { auto messageBox = _messageBoxes.value(id); if (messageBox) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "closeMessageBox", + Q_ARG(int, id)); + return; + } + disconnect(messageBox); messageBox->setVisible(false); messageBox->deleteLater();