History

Fix threading of message box updates

David Rowe committed 9 years ago

Commit 74b878a1 parent dcd63201 file · +16 −0Browse files

Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+16−0
@@ -253,6 +253,16 @@ int WindowScriptingInterface::createMessageBox(QString title, QString text, int · 252 unmodified lines
253253 void WindowScriptingInterface::updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton) {
254254 auto messageBox = _messageBoxes.value(id);
255255 if (messageBox) {
256+ if (QThread::currentThread() != thread()) {
257+ QMetaObject::invokeMethod(this, "updateMessageBox",
258+ Q_ARG(int, id),
259+ Q_ARG(QString, title),
260+ Q_ARG(QString, text),
261+ Q_ARG(int, buttons),
262+ Q_ARG(int, defaultButton));
263+ return;
264+ }
265+
256266 messageBox->setProperty("title", title);
257267 messageBox->setProperty("text", text);
258268 messageBox->setProperty("buttons", buttons);
@@ -263,6 +273,12 @@ void WindowScriptingInterface::updateMessageBox(int id, QString title, QString t · 4 unmodified lines
263273 void WindowScriptingInterface::closeMessageBox(int id) {
264274 auto messageBox = _messageBoxes.value(id);
265275 if (messageBox) {
276+ if (QThread::currentThread() != thread()) {
277+ QMetaObject::invokeMethod(this, "closeMessageBox",
278+ Q_ARG(int, id));
279+ return;
280+ }
281+
266282 disconnect(messageBox);
267283 messageBox->setVisible(false);
268284 messageBox->deleteLater();