aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@theqtcompany.com>2014-11-20 12:50:00 +0100
committerTim Jenssen <tim.jenssen@theqtcompany.com>2014-11-24 14:45:58 +0100
commitcd5a6c4bdf061600aa068a0d6612fae9b168682c (patch)
tree4c95ba98ae6b4518953adf76fd4f99d015990689
parent63487158f1928f2d8499995783610839904ab149 (diff)
QmlDesigner: Use Utils::AsynchronousMessageBox::warning
Warning which needs return value should be asynchronous because the event loop of the blocking dialog leads to crashes. Change-Id: I2e348f9351611dfd053cd3fbacfb6696401ee427 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
-rw-r--r--src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp4
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp8
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp12
-rw-r--r--src/plugins/qmldesigner/componentsplugin/addtabdesigneraction.cpp4
-rw-r--r--src/plugins/qmldesigner/designercore/exceptions/exception.cpp5
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp14
-rw-r--r--src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp33
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp5
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp7
-rw-r--r--src/plugins/qmldesigner/documentmanager.cpp6
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.pri6
-rw-r--r--src/plugins/qmldesigner/qmldesignerwarning.cpp44
-rw-r--r--src/plugins/qmldesigner/qmldesignerwarning.h46
13 files changed, 50 insertions, 144 deletions
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
index 33475a8cd2..2e07987070 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
@@ -49,6 +49,8 @@
#include <QApplication>
#include <QPointF>
+#include <utils/messagebox.h>
+
#include <QtDebug>
#define DISABLE_VISIBLE_PROPERTIES
@@ -344,7 +346,7 @@ void NavigatorTreeModel::updateItemRow(const ModelNode &node)
static void handleWrongId(QStandardItem *item, const ModelNode &modelNode, const QString &errorTitle, const QString &errorMessage, NavigatorTreeModel *treeModel)
{
- QMessageBox::warning(Core::ICore::dialogParent(), errorTitle, errorMessage);
+ Utils::AsynchronousMessageBox::warning(errorTitle, errorMessage);
bool blockSingals = treeModel->blockItemChangedSignal(true);
item->setText(modelNode.id());
treeModel->blockItemChangedSignal(blockSingals);
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp
index ef99fe6194..294ba4f209 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp
@@ -46,10 +46,9 @@
#include <nodeabstractproperty.h>
#include <rewriterview.h>
-#include <qmldesignerwarning.h>
-
#include <coreplugin/icore.h>
#include <utils/fileutils.h>
+#include <utils/messagebox.h>
#include <QCoreApplication>
#include <QDir>
@@ -58,7 +57,6 @@
#include <QDebug>
#include <QTimer>
#include <QShortcut>
-#include <QMessageBox>
#include <QApplication>
enum {
@@ -159,9 +157,9 @@ void PropertyEditorView::changeValue(const QString &name)
value->setValue(m_selectedNode.id());
m_locked = false;
if (!m_selectedNode.isValidId(newId))
- QmlDesignerWarning::show(tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId));
+ Utils::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId));
else
- QmlDesignerWarning::show(tr("Invalid Id"), tr("%1 already exists.").arg(newId));
+ Utils::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 already exists.").arg(newId));
}
return;
}
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp
index 58afcdba42..7501a8d1f4 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp
@@ -31,16 +31,14 @@
#include "stateseditormodel.h"
#include "stateseditorview.h"
-#include <qmldesignerwarning.h>
-
#include <QDebug>
-#include <QMessageBox>
#include <nodelistproperty.h>
#include <modelnode.h>
#include <variantproperty.h>
#include <coreplugin/icore.h>
+#include <utils/messagebox.h>
enum {
debug = false
@@ -178,10 +176,10 @@ void StatesEditorModel::renameState(int internalNodeId, const QString &newName)
return;
if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) {
- QmlDesignerWarning::show(tr("Invalid state name"),
- newName.isEmpty() ?
- tr("The empty string as a name is reserved for the base state.") :
- tr("Name already used in another state"));
+ Utils::AsynchronousMessageBox::warning(tr("Invalid state name"),
+ newName.isEmpty() ?
+ tr("The empty string as a name is reserved for the base state.") :
+ tr("Name already used in another state"));
} else {
m_statesEditorView->renameState(internalNodeId, newName);
}
diff --git a/src/plugins/qmldesigner/componentsplugin/addtabdesigneraction.cpp b/src/plugins/qmldesigner/componentsplugin/addtabdesigneraction.cpp
index 728f66f5cc..f6a11a18e5 100644
--- a/src/plugins/qmldesigner/componentsplugin/addtabdesigneraction.cpp
+++ b/src/plugins/qmldesigner/componentsplugin/addtabdesigneraction.cpp
@@ -37,6 +37,8 @@
#include <QFileInfo>
#include <coreplugin/icore.h>
+#include <utils/messagebox.h>
+
#include <documentmanager.h>
#include <nodemetainfo.h>
#include <modelnode.h>
@@ -115,7 +117,7 @@ void AddTabDesignerAction::addNewTab()
QString newFilePath = directoryPath +QStringLiteral("/") + tabName + QStringLiteral(".qml");
if (QFileInfo::exists(newFilePath)) {
- QMessageBox::warning(Core::ICore::mainWindow(), tr("Naming Error"), tr("Component already exists."));
+ Utils::AsynchronousMessageBox::warning(tr("Naming Error"), tr("Component already exists."));
} else {
const QString sourceString = QStringLiteral("import QtQuick 2.1\nimport QtQuick.Controls 1.0\n\nItem {\n anchors.fill: parent\n}");
bool fileCreated = DocumentManager::createFile(newFilePath, sourceString);
diff --git a/src/plugins/qmldesigner/designercore/exceptions/exception.cpp b/src/plugins/qmldesigner/designercore/exceptions/exception.cpp
index 281952a562..ac49542dd8 100644
--- a/src/plugins/qmldesigner/designercore/exceptions/exception.cpp
+++ b/src/plugins/qmldesigner/designercore/exceptions/exception.cpp
@@ -36,9 +36,8 @@
#endif
#include <QCoreApplication>
-#include <QMessageBox>
-#include <qmldesignerwarning.h>
+#include <utils/messagebox.h>
/*!
\defgroup CoreExceptions
@@ -156,7 +155,7 @@ QString Exception::description() const
void Exception::showException(const QString &title) const
{
QString composedTitle = title.isEmpty() ? QCoreApplication::translate("QmlDesigner", "Error") : title;
- QmlDesignerWarning::show(composedTitle, description());
+ Utils::AsynchronousMessageBox::warning(composedTitle, description());
}
/*!
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
index 5804fbf506..19bf349c15 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
@@ -75,10 +75,10 @@
#include "qmldesignerplugin.h"
#include "puppetcreator.h"
-#include <qmldesignerwarning.h>
#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>
+#include <utils/messagebox.h>
#include <projectexplorer/kit.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/baseqtversion.h>
@@ -101,9 +101,9 @@ static bool hasQtQuick1(NodeInstanceView *nodeInstanceView)
static void showCannotConnectToPuppetWarningAndSwitchToEditMode()
{
- QmlDesignerWarning::show(QCoreApplication::translate("NodeInstanceServerProxy", "Cannot Connect to QML Emulation Layer (QML Puppet)"),
- QCoreApplication::translate("NodeInstanceServerProxy", "The executable of the QML emulation layer (QML Puppet) may not be responding. "
- "Switching to another kit might help."));
+ Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("NodeInstanceServerProxy", "Cannot Connect to QML Emulation Layer (QML Puppet)"),
+ QCoreApplication::translate("NodeInstanceServerProxy", "The executable of the QML emulation layer (QML Puppet) may not be responding. "
+ "Switching to another kit might help."));
QmlDesignerPlugin::instance()->switchToTextModeDeferred();
@@ -201,8 +201,8 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
}
} else {
- QmlDesignerWarning::show(tr("Cannot Start QML Emulation Layer (QML Puppet)"),
- tr("The executable of the QML emulation layer (QML Puppet) process cannot be started or does not respond."));
+ Utils::AsynchronousMessageBox::warning(tr("Cannot Start QML Emulation Layer (QML Puppet)"),
+ tr("The executable of the QML emulation layer (QML Puppet) process cannot be started or does not respond."));
QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
@@ -385,7 +385,7 @@ void NodeInstanceServerProxy::processFinished(int exitCode, QProcess::ExitStatus
if (m_captureFileForTest.isOpen()) {
m_captureFileForTest.close();
m_captureFileForTest.remove();
- QMessageBox::warning(Core::ICore::dialogParent(), tr("QML Emulation Layer (QML Puppet) Crashed"),
+ Utils::AsynchronousMessageBox::warning(tr("QML Emulation Layer (QML Puppet) Crashed"),
tr("You are recording a puppet stream and the emulations layer crashed. "
"It is recommended to reopen the Qt Quick Designer and start again."));
}
diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp
index 735126a771..8df72f8674 100644
--- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp
@@ -41,13 +41,14 @@
#include <projectexplorer/kit.h>
#include <projectexplorer/toolchain.h>
#include <utils/environment.h>
+#include <utils/messagebox.h>
#include <coreplugin/icore.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
#include <coreplugin/icore.h>
-#include <qmldesignerwarning.h>
+
#include <qmldesignerplugin.h>
#include <designersettings.h>
#include "puppetbuildprogressdialog.h"
@@ -229,19 +230,19 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
}
if (!buildSucceeded)
- QmlDesignerWarning::show(QCoreApplication::translate("PuppetCreator", "QML Emulation Layer (QML Puppet) Building was Unsuccessful"),
- QCoreApplication::translate("PuppetCreator",
+ Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("PuppetCreator", "QML Emulation Layer (QML Puppet) Building was Unsuccessful"),
+ QCoreApplication::translate("PuppetCreator",
"The QML emulation layer (QML Puppet) cannot be built. "
"The fallback emulation layer, which does not support all features, will be used."
));
}
} else {
- QmlDesignerWarning::show(QCoreApplication::translate("PuppetCreator", "Qt Version is not supported"),
- QCoreApplication::translate("PuppetCreator",
- "The QML emulation layer (QML Puppet) cannot be built because the Qt version is too old "
- "or it cannot run natively on your computer. "
- "The fallback emulation layer, which does not support all features, will be used."
- ));
+ Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("PuppetCreator", "Qt Version is not supported"),
+ QCoreApplication::translate("PuppetCreator",
+ "The QML emulation layer (QML Puppet) cannot be built because the Qt version is too old "
+ "or it cannot run natively on your computer. "
+ "The fallback emulation layer, which does not support all features, will be used."
+ ));
}
return buildSucceeded;
@@ -249,13 +250,13 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
static void warnAboutInvalidKit()
{
- QmlDesignerWarning::show(QCoreApplication::translate("PuppetCreator", "Kit is invalid"),
- QCoreApplication::translate("PuppetCreator",
- "The QML emulation layer (QML Puppet) cannot be built because the kit is not configured correctly. "
- "For example the compiler can be misconfigured. "
- "Fix the kit configuration and restart Qt Creator. "
- "Otherwise, the fallback emulation layer, which does not support all features, will be used."
- ));
+ Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("PuppetCreator", "Kit is invalid"),
+ QCoreApplication::translate("PuppetCreator",
+ "The QML emulation layer (QML Puppet) cannot be built because the kit is not configured correctly. "
+ "For example the compiler can be misconfigured. "
+ "Fix the kit configuration and restart Qt Creator. "
+ "Otherwise, the fallback emulation layer, which does not support all features, will be used."
+ ));
}
void PuppetCreator::createQml1PuppetExecutableIfMissing()
diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
index 9a8a359307..d85183a9ba 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
@@ -34,8 +34,7 @@
#include "metainforeader.h"
#include "iwidgetplugin.h"
-#include <qmldesignerwarning.h>
-
+#include <utils/messagebox.h>
#include "pluginmanager/widgetpluginmanager.h"
@@ -100,7 +99,7 @@ void MetaInfoPrivate::parseItemLibraryDescriptions()
} catch (InvalidMetaInfoException &e) {
qWarning() << e.description();
const QString errorMessage = plugin->metaInfo() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1Char('\n'));
- QmlDesignerWarning::show(QCoreApplication::translate("QmlDesigner::Internal::MetaInfoPrivate", "Invalid meta info"),
+ Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("QmlDesigner::Internal::MetaInfoPrivate", "Invalid meta info"),
errorMessage);
}
}
diff --git a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
index b95fc3a3ec..38428649e7 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
@@ -35,10 +35,9 @@
#include "model.h"
#include "metainforeader.h"
-#include <qmldesignerwarning.h>
-
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
+#include <utils/messagebox.h>
#include <QDir>
#include <QMessageBox>
@@ -239,8 +238,8 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
} catch (InvalidMetaInfoException &e) {
qWarning() << e.description();
const QString errorMessage = metaInfoFile.absoluteFilePath() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1Char('\n'));
- QmlDesignerWarning::show(QCoreApplication::translate("SubComponentManager::parseDirectory", "Invalid meta info"),
- errorMessage);
+ Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("SubComponentManager::parseDirectory", "Invalid meta info"),
+ errorMessage);
}
}
}
diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp
index c570996d6a..da6729d3b5 100644
--- a/src/plugins/qmldesigner/documentmanager.cpp
+++ b/src/plugins/qmldesigner/documentmanager.cpp
@@ -44,6 +44,7 @@
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/icore.h>
+#include <utils/messagebox.h>
#include <QMessageBox>
@@ -337,9 +338,8 @@ void DocumentManager::addFileToVersionControl(const QString &directoryPath, cons
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath), versionControl),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFilePath)) {
- QMessageBox::warning(Core::ICore::mainWindow(),
- Core::VcsManager::msgAddToVcsFailedTitle(),
- Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl));
+ Utils::AsynchronousMessageBox::warning(Core::VcsManager::msgAddToVcsFailedTitle(),
+ Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl));
}
}
}
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.pri b/src/plugins/qmldesigner/qmldesignerplugin.pri
index ebef480516..7c52f0aaf4 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.pri
+++ b/src/plugins/qmldesigner/qmldesignerplugin.pri
@@ -6,8 +6,7 @@ HEADERS += $$PWD/qmldesignerconstants.h \
$$PWD/settingspage.h \
$$PWD/designmodecontext.h \
$$PWD/documentmanager.h \
- $$PWD/styledoutputpaneplaceholder.h \
- $$PWD/qmldesignerwarning.h
+ $$PWD/styledoutputpaneplaceholder.h
SOURCES += $$PWD/qmldesignerplugin.cpp \
$$PWD/shortcutmanager.cpp \
@@ -16,7 +15,6 @@ SOURCES += $$PWD/qmldesignerplugin.cpp \
$$PWD/settingspage.cpp \
$$PWD/designmodecontext.cpp \
$$PWD/documentmanager.cpp \
- $$PWD/styledoutputpaneplaceholder.cpp \
- $$PWD/qmldesignerwarning.cpp
+ $$PWD/styledoutputpaneplaceholder.cpp
FORMS += $$PWD/settingspage.ui
diff --git a/src/plugins/qmldesigner/qmldesignerwarning.cpp b/src/plugins/qmldesigner/qmldesignerwarning.cpp
deleted file mode 100644
index 89551e5914..0000000000
--- a/src/plugins/qmldesigner/qmldesignerwarning.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://www.qt.io/licensing. For further information
-** use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qmldesignerwarning.h"
-
-#include <coreplugin/icore.h>
-
-#include <QMessageBox>
-
-void QmlDesigner::QmlDesignerWarning::show(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();
-}
diff --git a/src/plugins/qmldesigner/qmldesignerwarning.h b/src/plugins/qmldesigner/qmldesignerwarning.h
deleted file mode 100644
index adf0abde6d..0000000000
--- a/src/plugins/qmldesigner/qmldesignerwarning.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://www.qt.io/licensing. For further information
-** use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef QMLDESIGNERWARNING_H
-#define QMLDESIGNERWARNING_H
-
-#include <QString>
-
-namespace QmlDesigner {
-
-class QmlDesignerWarning
-{
-public:
- static void show(const QString &title, const QString &desciption);
-};
-
-} //QmlDesigner
-
-#endif // QMLDESIGNERWARNING_H