Disable plugin project config if project without a IBuildSystemManager dep

The Clazy plugin relies on the project providing a buildsystem manager
to query for the toplevel build directory. If a project has no such manager,
showing the Clazy plugin config pages in the project settings has no
As a session might contain different projects, some with a buildsystem
manager, some without, simply disabling the Clazy plugin might not be
wanted for the projects with a buildsystem manager.
So we need to have some condition whether to show some plugins per-project
config pages or not.
For a start, motivated by the crash with the Clazy plugin which has a
hard assumption of project->buildSystemManager() being != nullptr,
this patch adds to the code to collect the config pages for the project
settings dialog some special code which makes use of the plugin metadata
to skip plugins which require a org.kdevelop.IBuildSystemManager, if
there is no buildsystem manager available for the project.
As well adds the (so far missing) entry
X-KDevelop-IRequired: [org.kdevelop.IBuildSystemManager]
to the metadata.

BUG: 400769

Test Plan:
Clazy config is no longer shown in the project settings dialog if the
project is used with the generic project manager.

Reviewers: #kdevelop, apol

Reviewed By: #kdevelop, apol

Subscribers: kfunk, kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D16915
parent 7b9572d3
......@@ -206,12 +206,13 @@ public:
QVector<IPlugin*> findPluginsForProject( IProject* project ) const
const QList<IPlugin*> plugins = m_core->pluginController()->loadedPlugins();
const IBuildSystemManager* const buildSystemManager = project->buildSystemManager();
QVector<IPlugin*> projectPlugins;
QList<IProjectBuilder*> buildersForKcm;
// Important to also include the "top" builder for the project, so
// projects with only one such builder are kept working. Otherwise the project config
// dialog is empty for such cases.
if( IBuildSystemManager* buildSystemManager = project->buildSystemManager() ) {
if (buildSystemManager) {
buildersForKcm << buildSystemManager->builder();
collectBuilders( buildersForKcm, buildSystemManager->builder(), project );
......@@ -229,6 +230,15 @@ public:
// Do not show config pages for analyzer tools which need a buildSystemManager
// TODO: turn into generic feature to disable plugin config pages which do not apply for a project
if (!buildSystemManager) {
const auto required = KPluginMetaData::readStringList(info.rawData(), QStringLiteral("X-KDevelop-IRequired"));
if (required.contains(QLatin1String("org.kdevelop.IBuildSystemManager"))) {
qCDebug(SHELL) << "Using plugin" << info.pluginId() << "for project" << project->name();
projectPlugins << plugin;
......@@ -73,5 +73,8 @@
"X-KDevelop-Category": "Global",
"X-KDevelop-IRequired": [
"X-KDevelop-Mode": "GUI"
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