From f8937daf717597f696a5ba3963e02878b01ab4ae Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 24 Apr 2018 15:07:02 +0200 Subject: [PATCH] ProjectExplorer: Make "Manage..." kits button work again When configuring a newly opened or created project you are able to press a 'Manage...' button that brings up the options page of the kits. Was broken with the rework done on the global object pool. Change-Id: I87d91351c5769655c1192431a53784de1bca77aa Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/kitoptionspage.cpp | 8 ++++++++ src/plugins/projectexplorer/kitoptionspage.h | 1 + src/plugins/projectexplorer/projectwindow.cpp | 6 ++---- src/plugins/projectexplorer/targetsetupwidget.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/kitoptionspage.cpp b/src/plugins/projectexplorer/kitoptionspage.cpp index 6155f29c0bb..f37687c5866 100644 --- a/src/plugins/projectexplorer/kitoptionspage.cpp +++ b/src/plugins/projectexplorer/kitoptionspage.cpp @@ -235,8 +235,11 @@ QModelIndex KitOptionsPageWidget::currentIndex() const // KitOptionsPage: // -------------------------------------------------------------------------- +static KitOptionsPage *theKitOptionsPage = nullptr; + KitOptionsPage::KitOptionsPage() { + theKitOptionsPage = this; static const Utils::Icon categoryIcon({{":/projectexplorer/images/mode_project_mask.png", Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint); @@ -283,4 +286,9 @@ void KitOptionsPage::showKit(Kit *k) m_widget->m_kitsView->scrollTo(index); } +KitOptionsPage *KitOptionsPage::instance() +{ + return theKitOptionsPage; +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitoptionspage.h b/src/plugins/projectexplorer/kitoptionspage.h index b9d484e9d0f..7e7f02b363a 100644 --- a/src/plugins/projectexplorer/kitoptionspage.h +++ b/src/plugins/projectexplorer/kitoptionspage.h @@ -53,6 +53,7 @@ public: void finish() override; void showKit(Kit *k); + static KitOptionsPage *instance(); private: QPointer m_widget; diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 41659d3eeb7..51e17e5610d 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -42,8 +42,6 @@ #include #include -#include - #include #include #include @@ -531,8 +529,8 @@ public: void handleManageKits() { if (ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0)) { - if (KitOptionsPage *page = ExtensionSystem::PluginManager::getObject()) - page->showKit(KitManager::kit(Id::fromSetting(projectItem->data(0, KitIdRole)))); + if (auto kitPage = KitOptionsPage::instance()) + kitPage->showKit(KitManager::kit(Id::fromSetting(projectItem->data(0, KitIdRole)))); } ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, ICore::mainWindow()); } diff --git a/src/plugins/projectexplorer/targetsetupwidget.cpp b/src/plugins/projectexplorer/targetsetupwidget.cpp index 258809f7125..b59f3dbb565 100644 --- a/src/plugins/projectexplorer/targetsetupwidget.cpp +++ b/src/plugins/projectexplorer/targetsetupwidget.cpp @@ -34,7 +34,6 @@ #include "kitoptionspage.h" #include -#include #include #include @@ -201,12 +200,13 @@ void TargetSetupWidget::targetCheckBoxToggled(bool b) void TargetSetupWidget::manageKit() { - KitOptionsPage *page = ExtensionSystem::PluginManager::getObject(); - if (!page || !m_kit) + if (!m_kit) return; - page->showKit(m_kit); - Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, parentWidget()); + if (auto kitPage = KitOptionsPage::instance()) { + kitPage->showKit(m_kit); + Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, parentWidget()); + } } void TargetSetupWidget::setProjectPath(const QString &projectPath)