From e7d6501553db39fcaef26be4bb78aa8c5179f2bd Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Apr 2023 15:58:03 +0200 Subject: [PATCH] ProjectExplorer: Postpone ToolChainConfigWidget creation ... until they are actually used, i.e. when the respective tool chain is selected in the Toolchain tab. Some of them (QNX) can be expensive to set up. Previously all of were created when the Kits settings page was opened. Change-Id: I80e4238269b9f08788c330e2052c525dcf41d1ba Reviewed-by: Christian Kandeler --- .../projectexplorer/toolchainoptionspage.cpp | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp index b8df603850f..e0717ab7804 100644 --- a/src/plugins/projectexplorer/toolchainoptionspage.cpp +++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp @@ -48,20 +48,8 @@ class ToolChainTreeItem : public TreeItem { public: ToolChainTreeItem(QStackedWidget *parentWidget, ToolChain *tc, bool c) : - toolChain(tc), changed(c) - { - widget = tc->createConfigurationWidget().release(); - if (widget) { - parentWidget->addWidget(widget); - if (tc->isAutoDetected()) - widget->makeReadOnly(); - QObject::connect(widget, &ToolChainConfigWidget::dirty, - [this] { - changed = true; - update(); - }); - } - } + toolChain(tc), changed(c), m_parentWidget(parentWidget) + {} QVariant data(int column, int role) const override { @@ -93,9 +81,30 @@ public: return QVariant(); } + ToolChainConfigWidget *widget() + { + if (!m_widget) { + m_widget = toolChain->createConfigurationWidget().release(); + if (m_widget) { + m_parentWidget->addWidget(m_widget); + if (toolChain->isAutoDetected()) + m_widget->makeReadOnly(); + QObject::connect(m_widget, &ToolChainConfigWidget::dirty, + [this] { + changed = true; + update(); + }); + } + } + return m_widget; + } + ToolChain *toolChain; - ToolChainConfigWidget *widget; bool changed; + +private: + ToolChainConfigWidget *m_widget = nullptr; + QStackedWidget *m_parentWidget = nullptr; }; class DetectionSettingsDialog : public QDialog @@ -423,7 +432,7 @@ void ToolChainOptionsWidget::toolChainSelectionChanged() { ToolChainTreeItem *item = currentTreeItem(); - QWidget *currentTcWidget = item ? item->widget : nullptr; + QWidget *currentTcWidget = item ? item->widget() : nullptr; if (currentTcWidget) m_widgetStack->setCurrentWidget(currentTcWidget); m_container->setVisible(currentTcWidget); @@ -447,8 +456,8 @@ void ToolChainOptionsWidget::apply() for (TreeItem *item : *parent) { auto tcItem = static_cast(item); Q_ASSERT(tcItem->toolChain); - if (!tcItem->toolChain->isAutoDetected() && tcItem->widget && tcItem->changed) - tcItem->widget->apply(); + if (!tcItem->toolChain->isAutoDetected() && tcItem->widget() && tcItem->changed) + tcItem->widget()->apply(); tcItem->changed = false; tcItem->update(); }