QmlDesigner: Fix crash

We have to ensure the modal dialog is actually visible
before calling process events later.

Task-number: QTCREATORBUG-16722
Change-Id: I4362a2887ee95483df082305b024232366eb074d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-03-20 16:53:47 +01:00
parent 2b09fc7885
commit 0dbec5a904

View File

@@ -66,6 +66,25 @@ static Q_LOGGING_CATEGORY(puppetBuild, "qtc.puppet.build")
namespace QmlDesigner {
class EventFilter : public QObject {
public:
EventFilter()
{}
bool eventFilter(QObject *o, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress
|| event->type() == QEvent::MouseButtonRelease
|| event->type() == QEvent::KeyPress
|| event->type() == QEvent::KeyRelease) {
return true;
}
return QObject::eventFilter(o, event);
}
};
QHash<Core::Id, PuppetCreator::PuppetType> PuppetCreator::m_qml2PuppetForKitPuppetHash;
QByteArray PuppetCreator::qtHash() const
@@ -241,6 +260,7 @@ static QString idealProcessCount()
bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
{
PuppetBuildProgressDialog progressDialog;
progressDialog.setParent(Core::ICore::mainWindow());
m_compileLog.clear();
@@ -248,6 +268,16 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
bool buildSucceeded = false;
/* Ensure the model dialog is shown and no events are delivered to the rest of Qt Creator. */
EventFilter eventFilter;
QCoreApplication::instance()->installEventFilter(&eventFilter);
progressDialog.show();
QCoreApplication::processEvents();
QCoreApplication::instance()->removeEventFilter(&eventFilter);
/* Now the modal dialog will block input to the rest of Qt Creator.
We can call process events without risking a mode change. */
if (qtIsSupported()) {
if (buildDirectory.isValid()) {
QStringList qmakeArguments;