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