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>
This commit is contained in:
Marco Bubke
2014-11-20 12:50:00 +01:00
committed by Tim Jenssen
parent 63487158f1
commit cd5a6c4bdf
13 changed files with 50 additions and 144 deletions

View File

@@ -49,6 +49,8 @@
#include <QApplication> #include <QApplication>
#include <QPointF> #include <QPointF>
#include <utils/messagebox.h>
#include <QtDebug> #include <QtDebug>
#define DISABLE_VISIBLE_PROPERTIES #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) 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); bool blockSingals = treeModel->blockItemChangedSignal(true);
item->setText(modelNode.id()); item->setText(modelNode.id());
treeModel->blockItemChangedSignal(blockSingals); treeModel->blockItemChangedSignal(blockSingals);

View File

@@ -46,10 +46,9 @@
#include <nodeabstractproperty.h> #include <nodeabstractproperty.h>
#include <rewriterview.h> #include <rewriterview.h>
#include <qmldesignerwarning.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/messagebox.h>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
@@ -58,7 +57,6 @@
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QShortcut> #include <QShortcut>
#include <QMessageBox>
#include <QApplication> #include <QApplication>
enum { enum {
@@ -159,9 +157,9 @@ void PropertyEditorView::changeValue(const QString &name)
value->setValue(m_selectedNode.id()); value->setValue(m_selectedNode.id());
m_locked = false; m_locked = false;
if (!m_selectedNode.isValidId(newId)) 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 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; return;
} }

View File

@@ -31,16 +31,14 @@
#include "stateseditormodel.h" #include "stateseditormodel.h"
#include "stateseditorview.h" #include "stateseditorview.h"
#include <qmldesignerwarning.h>
#include <QDebug> #include <QDebug>
#include <QMessageBox>
#include <nodelistproperty.h> #include <nodelistproperty.h>
#include <modelnode.h> #include <modelnode.h>
#include <variantproperty.h> #include <variantproperty.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/messagebox.h>
enum { enum {
debug = false debug = false
@@ -178,7 +176,7 @@ void StatesEditorModel::renameState(int internalNodeId, const QString &newName)
return; return;
if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) { if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) {
QmlDesignerWarning::show(tr("Invalid state name"), Utils::AsynchronousMessageBox::warning(tr("Invalid state name"),
newName.isEmpty() ? newName.isEmpty() ?
tr("The empty string as a name is reserved for the base state.") : tr("The empty string as a name is reserved for the base state.") :
tr("Name already used in another state")); tr("Name already used in another state"));

View File

@@ -37,6 +37,8 @@
#include <QFileInfo> #include <QFileInfo>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/messagebox.h>
#include <documentmanager.h> #include <documentmanager.h>
#include <nodemetainfo.h> #include <nodemetainfo.h>
#include <modelnode.h> #include <modelnode.h>
@@ -115,7 +117,7 @@ void AddTabDesignerAction::addNewTab()
QString newFilePath = directoryPath +QStringLiteral("/") + tabName + QStringLiteral(".qml"); QString newFilePath = directoryPath +QStringLiteral("/") + tabName + QStringLiteral(".qml");
if (QFileInfo::exists(newFilePath)) { 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 { } else {
const QString sourceString = QStringLiteral("import QtQuick 2.1\nimport QtQuick.Controls 1.0\n\nItem {\n anchors.fill: parent\n}"); 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); bool fileCreated = DocumentManager::createFile(newFilePath, sourceString);

View File

@@ -36,9 +36,8 @@
#endif #endif
#include <QCoreApplication> #include <QCoreApplication>
#include <QMessageBox>
#include <qmldesignerwarning.h> #include <utils/messagebox.h>
/*! /*!
\defgroup CoreExceptions \defgroup CoreExceptions
@@ -156,7 +155,7 @@ QString Exception::description() const
void Exception::showException(const QString &title) const void Exception::showException(const QString &title) const
{ {
QString composedTitle = title.isEmpty() ? QCoreApplication::translate("QmlDesigner", "Error") : title; QString composedTitle = title.isEmpty() ? QCoreApplication::translate("QmlDesigner", "Error") : title;
QmlDesignerWarning::show(composedTitle, description()); Utils::AsynchronousMessageBox::warning(composedTitle, description());
} }
/*! /*!

View File

@@ -75,10 +75,10 @@
#include "qmldesignerplugin.h" #include "qmldesignerplugin.h"
#include "puppetcreator.h" #include "puppetcreator.h"
#include <qmldesignerwarning.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/messagebox.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
@@ -101,7 +101,7 @@ static bool hasQtQuick1(NodeInstanceView *nodeInstanceView)
static void showCannotConnectToPuppetWarningAndSwitchToEditMode() static void showCannotConnectToPuppetWarningAndSwitchToEditMode()
{ {
QmlDesignerWarning::show(QCoreApplication::translate("NodeInstanceServerProxy", "Cannot Connect to QML Emulation Layer (QML Puppet)"), 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. " QCoreApplication::translate("NodeInstanceServerProxy", "The executable of the QML emulation layer (QML Puppet) may not be responding. "
"Switching to another kit might help.")); "Switching to another kit might help."));
@@ -201,7 +201,7 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
} }
} else { } else {
QmlDesignerWarning::show(tr("Cannot Start QML Emulation Layer (QML Puppet)"), 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.")); tr("The executable of the QML emulation layer (QML Puppet) process cannot be started or does not respond."));
QmlDesignerPlugin::instance()->switchToTextModeDeferred(); QmlDesignerPlugin::instance()->switchToTextModeDeferred();
@@ -385,7 +385,7 @@ void NodeInstanceServerProxy::processFinished(int exitCode, QProcess::ExitStatus
if (m_captureFileForTest.isOpen()) { if (m_captureFileForTest.isOpen()) {
m_captureFileForTest.close(); m_captureFileForTest.close();
m_captureFileForTest.remove(); 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. " tr("You are recording a puppet stream and the emulations layer crashed. "
"It is recommended to reopen the Qt Quick Designer and start again.")); "It is recommended to reopen the Qt Quick Designer and start again."));
} }

View File

@@ -41,13 +41,14 @@
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/messagebox.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h> #include <qtsupport/qtsupportconstants.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <qmldesignerwarning.h>
#include <qmldesignerplugin.h> #include <qmldesignerplugin.h>
#include <designersettings.h> #include <designersettings.h>
#include "puppetbuildprogressdialog.h" #include "puppetbuildprogressdialog.h"
@@ -229,14 +230,14 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
} }
if (!buildSucceeded) if (!buildSucceeded)
QmlDesignerWarning::show(QCoreApplication::translate("PuppetCreator", "QML Emulation Layer (QML Puppet) Building was Unsuccessful"), Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("PuppetCreator", "QML Emulation Layer (QML Puppet) Building was Unsuccessful"),
QCoreApplication::translate("PuppetCreator", QCoreApplication::translate("PuppetCreator",
"The QML emulation layer (QML Puppet) cannot be built. " "The QML emulation layer (QML Puppet) cannot be built. "
"The fallback emulation layer, which does not support all features, will be used." "The fallback emulation layer, which does not support all features, will be used."
)); ));
} }
} else { } else {
QmlDesignerWarning::show(QCoreApplication::translate("PuppetCreator", "Qt Version is not supported"), Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("PuppetCreator", "Qt Version is not supported"),
QCoreApplication::translate("PuppetCreator", QCoreApplication::translate("PuppetCreator",
"The QML emulation layer (QML Puppet) cannot be built because the Qt version is too old " "The QML emulation layer (QML Puppet) cannot be built because the Qt version is too old "
"or it cannot run natively on your computer. " "or it cannot run natively on your computer. "
@@ -249,7 +250,7 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
static void warnAboutInvalidKit() static void warnAboutInvalidKit()
{ {
QmlDesignerWarning::show(QCoreApplication::translate("PuppetCreator", "Kit is invalid"), Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("PuppetCreator", "Kit is invalid"),
QCoreApplication::translate("PuppetCreator", QCoreApplication::translate("PuppetCreator",
"The QML emulation layer (QML Puppet) cannot be built because the kit is not configured correctly. " "The QML emulation layer (QML Puppet) cannot be built because the kit is not configured correctly. "
"For example the compiler can be misconfigured. " "For example the compiler can be misconfigured. "

View File

@@ -34,8 +34,7 @@
#include "metainforeader.h" #include "metainforeader.h"
#include "iwidgetplugin.h" #include "iwidgetplugin.h"
#include <qmldesignerwarning.h> #include <utils/messagebox.h>
#include "pluginmanager/widgetpluginmanager.h" #include "pluginmanager/widgetpluginmanager.h"
@@ -100,7 +99,7 @@ void MetaInfoPrivate::parseItemLibraryDescriptions()
} catch (InvalidMetaInfoException &e) { } catch (InvalidMetaInfoException &e) {
qWarning() << e.description(); qWarning() << e.description();
const QString errorMessage = plugin->metaInfo() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1Char('\n')); 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); errorMessage);
} }
} }

View File

@@ -35,10 +35,9 @@
#include "model.h" #include "model.h"
#include "metainforeader.h" #include "metainforeader.h"
#include <qmldesignerwarning.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/messagebox.h>
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
@@ -239,7 +238,7 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
} catch (InvalidMetaInfoException &e) { } catch (InvalidMetaInfoException &e) {
qWarning() << e.description(); qWarning() << e.description();
const QString errorMessage = metaInfoFile.absoluteFilePath() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1Char('\n')); const QString errorMessage = metaInfoFile.absoluteFilePath() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1Char('\n'));
QmlDesignerWarning::show(QCoreApplication::translate("SubComponentManager::parseDirectory", "Invalid meta info"), Utils::AsynchronousMessageBox::warning(QCoreApplication::translate("SubComponentManager::parseDirectory", "Invalid meta info"),
errorMessage); errorMessage);
} }
} }

View File

@@ -44,6 +44,7 @@
#include <coreplugin/iversioncontrol.h> #include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h> #include <coreplugin/vcsmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/messagebox.h>
#include <QMessageBox> #include <QMessageBox>
@@ -337,8 +338,7 @@ void DocumentManager::addFileToVersionControl(const QString &directoryPath, cons
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath), versionControl), Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath), versionControl),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFilePath)) { if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFilePath)) {
QMessageBox::warning(Core::ICore::mainWindow(), Utils::AsynchronousMessageBox::warning(Core::VcsManager::msgAddToVcsFailedTitle(),
Core::VcsManager::msgAddToVcsFailedTitle(),
Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl)); Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl));
} }
} }

View File

@@ -6,8 +6,7 @@ HEADERS += $$PWD/qmldesignerconstants.h \
$$PWD/settingspage.h \ $$PWD/settingspage.h \
$$PWD/designmodecontext.h \ $$PWD/designmodecontext.h \
$$PWD/documentmanager.h \ $$PWD/documentmanager.h \
$$PWD/styledoutputpaneplaceholder.h \ $$PWD/styledoutputpaneplaceholder.h
$$PWD/qmldesignerwarning.h
SOURCES += $$PWD/qmldesignerplugin.cpp \ SOURCES += $$PWD/qmldesignerplugin.cpp \
$$PWD/shortcutmanager.cpp \ $$PWD/shortcutmanager.cpp \
@@ -16,7 +15,6 @@ SOURCES += $$PWD/qmldesignerplugin.cpp \
$$PWD/settingspage.cpp \ $$PWD/settingspage.cpp \
$$PWD/designmodecontext.cpp \ $$PWD/designmodecontext.cpp \
$$PWD/documentmanager.cpp \ $$PWD/documentmanager.cpp \
$$PWD/styledoutputpaneplaceholder.cpp \ $$PWD/styledoutputpaneplaceholder.cpp
$$PWD/qmldesignerwarning.cpp
FORMS += $$PWD/settingspage.ui FORMS += $$PWD/settingspage.ui

View File

@@ -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();
}

View File

@@ -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