forked from qt-creator/qt-creator
ExtensionSystem: Return Utils::Result from IPlugin::initialize()
Change-Id: I3c41ddcbbb2b2eb7c4c69797aa90fa794b4b9141 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -172,12 +172,11 @@ IPlugin::IPlugin() = default;
|
||||
*/
|
||||
IPlugin::~IPlugin() = default;
|
||||
|
||||
bool IPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
Utils::Result<> IPlugin::initialize(const QStringList &arguments)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
initialize();
|
||||
return true;
|
||||
return Utils::ResultOk;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "extensionsystem_global.h"
|
||||
|
||||
#include <utils/result.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <functional>
|
||||
@@ -28,7 +30,7 @@ public:
|
||||
IPlugin();
|
||||
~IPlugin() override;
|
||||
|
||||
virtual bool initialize(const QStringList &arguments, QString *errorString);
|
||||
virtual Utils::Result<> initialize(const QStringList &arguments);
|
||||
virtual void extensionsInitialized() {}
|
||||
virtual bool delayedInitialize() { return false; }
|
||||
virtual ShutdownFlag aboutToShutdown() { return SynchronousShutdown; }
|
||||
|
@@ -1342,9 +1342,8 @@ bool CppPluginSpec::initializePlugin()
|
||||
::ExtensionSystem::Tr::tr("Internal error: have no plugin instance to initialize"));
|
||||
return false;
|
||||
}
|
||||
QString err;
|
||||
if (!d->plugin->initialize(arguments(), &err)) {
|
||||
setError(::ExtensionSystem::Tr::tr("Plugin initialization failed: %1").arg(err));
|
||||
if (Result<> res = d->plugin->initialize(arguments()); !res) {
|
||||
setError(::ExtensionSystem::Tr::tr("Plugin initialization failed: %1").arg(res.error()));
|
||||
return false;
|
||||
}
|
||||
setState(PluginSpec::Initialized);
|
||||
|
@@ -244,15 +244,14 @@ static void addToPathChooserContextMenu(PathChooser *pathChooser, QMenu *menu)
|
||||
menu->insertSeparator(firstAction);
|
||||
}
|
||||
|
||||
bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
Result<> CorePlugin::initialize(const QStringList &arguments)
|
||||
{
|
||||
initTAndCAcceptDialog();
|
||||
initProxyAuthDialog();
|
||||
|
||||
if (ThemeEntry::availableThemes().isEmpty()) {
|
||||
*errorMessage = Tr::tr("No themes found in installation.");
|
||||
return false;
|
||||
}
|
||||
if (ThemeEntry::availableThemes().isEmpty())
|
||||
return ResultError(Tr::tr("No themes found in installation."));
|
||||
|
||||
const CoreArguments args = parseArguments(arguments);
|
||||
Theme *themeFromArg = ThemeEntry::createTheme(args.themeId);
|
||||
Theme *theme = themeFromArg ? themeFromArg
|
||||
@@ -372,7 +371,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
addTestCreator(&createVcsManagerTest);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
static Id generateOpenPageCommandId(IOptionsPage *page)
|
||||
|
@@ -19,24 +19,24 @@ namespace Internal {
|
||||
class EditMode;
|
||||
class Locator;
|
||||
|
||||
class CorePlugin : public ExtensionSystem::IPlugin
|
||||
class CorePlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Core.json")
|
||||
|
||||
public:
|
||||
CorePlugin();
|
||||
~CorePlugin() override;
|
||||
~CorePlugin() final;
|
||||
|
||||
static CorePlugin *instance();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override;
|
||||
void extensionsInitialized() override;
|
||||
bool delayedInitialize() override;
|
||||
ShutdownFlag aboutToShutdown() override;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
void extensionsInitialized() final;
|
||||
bool delayedInitialize() final;
|
||||
ShutdownFlag aboutToShutdown() final;
|
||||
QObject *remoteCommand(const QStringList & /* options */,
|
||||
const QString &workingDirectory,
|
||||
const QStringList &args) override;
|
||||
const QStringList &args) final;
|
||||
|
||||
static QString msgCrashpadInformation();
|
||||
|
||||
|
@@ -2056,7 +2056,7 @@ public:
|
||||
|
||||
private:
|
||||
// IPlugin implementation.
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
QObject *remoteCommand(const QStringList &options,
|
||||
const QString &workingDirectory,
|
||||
const QStringList &arguments) final;
|
||||
@@ -2272,10 +2272,8 @@ void showPermanentStatusMessage(const QString &message)
|
||||
|
||||
namespace Internal {
|
||||
|
||||
bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
Result<> DebuggerPlugin::initialize(const QStringList &arguments)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
IOptionsPage::registerCategory(
|
||||
DEBUGGER_SETTINGS_CATEGORY,
|
||||
Tr::tr("Debugger"),
|
||||
@@ -2295,7 +2293,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
addTestCreator(createDebuggerTest);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
void DebuggerPlugin::attachToProcess(const qint64 processId, const Utils::FilePath &executable)
|
||||
|
@@ -129,7 +129,7 @@ class DesignerPlugin final : public ExtensionSystem::IPlugin
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *) final
|
||||
Result<> initialize(const QStringList &arguments) final
|
||||
{
|
||||
d = new FormEditorPluginPrivate;
|
||||
|
||||
@@ -166,7 +166,7 @@ class DesignerPlugin final : public ExtensionSystem::IPlugin
|
||||
#endif
|
||||
|
||||
parseArguments(arguments);
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
void extensionsInitialized() final
|
||||
|
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
|
||||
namespace EffectComposer {
|
||||
|
||||
static bool enableEffectComposer()
|
||||
@@ -16,7 +15,7 @@ static bool enableEffectComposer()
|
||||
return Core::ICore::isQtDesignStudio();
|
||||
}
|
||||
|
||||
class EffectComposerPlugin : public ExtensionSystem::IPlugin
|
||||
class EffectComposerPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "EffectComposer.json")
|
||||
@@ -25,10 +24,9 @@ public:
|
||||
EffectComposerPlugin() {}
|
||||
~EffectComposerPlugin() override {}
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) override
|
||||
void initialize() final
|
||||
{
|
||||
EffectComposerView::registerDeclarativeTypes();
|
||||
return ExtensionSystem::IPlugin::initialize(arguments, errorString);
|
||||
}
|
||||
|
||||
bool delayedInitialize() override
|
||||
|
@@ -2254,10 +2254,8 @@ class GITSHARED_EXPORT GitPlugin final : public ExtensionSystem::IPlugin
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) final
|
||||
Result<> initialize(const QStringList &arguments) final
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
addTest<GitTest>();
|
||||
#endif
|
||||
@@ -2270,8 +2268,7 @@ class GITSHARED_EXPORT GitPlugin final : public ExtensionSystem::IPlugin
|
||||
remoteCommand(arguments, QDir::currentPath(), {});
|
||||
cmdContext->deleteLater();
|
||||
});
|
||||
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
void extensionsInitialized() final
|
||||
|
@@ -166,7 +166,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -781,10 +780,8 @@ static void restoreRecentProjects(QtcSettings *s)
|
||||
dd->checkRecentProjectsAsync();
|
||||
}
|
||||
|
||||
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
Result<> ProjectExplorerPlugin::initialize(const QStringList &arguments)
|
||||
{
|
||||
Q_UNUSED(error)
|
||||
|
||||
IOptionsPage::registerCategory(
|
||||
Constants::KITS_SETTINGS_CATEGORY,
|
||||
Tr::tr("Kits"),
|
||||
@@ -1940,7 +1937,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
#ifdef WITH_TESTS
|
||||
addTestCreator(&createSanitizerOutputParserTest);
|
||||
#endif
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
void ProjectExplorerPluginPrivate::loadAction()
|
||||
|
@@ -82,7 +82,7 @@ private:
|
||||
QString m_errorMessage;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin : public ExtensionSystem::IPlugin
|
||||
class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ProjectExplorer.json")
|
||||
@@ -91,7 +91,7 @@ class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin : public ExtensionSystem::IPl
|
||||
|
||||
public:
|
||||
ProjectExplorerPlugin();
|
||||
~ProjectExplorerPlugin() override;
|
||||
~ProjectExplorerPlugin() final;
|
||||
|
||||
static ProjectExplorerPlugin *instance();
|
||||
|
||||
@@ -106,10 +106,10 @@ public:
|
||||
static void showContextMenu(QWidget *view, const QPoint &globalPos, Node *node);
|
||||
|
||||
//PluginInterface
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||
void extensionsInitialized() override;
|
||||
bool delayedInitialize() override;
|
||||
ShutdownFlag aboutToShutdown() override;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
void extensionsInitialized() final;
|
||||
bool delayedInitialize() final;
|
||||
ShutdownFlag aboutToShutdown() final;
|
||||
|
||||
static void setCustomParsers(const QList<CustomParserSettings> &settings);
|
||||
static void addCustomParser(const CustomParserSettings &settings);
|
||||
|
@@ -88,8 +88,6 @@
|
||||
|
||||
#include <modelnodecontextmenu_helper.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
static Q_LOGGING_CATEGORY(qmldesignerLog, "qtc.qmldesigner", QtWarningMsg)
|
||||
|
||||
using namespace Core;
|
||||
@@ -258,7 +256,7 @@ QmlDesignerPlugin::~QmlDesignerPlugin()
|
||||
// INHERITED FROM ExtensionSystem::Plugin
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString * /*errorMessage*/)
|
||||
Utils::Result<> QmlDesignerPlugin::initialize(const QStringList &)
|
||||
{
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
auto specialSnapshotName = QGuiApplication::applicationDisplayName() + "(PROJECTSTORAGE)";
|
||||
@@ -270,7 +268,8 @@ bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
QMessageBox::warning(Core::ICore::dialogParent(),
|
||||
tr("Qml Designer Lite"),
|
||||
tr("The Qml Designer Lite plugin is not enabled."));
|
||||
return false;
|
||||
return Utils::ResultError(tr("Qml Designer Lite initialization error: "
|
||||
"The Qml Designer Lite plugin is not enabled."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +319,7 @@ bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
d->statusBar = ToolBar::createStatusBar();
|
||||
}
|
||||
|
||||
return true;
|
||||
return Utils::ResultOk;
|
||||
}
|
||||
|
||||
bool QmlDesignerPlugin::delayedInitialize()
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
QmlDesignerPlugin();
|
||||
~QmlDesignerPlugin() final;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
bool delayedInitialize() final;
|
||||
void extensionsInitialized() final;
|
||||
ShutdownFlag aboutToShutdown() final;
|
||||
|
@@ -87,7 +87,7 @@ bool QmlDesignerBasePlugin::isLiteModeEnabled()
|
||||
return global->m_enableLiteMode;
|
||||
}
|
||||
|
||||
bool QmlDesignerBasePlugin::initialize(const QStringList &arguments, QString *)
|
||||
Utils::Result<> QmlDesignerBasePlugin::initialize(const QStringList &arguments)
|
||||
{
|
||||
if (arguments.contains("-qml-lite-designer"))
|
||||
enableLiteMode();
|
||||
@@ -100,7 +100,7 @@ bool QmlDesignerBasePlugin::initialize(const QStringList &arguments, QString *)
|
||||
d = std::make_unique<Data>();
|
||||
if (Core::ICore::settings()->value("QML/Designer/StandAloneMode", false).toBool())
|
||||
d->studioConfigSettingsPage = std::make_unique<StudioConfigSettingsPage>();
|
||||
return true;
|
||||
return Utils::ResultOk;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -37,7 +37,7 @@ public:
|
||||
static bool isLiteModeEnabled();
|
||||
|
||||
private:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
|
||||
private:
|
||||
class Data;
|
||||
|
@@ -12,11 +12,4 @@ QmlDesignerLitePlugin::QmlDesignerLitePlugin()
|
||||
QmlDesignerBasePlugin::enableLiteMode();
|
||||
}
|
||||
|
||||
QmlDesignerLitePlugin::~QmlDesignerLitePlugin() = default;
|
||||
|
||||
bool QmlDesignerLitePlugin::initialize(const QStringList &, QString *)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -14,10 +14,6 @@ class QmlDesignerLitePlugin final : public ExtensionSystem::IPlugin
|
||||
|
||||
public:
|
||||
QmlDesignerLitePlugin();
|
||||
~QmlDesignerLitePlugin();
|
||||
|
||||
private:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -3,6 +3,5 @@ add_qtc_plugin(SafeRenderer
|
||||
QtCreator::Core QtCreator::ProjectExplorer
|
||||
SOURCES
|
||||
saferenderer.qrc
|
||||
saferenderer.cpp
|
||||
saferenderer.h
|
||||
)
|
||||
|
@@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "saferenderer.h"
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||
|
||||
namespace SafeRenderer::Internal {
|
||||
|
||||
SafeRendererPlugin::SafeRendererPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
SafeRendererPlugin::~SafeRendererPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
bool SafeRendererPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace SafeRenderer::Internal
|
@@ -7,16 +7,10 @@
|
||||
|
||||
namespace SafeRenderer::Internal {
|
||||
|
||||
class SafeRendererPlugin : public ExtensionSystem::IPlugin
|
||||
class SafeRendererPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "SafeRenderer.json")
|
||||
|
||||
public:
|
||||
SafeRendererPlugin();
|
||||
~SafeRendererPlugin() override;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||
};
|
||||
|
||||
} // namespace SafeRenderer::Internal
|
||||
|
@@ -7,7 +7,6 @@ QtcPlugin {
|
||||
Depends { name: "ProjectExplorer" }
|
||||
|
||||
files: [
|
||||
"saferenderer.cpp",
|
||||
"saferenderer.h",
|
||||
"saferenderer.qrc",
|
||||
]
|
||||
|
@@ -288,21 +288,19 @@ void UpdateInfoPlugin::extensionsInitialized()
|
||||
QTimer::singleShot(OneMinute, this, &UpdateInfoPlugin::startAutoCheckForUpdates);
|
||||
}
|
||||
|
||||
bool UpdateInfoPlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
|
||||
Result<> UpdateInfoPlugin::initialize(const QStringList &)
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
if (d->m_maintenanceTool.isEmpty()) {
|
||||
*errorMessage = Tr::tr("Could not determine location of maintenance tool. Please check "
|
||||
"your installation if you did not enable this plugin manually.");
|
||||
return false;
|
||||
return ResultError(Tr::tr("Could not determine location of maintenance tool. Please check "
|
||||
"your installation if you did not enable this plugin manually."));
|
||||
}
|
||||
|
||||
if (!d->m_maintenanceTool.isExecutableFile()) {
|
||||
*errorMessage = Tr::tr("The maintenance tool at \"%1\" is not an executable. Check your installation.")
|
||||
.arg(d->m_maintenanceTool.toUserOutput());
|
||||
d->m_maintenanceTool.clear();
|
||||
return false;
|
||||
return ResultError(Tr::tr("The maintenance tool at \"%1\" is not an executable. Check your installation.")
|
||||
.arg(d->m_maintenanceTool.toUserOutput()));
|
||||
}
|
||||
|
||||
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
||||
@@ -332,8 +330,7 @@ bool UpdateInfoPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
startMaintenanceTool({});
|
||||
});
|
||||
mmaintenanceTool->addAction(startMaintenanceToolCommand);
|
||||
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
void UpdateInfoPlugin::loadSettings() const
|
||||
|
@@ -33,7 +33,7 @@ public:
|
||||
~UpdateInfoPlugin() override;
|
||||
|
||||
void extensionsInitialized() override;
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
|
||||
bool isAutomaticCheck() const;
|
||||
void setAutomaticCheck(bool on);
|
||||
|
@@ -376,7 +376,7 @@ class WelcomePlugin final : public ExtensionSystem::IPlugin
|
||||
|
||||
~WelcomePlugin() final { delete m_welcomeMode; }
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *) final
|
||||
Result<> initialize(const QStringList &arguments) final
|
||||
{
|
||||
m_welcomeMode = new WelcomeMode;
|
||||
|
||||
@@ -389,8 +389,7 @@ class WelcomePlugin final : public ExtensionSystem::IPlugin
|
||||
connect(ICore::instance(), &ICore::coreOpened, this, [] { askUserAboutIntroduction(); },
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
return true;
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
void extensionsInitialized() final
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
using namespace Plugin1;
|
||||
using namespace Utils;
|
||||
|
||||
MyPlugin1::~MyPlugin1()
|
||||
{
|
||||
@@ -13,7 +14,7 @@ MyPlugin1::~MyPlugin1()
|
||||
ExtensionSystem::PluginManager::removeObject(object2);
|
||||
}
|
||||
|
||||
bool MyPlugin1::initialize(const QStringList & /*arguments*/, QString *errorString)
|
||||
Result<> MyPlugin1::initialize(const QStringList &)
|
||||
{
|
||||
initializeCalled = true;
|
||||
object1 = new QObject(this);
|
||||
@@ -27,18 +28,15 @@ bool MyPlugin1::initialize(const QStringList & /*arguments*/, QString *errorStri
|
||||
found2 = true;
|
||||
else if (object->objectName() == QLatin1String("MyPlugin3"))
|
||||
found3 = true;
|
||||
}
|
||||
if (found2 && found3)
|
||||
return true;
|
||||
if (errorString) {
|
||||
return ResultOk;
|
||||
}
|
||||
QString error = QLatin1String("object(s) missing from plugin(s):");
|
||||
if (!found2)
|
||||
error.append(QLatin1String(" plugin2"));
|
||||
if (!found3)
|
||||
error.append(QLatin1String(" plugin3"));
|
||||
*errorString = error;
|
||||
}
|
||||
return false;
|
||||
return ResultError(error);
|
||||
}
|
||||
|
||||
void MyPlugin1::extensionsInitialized()
|
||||
|
@@ -24,7 +24,7 @@ public:
|
||||
MyPlugin1() = default;
|
||||
~MyPlugin1() final;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
void extensionsInitialized() final;
|
||||
|
||||
private:
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
using namespace Plugin3;
|
||||
using namespace Utils;
|
||||
|
||||
MyPlugin3::~MyPlugin3()
|
||||
{
|
||||
@@ -13,23 +14,18 @@ MyPlugin3::~MyPlugin3()
|
||||
ExtensionSystem::PluginManager::removeObject(object2);
|
||||
}
|
||||
|
||||
bool MyPlugin3::initialize(const QStringList & /*arguments*/, QString *errorString)
|
||||
Result<> MyPlugin3::initialize(const QStringList &)
|
||||
{
|
||||
initializeCalled = true;
|
||||
object1 = new QObject(this);
|
||||
object1->setObjectName(QLatin1String("MyPlugin3"));
|
||||
ExtensionSystem::PluginManager::addObject(object1);
|
||||
|
||||
bool found2 = false;
|
||||
for (QObject *object : ExtensionSystem::PluginManager::allObjects()) {
|
||||
if (object->objectName() == QLatin1String("MyPlugin2"))
|
||||
found2 = true;
|
||||
return ResultOk;
|
||||
}
|
||||
if (found2)
|
||||
return true;
|
||||
if (errorString)
|
||||
*errorString = QLatin1String("object from plugin2 could not be found");
|
||||
return false;
|
||||
return ResultError("object from plugin2 could not be found");
|
||||
}
|
||||
|
||||
void MyPlugin3::extensionsInitialized()
|
||||
|
@@ -24,7 +24,7 @@ public:
|
||||
MyPlugin3() = default;
|
||||
~MyPlugin3() final;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
void extensionsInitialized() final;
|
||||
|
||||
private:
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
using namespace Plugin1;
|
||||
using namespace Utils;
|
||||
|
||||
MyPlugin1::~MyPlugin1()
|
||||
{
|
||||
@@ -13,7 +14,7 @@ MyPlugin1::~MyPlugin1()
|
||||
ExtensionSystem::PluginManager::removeObject(object2);
|
||||
}
|
||||
|
||||
bool MyPlugin1::initialize(const QStringList & /*arguments*/, QString *errorString)
|
||||
Result<> MyPlugin1::initialize(const QStringList &)
|
||||
{
|
||||
initializeCalled = true;
|
||||
object1 = new QObject(this);
|
||||
@@ -28,18 +29,15 @@ bool MyPlugin1::initialize(const QStringList & /*arguments*/, QString *errorStri
|
||||
found2 = true;
|
||||
else if (object->objectName() == "MyPlugin3")
|
||||
found3 = true;
|
||||
}
|
||||
if (found2 && found3)
|
||||
return true;
|
||||
if (errorString) {
|
||||
return ResultOk;
|
||||
}
|
||||
QString error = "object(s) missing from plugin(s):";
|
||||
if (!found2)
|
||||
error.append(" plugin2");
|
||||
if (!found3)
|
||||
error.append(" plugin3");
|
||||
*errorString = error;
|
||||
}
|
||||
return false;
|
||||
return ResultError(error);
|
||||
}
|
||||
|
||||
void MyPlugin1::extensionsInitialized()
|
||||
|
@@ -16,7 +16,7 @@ public:
|
||||
MyPlugin1() = default;
|
||||
~MyPlugin1() final;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
void extensionsInitialized() final;
|
||||
|
||||
private:
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
using namespace Plugin3;
|
||||
using namespace Utils;
|
||||
|
||||
MyPlugin3::~MyPlugin3()
|
||||
{
|
||||
@@ -13,24 +14,19 @@ MyPlugin3::~MyPlugin3()
|
||||
ExtensionSystem::PluginManager::removeObject(object2);
|
||||
}
|
||||
|
||||
bool MyPlugin3::initialize(const QStringList & /*arguments*/, QString *errorString)
|
||||
Result<> MyPlugin3::initialize(const QStringList &)
|
||||
{
|
||||
initializeCalled = true;
|
||||
object1 = new QObject(this);
|
||||
object1->setObjectName("MyPlugin3");
|
||||
ExtensionSystem::PluginManager::addObject(object1);
|
||||
|
||||
bool found2 = false;
|
||||
const QList<QObject *> objects = ExtensionSystem::PluginManager::allObjects();
|
||||
for (QObject *object : objects) {
|
||||
if (object->objectName() == "MyPlugin2")
|
||||
found2 = true;
|
||||
return ResultOk;
|
||||
}
|
||||
if (found2)
|
||||
return true;
|
||||
if (errorString)
|
||||
*errorString = "object from plugin2 could not be found";
|
||||
return false;
|
||||
return ResultError("object from plugin2 could not be found");
|
||||
}
|
||||
|
||||
void MyPlugin3::extensionsInitialized()
|
||||
|
@@ -16,7 +16,7 @@ public:
|
||||
MyPlugin3() = default;
|
||||
~MyPlugin3();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
Utils::Result<> initialize(const QStringList &arguments) final;
|
||||
void extensionsInitialized() final;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user