summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2014-04-07 13:46:04 +0200
committerThomas Hartmann <Thomas.Hartmann@digia.com>2014-04-07 14:32:14 +0200
commit184bfebaabf019a46989c72e12f99997b6eaa7db (patch)
treec1917ac060a6eb0703e1b8ce018b00a1eb2a8a75
parent59b60317351c7f3c8c5ed2422fdfc75936f1b6fb (diff)
downloadqt-creator-184bfebaabf019a46989c72e12f99997b6eaa7db.tar.gz
QmlDesigner: Always warn asynchronously in exceptions
Exceptions are likely to be triggered from QML code. Calling QMessageBox::warning() results in a call to exec() and exec() returns back into the Qt event loop. This is dangerous, because QML might have scheduled a deleteLater which is then executed by exec(). This can crash the application, because the object is supposed to be "deleted later" and not directly as a side effect of the signal that was emmited by QML. Task-number: QTCREATORBUG-11946 Change-Id: Icb884847633bd421d3dc7bc034d598ef84d39429 Reviewed-by: Marco Bubke <marco.bubke@digia.com>
-rw-r--r--src/plugins/qmldesigner/designercore/exceptions/exception.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/qmldesigner/designercore/exceptions/exception.cpp b/src/plugins/qmldesigner/designercore/exceptions/exception.cpp
index c00b52f024..29d820683d 100644
--- a/src/plugins/qmldesigner/designercore/exceptions/exception.cpp
+++ b/src/plugins/qmldesigner/designercore/exceptions/exception.cpp
@@ -39,6 +39,13 @@
#include <QCoreApplication>
#include <QMessageBox>
+static void showAsyncWarning(const QString &title, const QString &desciption)
+{
+ QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning, title, desciption, QMessageBox::Ok, Core::ICore::dialogParent());
+ messageBox->setAttribute(Qt::WA_DeleteOnClose);
+ messageBox->setModal(true);
+ messageBox->show();
+}
/*!
\defgroup CoreExceptions
@@ -156,7 +163,7 @@ QString Exception::description() const
void Exception::showException(const QString &title) const
{
QString t = title.isEmpty() ? QCoreApplication::translate("QmlDesigner", "Error") : title;
- QMessageBox::warning(Core::ICore::dialogParent(), t, description());
+ showAsyncWarning(t, description());
}
/*!