Commit cd5a6c4b authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen

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: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 63487158
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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());
}
/*!
......
......@@ -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."));
}
......
......@@ -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()
......
......@@ -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);
}
}
......
......@@ -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);
}
}
}
......
......@@ -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));
}
}
}
......
......@@ -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
/****************************************************************************
**
** 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();
}
/****************************************************************************
**
** 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment