From 2175404d4ec5290faed8da3144ac186bdad63508 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 9 Nov 2016 18:09:56 +0100 Subject: [PATCH] Ensure message boxes happen on the main thread --- qrenderdoc/Code/QRDUtils.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index 4c0133e5a..fd598165d 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -151,10 +151,16 @@ QMessageBox::StandardButton RDDialog::messageBox(QMessageBox::Icon icon, QWidget QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - QMessageBox mb(icon, title, text, buttons, parent); - mb.setDefaultButton(defaultButton); - show(&mb); - return mb.standardButton(mb.clickedButton()); + QMessageBox::StandardButton ret = defaultButton; + + // if we're already on the right thread, this boils down to a function call + GUIInvoke::blockcall([&]() { + QMessageBox mb(icon, title, text, buttons, parent); + mb.setDefaultButton(defaultButton); + show(&mb); + ret = mb.standardButton(mb.clickedButton()); + }); + return ret; } QString RDDialog::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir,