forked from qt-creator/qt-creator
Extensionsystem: Modernize
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-equals-default Change-Id: I20b4508e98ad3f8d6cd0ca2339bfc4c7dcb2ef2c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -34,7 +34,7 @@ InvokerBase::InvokerBase()
|
|||||||
nag = true;
|
nag = true;
|
||||||
success = true;
|
success = true;
|
||||||
connectionType = Qt::AutoConnection;
|
connectionType = Qt::AutoConnection;
|
||||||
target = 0;
|
target = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvokerBase::~InvokerBase()
|
InvokerBase::~InvokerBase()
|
||||||
|
@@ -265,9 +265,9 @@ bool OptionsParser::checkForUnknownOption()
|
|||||||
|
|
||||||
void OptionsParser::forceDisableAllPluginsExceptTestedAndForceEnabled()
|
void OptionsParser::forceDisableAllPluginsExceptTestedAndForceEnabled()
|
||||||
{
|
{
|
||||||
for (const PluginManagerPrivate::TestSpec &testSpec : m_pmPrivate->testSpecs)
|
for (const PluginManagerPrivate::TestSpec &testSpec : qAsConst(m_pmPrivate->testSpecs))
|
||||||
testSpec.pluginSpec->d->setForceEnabled(true);
|
testSpec.pluginSpec->d->setForceEnabled(true);
|
||||||
for (PluginSpec *spec : m_pmPrivate->pluginSpecs) {
|
for (PluginSpec *spec : qAsConst(m_pmPrivate->pluginSpecs)) {
|
||||||
if (!spec->isForceEnabled() && !spec->isRequired())
|
if (!spec->isForceEnabled() && !spec->isRequired())
|
||||||
spec->d->setForceDisabled(true);
|
spec->d->setForceDisabled(true);
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ PluginErrorOverview::~PluginErrorOverview()
|
|||||||
void PluginErrorOverview::showDetails(QListWidgetItem *item)
|
void PluginErrorOverview::showDetails(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
if (item) {
|
if (item) {
|
||||||
PluginSpec *spec = item->data(Qt::UserRole).value<PluginSpec *>();
|
auto *spec = item->data(Qt::UserRole).value<PluginSpec *>();
|
||||||
m_ui->pluginError->setText(spec->errorString());
|
m_ui->pluginError->setText(spec->errorString());
|
||||||
} else {
|
} else {
|
||||||
m_ui->pluginError->clear();
|
m_ui->pluginError->clear();
|
||||||
|
@@ -256,8 +256,8 @@ namespace ExtensionSystem {
|
|||||||
|
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
static Internal::PluginManagerPrivate *d = 0;
|
static Internal::PluginManagerPrivate *d = nullptr;
|
||||||
static PluginManager *m_instance = 0;
|
static PluginManager *m_instance = nullptr;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Gets the unique plugin manager instance.
|
Gets the unique plugin manager instance.
|
||||||
@@ -282,7 +282,7 @@ PluginManager::PluginManager()
|
|||||||
PluginManager::~PluginManager()
|
PluginManager::~PluginManager()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
d = 0;
|
d = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -625,7 +625,7 @@ void PluginManager::remoteArguments(const QString &serializedArgument, QObject *
|
|||||||
arguments);
|
arguments);
|
||||||
if (socketParent && socket) {
|
if (socketParent && socket) {
|
||||||
socket->setParent(socketParent);
|
socket->setParent(socketParent);
|
||||||
socket = 0;
|
socket = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -829,7 +829,7 @@ void PluginManagerPrivate::nextDelayedInitialize()
|
|||||||
if (delayedInitializeQueue.isEmpty()) {
|
if (delayedInitializeQueue.isEmpty()) {
|
||||||
m_isInitializationDone = true;
|
m_isInitializationDone = true;
|
||||||
delete delayedInitializeTimer;
|
delete delayedInitializeTimer;
|
||||||
delayedInitializeTimer = 0;
|
delayedInitializeTimer = nullptr;
|
||||||
profilingSummary();
|
profilingSummary();
|
||||||
emit q->initializationDone();
|
emit q->initializationDone();
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
@@ -845,12 +845,6 @@ void PluginManagerPrivate::nextDelayedInitialize()
|
|||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
|
PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
|
||||||
delayedInitializeTimer(0),
|
|
||||||
shutdownEventLoop(0),
|
|
||||||
m_profileElapsedMS(0),
|
|
||||||
m_profilingVerbosity(0),
|
|
||||||
settings(0),
|
|
||||||
globalSettings(0),
|
|
||||||
q(pluginManager)
|
q(pluginManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -907,7 +901,7 @@ void PluginManagerPrivate::stopAll()
|
|||||||
if (delayedInitializeTimer && delayedInitializeTimer->isActive()) {
|
if (delayedInitializeTimer && delayedInitializeTimer->isActive()) {
|
||||||
delayedInitializeTimer->stop();
|
delayedInitializeTimer->stop();
|
||||||
delete delayedInitializeTimer;
|
delete delayedInitializeTimer;
|
||||||
delayedInitializeTimer = 0;
|
delayedInitializeTimer = nullptr;
|
||||||
}
|
}
|
||||||
QList<PluginSpec *> queue = loadQueue();
|
QList<PluginSpec *> queue = loadQueue();
|
||||||
foreach (PluginSpec *spec, queue) {
|
foreach (PluginSpec *spec, queue) {
|
||||||
@@ -927,8 +921,8 @@ void PluginManagerPrivate::deleteAll()
|
|||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
|
|
||||||
typedef QMap<QObject *, QStringList> TestPlan; // Object -> selected test functions
|
using TestPlan = QMap<QObject *, QStringList>; // Object -> selected test functions
|
||||||
typedef QMapIterator<QObject *, QStringList> TestPlanIterator;
|
using TestPlanIterator = QMapIterator<QObject *, QStringList>;
|
||||||
|
|
||||||
static bool isTestFunction(const QMetaMethod &metaMethod)
|
static bool isTestFunction(const QMetaMethod &metaMethod)
|
||||||
{
|
{
|
||||||
@@ -999,7 +993,7 @@ static QStringList matchingTestFunctions(const QStringList &testFunctions,
|
|||||||
|
|
||||||
static QObject *objectWithClassName(const QList<QObject *> &objects, const QString &className)
|
static QObject *objectWithClassName(const QList<QObject *> &objects, const QString &className)
|
||||||
{
|
{
|
||||||
return Utils::findOr(objects, 0, [className] (QObject *object) -> bool {
|
return Utils::findOr(objects, nullptr, [className] (QObject *object) -> bool {
|
||||||
QString candidate = QString::fromUtf8(object->metaObject()->className());
|
QString candidate = QString::fromUtf8(object->metaObject()->className());
|
||||||
const int colonIndex = candidate.lastIndexOf(QLatin1Char(':'));
|
const int colonIndex = candidate.lastIndexOf(QLatin1Char(':'));
|
||||||
if (colonIndex != -1 && colonIndex < candidate.size() - 1)
|
if (colonIndex != -1 && colonIndex < candidate.size() - 1)
|
||||||
@@ -1159,7 +1153,7 @@ void PluginManagerPrivate::addObject(QObject *obj)
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
QWriteLocker lock(&m_lock);
|
QWriteLocker lock(&m_lock);
|
||||||
if (obj == 0) {
|
if (obj == nullptr) {
|
||||||
qWarning() << "PluginManagerPrivate::addObject(): trying to add null object";
|
qWarning() << "PluginManagerPrivate::addObject(): trying to add null object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1188,7 +1182,7 @@ void PluginManagerPrivate::addObject(QObject *obj)
|
|||||||
*/
|
*/
|
||||||
void PluginManagerPrivate::removeObject(QObject *obj)
|
void PluginManagerPrivate::removeObject(QObject *obj)
|
||||||
{
|
{
|
||||||
if (obj == 0) {
|
if (obj == nullptr) {
|
||||||
qWarning() << "PluginManagerPrivate::removeObject(): trying to remove null object";
|
qWarning() << "PluginManagerPrivate::removeObject(): trying to remove null object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1265,7 +1259,7 @@ void PluginManagerPrivate::shutdown()
|
|||||||
*/
|
*/
|
||||||
void PluginManagerPrivate::asyncShutdownFinished()
|
void PluginManagerPrivate::asyncShutdownFinished()
|
||||||
{
|
{
|
||||||
IPlugin *plugin = qobject_cast<IPlugin *>(sender());
|
auto *plugin = qobject_cast<IPlugin *>(sender());
|
||||||
Q_ASSERT(plugin);
|
Q_ASSERT(plugin);
|
||||||
asynchronousPlugins.removeAll(plugin->pluginSpec());
|
asynchronousPlugins.removeAll(plugin->pluginSpec());
|
||||||
if (asynchronousPlugins.isEmpty())
|
if (asynchronousPlugins.isEmpty())
|
||||||
@@ -1442,7 +1436,7 @@ void PluginManagerPrivate::readPluginPaths()
|
|||||||
pluginCategories.insert(QString(), QList<PluginSpec *>());
|
pluginCategories.insert(QString(), QList<PluginSpec *>());
|
||||||
|
|
||||||
foreach (const QString &pluginFile, pluginFiles(pluginPaths)) {
|
foreach (const QString &pluginFile, pluginFiles(pluginPaths)) {
|
||||||
PluginSpec *spec = new PluginSpec;
|
auto *spec = new PluginSpec;
|
||||||
if (!spec->d->read(pluginFile)) { // not a Qt Creator plugin
|
if (!spec->d->read(pluginFile)) { // not a Qt Creator plugin
|
||||||
delete spec;
|
delete spec;
|
||||||
continue;
|
continue;
|
||||||
@@ -1505,7 +1499,7 @@ PluginSpec *PluginManagerPrivate::pluginForOption(const QString &option, bool *r
|
|||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginSpec *PluginManagerPrivate::pluginByName(const QString &name) const
|
PluginSpec *PluginManagerPrivate::pluginByName(const QString &name) const
|
||||||
|
@@ -55,7 +55,7 @@ class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PluginManagerPrivate(PluginManager *pluginManager);
|
PluginManagerPrivate(PluginManager *pluginManager);
|
||||||
virtual ~PluginManagerPrivate();
|
~PluginManagerPrivate() override;
|
||||||
|
|
||||||
// Object pool operations
|
// Object pool operations
|
||||||
void addObject(QObject *obj);
|
void addObject(QObject *obj);
|
||||||
@@ -106,19 +106,19 @@ public:
|
|||||||
QStringList disabledPlugins;
|
QStringList disabledPlugins;
|
||||||
QStringList forceEnabledPlugins;
|
QStringList forceEnabledPlugins;
|
||||||
// delayed initialization
|
// delayed initialization
|
||||||
QTimer *delayedInitializeTimer;
|
QTimer *delayedInitializeTimer = nullptr;
|
||||||
QList<PluginSpec *> delayedInitializeQueue;
|
QList<PluginSpec *> delayedInitializeQueue;
|
||||||
// ansynchronous shutdown
|
// ansynchronous shutdown
|
||||||
QList<PluginSpec *> asynchronousPlugins; // plugins that have requested async shutdown
|
QList<PluginSpec *> asynchronousPlugins; // plugins that have requested async shutdown
|
||||||
QEventLoop *shutdownEventLoop; // used for async shutdown
|
QEventLoop *shutdownEventLoop = nullptr; // used for async shutdown
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
QScopedPointer<QTime> m_profileTimer;
|
QScopedPointer<QTime> m_profileTimer;
|
||||||
QHash<const PluginSpec *, int> m_profileTotal;
|
QHash<const PluginSpec *, int> m_profileTotal;
|
||||||
int m_profileElapsedMS;
|
int m_profileElapsedMS = 0;
|
||||||
unsigned m_profilingVerbosity;
|
unsigned m_profilingVerbosity = 0;
|
||||||
QSettings *settings;
|
QSettings *settings = nullptr;
|
||||||
QSettings *globalSettings;
|
QSettings *globalSettings = nullptr;
|
||||||
|
|
||||||
// Look in argument descriptions of the specs for the option.
|
// Look in argument descriptions of the specs for the option.
|
||||||
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
|
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
|
||||||
|
@@ -182,7 +182,7 @@ PluginSpec::PluginSpec()
|
|||||||
PluginSpec::~PluginSpec()
|
PluginSpec::~PluginSpec()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
d = 0;
|
d = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -963,7 +963,7 @@ bool PluginSpecPrivate::loadLibrary()
|
|||||||
+ QString::fromLatin1(": ") + loader.errorString();
|
+ QString::fromLatin1(": ") + loader.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IPlugin *pluginObject = qobject_cast<IPlugin*>(loader.instance());
|
auto *pluginObject = qobject_cast<IPlugin*>(loader.instance());
|
||||||
if (!pluginObject) {
|
if (!pluginObject) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
errorString = QCoreApplication::translate("PluginSpec", "Plugin is not valid (does not derive from IPlugin)");
|
errorString = QCoreApplication::translate("PluginSpec", "Plugin is not valid (does not derive from IPlugin)");
|
||||||
@@ -1065,6 +1065,6 @@ void PluginSpecPrivate::kill()
|
|||||||
if (!plugin)
|
if (!plugin)
|
||||||
return;
|
return;
|
||||||
delete plugin;
|
delete plugin;
|
||||||
plugin = 0;
|
plugin = nullptr;
|
||||||
state = PluginSpec::Deleted;
|
state = PluginSpec::Deleted;
|
||||||
}
|
}
|
||||||
|
@@ -106,7 +106,7 @@ public:
|
|||||||
QVector<PluginDependency> dependencies() const;
|
QVector<PluginDependency> dependencies() const;
|
||||||
QJsonObject metaData() const;
|
QJsonObject metaData() const;
|
||||||
|
|
||||||
typedef QVector<PluginArgumentDescription> PluginArgumentDescriptions;
|
using PluginArgumentDescriptions = QVector<PluginArgumentDescription>;
|
||||||
PluginArgumentDescriptions argumentDescriptions() const;
|
PluginArgumentDescriptions argumentDescriptions() const;
|
||||||
|
|
||||||
// other information, valid after 'Read' state is reached
|
// other information, valid after 'Read' state is reached
|
||||||
|
@@ -110,7 +110,7 @@ public:
|
|||||||
|
|
||||||
int columnCount() const { return 4; }
|
int columnCount() const { return 4; }
|
||||||
|
|
||||||
QVariant data(int column, int role) const
|
QVariant data(int column, int role) const override
|
||||||
{
|
{
|
||||||
if (role == HiddenByDefaultRole)
|
if (role == HiddenByDefaultRole)
|
||||||
return m_spec->isHiddenByDefault() || !m_spec->isAvailableForHostPlatform();
|
return m_spec->isHiddenByDefault() || !m_spec->isAvailableForHostPlatform();
|
||||||
@@ -177,7 +177,7 @@ public:
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setData(int column, const QVariant &data, int role)
|
bool setData(int column, const QVariant &data, int role) override
|
||||||
{
|
{
|
||||||
if (column == LoadedColumn && role == Qt::CheckStateRole)
|
if (column == LoadedColumn && role == Qt::CheckStateRole)
|
||||||
return m_view->setPluginsEnabled(QSet<PluginSpec *>() << m_spec, data.toBool());
|
return m_view->setPluginsEnabled(QSet<PluginSpec *>() << m_spec, data.toBool());
|
||||||
@@ -189,7 +189,7 @@ public:
|
|||||||
return m_spec->isAvailableForHostPlatform() && !m_spec->isRequired();
|
return m_spec->isAvailableForHostPlatform() && !m_spec->isRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags flags(int column) const
|
Qt::ItemFlags flags(int column) const override
|
||||||
{
|
{
|
||||||
Qt::ItemFlags ret = Qt::ItemIsSelectable;
|
Qt::ItemFlags ret = Qt::ItemIsSelectable;
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ public:
|
|||||||
|
|
||||||
int columnCount() const { return 4; }
|
int columnCount() const { return 4; }
|
||||||
|
|
||||||
QVariant data(int column, int role) const
|
QVariant data(int column, int role) const override
|
||||||
{
|
{
|
||||||
if (role == HiddenByDefaultRole)
|
if (role == HiddenByDefaultRole)
|
||||||
return false;
|
return false;
|
||||||
@@ -260,7 +260,7 @@ public:
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setData(int column, const QVariant &data, int role)
|
bool setData(int column, const QVariant &data, int role) override
|
||||||
{
|
{
|
||||||
if (column == LoadedColumn && role == Qt::CheckStateRole) {
|
if (column == LoadedColumn && role == Qt::CheckStateRole) {
|
||||||
const QList<PluginSpec *> affectedPlugins =
|
const QList<PluginSpec *> affectedPlugins =
|
||||||
@@ -273,7 +273,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags flags(int column) const
|
Qt::ItemFlags flags(int column) const override
|
||||||
{
|
{
|
||||||
Qt::ItemFlags ret = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
Qt::ItemFlags ret = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
if (column == LoadedColumn)
|
if (column == LoadedColumn)
|
||||||
@@ -290,7 +290,7 @@ public:
|
|||||||
class PluginFilterModel : public CategorySortFilterModel
|
class PluginFilterModel : public CategorySortFilterModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PluginFilterModel(QObject *parent = 0) : CategorySortFilterModel(parent) {}
|
PluginFilterModel(QObject *parent = nullptr) : CategorySortFilterModel(parent) {}
|
||||||
|
|
||||||
void setShowHidden(bool show)
|
void setShowHidden(bool show)
|
||||||
{
|
{
|
||||||
@@ -355,7 +355,7 @@ PluginView::PluginView(QWidget *parent)
|
|||||||
m_sortModel->setFilterKeyColumn(-1/*all*/);
|
m_sortModel->setFilterKeyColumn(-1/*all*/);
|
||||||
m_categoryView->setModel(m_sortModel);
|
m_categoryView->setModel(m_sortModel);
|
||||||
|
|
||||||
QGridLayout *gridLayout = new QGridLayout(this);
|
auto *gridLayout = new QGridLayout(this);
|
||||||
gridLayout->setContentsMargins(2, 2, 2, 2);
|
gridLayout->setContentsMargins(2, 2, 2, 2);
|
||||||
gridLayout->addWidget(m_categoryView, 1, 0, 1, 1);
|
gridLayout->addWidget(m_categoryView, 1, 0, 1, 1);
|
||||||
|
|
||||||
@@ -367,10 +367,10 @@ PluginView::PluginView(QWidget *parent)
|
|||||||
this, &PluginView::updatePlugins);
|
this, &PluginView::updatePlugins);
|
||||||
|
|
||||||
connect(m_categoryView, &QAbstractItemView::activated,
|
connect(m_categoryView, &QAbstractItemView::activated,
|
||||||
[this](const QModelIndex &idx) { pluginActivated(pluginForIndex(idx)); });
|
[this](const QModelIndex &idx) { emit pluginActivated(pluginForIndex(idx)); });
|
||||||
|
|
||||||
connect(m_categoryView->selectionModel(), &QItemSelectionModel::currentChanged,
|
connect(m_categoryView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||||
[this](const QModelIndex &idx) { currentPluginChanged(pluginForIndex(idx)); });
|
[this](const QModelIndex &idx) { emit currentPluginChanged(pluginForIndex(idx)); });
|
||||||
|
|
||||||
updatePlugins();
|
updatePlugins();
|
||||||
}
|
}
|
||||||
@@ -378,9 +378,7 @@ PluginView::PluginView(QWidget *parent)
|
|||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
PluginView::~PluginView()
|
PluginView::~PluginView() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the current selection in the list of plugins.
|
Returns the current selection in the list of plugins.
|
||||||
@@ -411,7 +409,7 @@ PluginSpec *PluginView::pluginForIndex(const QModelIndex &index) const
|
|||||||
{
|
{
|
||||||
const QModelIndex &sourceIndex = m_sortModel->mapToSource(index);
|
const QModelIndex &sourceIndex = m_sortModel->mapToSource(index);
|
||||||
PluginItem *item = m_model->itemForIndexAtLevel<2>(sourceIndex);
|
PluginItem *item = m_model->itemForIndexAtLevel<2>(sourceIndex);
|
||||||
return item ? item->m_spec: 0;
|
return item ? item->m_spec: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginView::updatePlugins()
|
void PluginView::updatePlugins()
|
||||||
@@ -432,7 +430,7 @@ void PluginView::updatePlugins()
|
|||||||
foreach (CollectionItem *collection, collections)
|
foreach (CollectionItem *collection, collections)
|
||||||
m_model->rootItem()->appendChild(collection);
|
m_model->rootItem()->appendChild(collection);
|
||||||
|
|
||||||
m_model->layoutChanged();
|
emit m_model->layoutChanged();
|
||||||
m_categoryView->expandAll();
|
m_categoryView->expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user