Commit c4ab643d authored by Eike Ziller's avatar Eike Ziller

Show more useful error dialog in case of plugin errors.

Task-number: QTCREATORBUG-3940

Change-Id: I9e12ad68bba9c2f0d8f5243ab7dc763765fba756
Reviewed-on: http://codereview.qt.nokia.com/3811Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@nokia.com>
parent eaadc7d3
......@@ -35,6 +35,7 @@
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginerroroverview.h>
#include <QtCore/QDir>
#include <QtCore/QUrl>
......@@ -353,15 +354,10 @@ int main(int argc, char **argv)
return 1;
}
{
QStringList errors;
foreach (ExtensionSystem::PluginSpec *p, pluginManager.plugins())
// only show errors on startup if plugin is enabled.
if (p->hasError() && p->isEnabled() && !p->isDisabledIndirectly())
errors.append(p->name() + "\n" + p->errorString());
if (!errors.isEmpty())
QMessageBox::warning(0,
QCoreApplication::translate("Application", "Qt Creator - Plugin loader messages"),
errors.join(QString::fromLatin1("\n\n")));
if (pluginManager.hasError()) {
ExtensionSystem::PluginErrorOverview errorOverview(&pluginManager);
errorOverview.exec();
}
}
if (isFirstInstance) {
......@@ -385,4 +381,3 @@ int main(int argc, char **argv)
return app.exec();
}
......@@ -21,7 +21,8 @@ HEADERS += pluginerrorview.h \
pluginview.h \
pluginview_p.h \
optionsparser.h \
plugincollection.h
plugincollection.h \
pluginerroroverview.h
SOURCES += pluginerrorview.cpp \
plugindetailsview.cpp \
invoker.cpp \
......@@ -30,8 +31,13 @@ SOURCES += pluginerrorview.cpp \
pluginspec.cpp \
pluginview.cpp \
optionsparser.cpp \
plugincollection.cpp
plugincollection.cpp \
pluginerroroverview.cpp
FORMS += pluginview.ui \
pluginerrorview.ui \
plugindetailsview.ui
plugindetailsview.ui \
pluginerroroverview.ui
RESOURCES += pluginview.qrc
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#include "pluginerroroverview.h"
#include "ui_pluginerroroverview.h"
#include "pluginspec.h"
#include "pluginmanager.h"
Q_DECLARE_METATYPE(ExtensionSystem::PluginSpec*)
namespace ExtensionSystem {
namespace Internal {
class PluginErrorOverviewPrivate : public QObject
{
Q_OBJECT
public:
PluginErrorOverviewPrivate(PluginManager *manager, QDialog *dialog);
~PluginErrorOverviewPrivate();
private slots:
void showDetails(QListWidgetItem *item);
private:
Ui::PluginErrorOverview *m_ui;
PluginManager *m_manager;
};
} // Internal
} // ExtensionSystem
using namespace ExtensionSystem;
using namespace ExtensionSystem::Internal;
PluginErrorOverview::PluginErrorOverview(PluginManager *manager, QWidget *parent) :
QDialog(parent),
d(new PluginErrorOverviewPrivate(manager, this))
{
}
PluginErrorOverview::~PluginErrorOverview()
{
delete d;
}
PluginErrorOverviewPrivate::PluginErrorOverviewPrivate(PluginManager *manager, QDialog *dialog)
: m_ui(new Ui::PluginErrorOverview),
m_manager(manager)
{
m_ui->setupUi(dialog);
m_ui->buttonBox->addButton(tr("Continue"), QDialogButtonBox::AcceptRole);
foreach (PluginSpec *spec, m_manager->plugins()) {
// only show errors on startup if plugin is enabled.
if (spec->hasError() && spec->isEnabled() && !spec->isDisabledIndirectly()) {
QListWidgetItem *item = new QListWidgetItem(spec->name());
item->setData(Qt::UserRole, qVariantFromValue(spec));
m_ui->pluginList->addItem(item);
}
}
connect(m_ui->pluginList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(showDetails(QListWidgetItem*)));
if (m_ui->pluginList->count() > 0)
m_ui->pluginList->setCurrentRow(0);
}
PluginErrorOverviewPrivate::~PluginErrorOverviewPrivate()
{
delete m_ui;
}
void PluginErrorOverviewPrivate::showDetails(QListWidgetItem *item)
{
if (item) {
PluginSpec *spec = item->data(Qt::UserRole).value<PluginSpec *>();
m_ui->pluginError->setText(spec->errorString());
} else {
m_ui->pluginError->setText(QString());
}
}
#include "pluginerroroverview.moc"
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#ifndef PLUGINERROROVERVIEW_H
#define PLUGINERROROVERVIEW_H
#include "extensionsystem_global.h"
#include <QtGui/QDialog>
namespace ExtensionSystem {
class PluginManager;
namespace Internal {
class PluginErrorOverviewPrivate;
}
class EXTENSIONSYSTEM_EXPORT PluginErrorOverview : public QDialog
{
Q_OBJECT
public:
explicit PluginErrorOverview(PluginManager *manager, QWidget *parent = 0);
~PluginErrorOverview();
private:
Internal::PluginErrorOverviewPrivate *d;
};
} // ExtensionSystem
#endif // PLUGINERROROVERVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtensionSystem::Internal::PluginErrorOverview</class>
<widget class="QDialog" name="ExtensionSystem::Internal::PluginErrorOverview">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>434</width>
<height>361</height>
</rect>
</property>
<property name="windowTitle">
<string>Qt Creator - Plugin loader messages</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>The following plugins have errors and cannot be loaded:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="pluginList"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Details:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="pluginError">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::NoButton</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExtensionSystem::Internal::PluginErrorOverview</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExtensionSystem::Internal::PluginErrorOverview</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -328,6 +328,22 @@ void PluginManager::loadPlugins()
return d->loadPlugins();
}
/*!
\fn bool PluginManager::hasError() const
Returns true if any plugin has errors even though it is enabled.
Most useful to call after loadPlugins().
*/
bool PluginManager::hasError() const
{
foreach (PluginSpec *spec, plugins()) {
// only show errors on startup if plugin is enabled.
if (spec->hasError() && spec->isEnabled() && !spec->isDisabledIndirectly()) {
return true;
}
}
return false;
}
/*!
\fn void PluginManager::shutdown()
Shuts down and deletes all plugins.
......
......@@ -106,6 +106,7 @@ public:
QHash<QString, PluginCollection *> pluginCollections() const;
void setFileExtension(const QString &extension);
QString fileExtension() const;
bool hasError() const;
// Settings
void setSettings(QSettings *settings);
......
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