From 1b993e40e34ffbfe55912cfccee8cc7fecdcc604 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 10 Apr 2018 12:28:18 +0200 Subject: [PATCH] Core: Avoid duplicating options page Creating an IOptionPage registers it automatically. In case an IOptionsProvider is used this duplicates the the option pages and although duplicated still adds them to the respective category again. If one clicks on the respective tab this results in a crash. Slipped in with cc883023090030eb341a11c4d6634ca027f02c65. Change-Id: Ie881f532c3f0e397147d99ce368066cdce01a612 Reviewed-by: hjk --- src/plugins/coreplugin/dialogs/ioptionspage.cpp | 11 ++++++----- src/plugins/coreplugin/dialogs/ioptionspage.h | 4 ++-- src/plugins/designer/settingspage.cpp | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.cpp b/src/plugins/coreplugin/dialogs/ioptionspage.cpp index 49d72dc1d93..6a336a55501 100644 --- a/src/plugins/coreplugin/dialogs/ioptionspage.cpp +++ b/src/plugins/coreplugin/dialogs/ioptionspage.cpp @@ -138,13 +138,14 @@ QIcon Core::IOptionsPage::categoryIcon() const static QList g_optionsPages; /*! - Constructs an options page with the given \a parent. + Constructs an options page with the given \a parent and registers it + at the global options page pool if \a registerGlobally is true. */ -Core::IOptionsPage::IOptionsPage(QObject *parent) - : QObject(parent), - m_keywordsInitialized(false) +Core::IOptionsPage::IOptionsPage(QObject *parent, bool registerGlobally) + : QObject(parent) { - g_optionsPages.append(this); + if (registerGlobally) + g_optionsPages.append(this); } /*! diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.h b/src/plugins/coreplugin/dialogs/ioptionspage.h index 16e6d285c04..7f55c25c884 100644 --- a/src/plugins/coreplugin/dialogs/ioptionspage.h +++ b/src/plugins/coreplugin/dialogs/ioptionspage.h @@ -44,7 +44,7 @@ class CORE_EXPORT IOptionsPage : public QObject Q_OBJECT public: - IOptionsPage(QObject *parent = 0); + IOptionsPage(QObject *parent = nullptr, bool registerGlobally = true); virtual ~IOptionsPage(); static const QList allOptionsPages(); @@ -73,7 +73,7 @@ protected: QString m_displayCategory; Utils::Icon m_categoryIcon; - mutable bool m_keywordsInitialized; + mutable bool m_keywordsInitialized = false; mutable QStringList m_keywords; }; diff --git a/src/plugins/designer/settingspage.cpp b/src/plugins/designer/settingspage.cpp index 488ee8ea5e2..8e865cae8a3 100644 --- a/src/plugins/designer/settingspage.cpp +++ b/src/plugins/designer/settingspage.cpp @@ -37,6 +37,7 @@ using namespace Designer::Internal; SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) : + Core::IOptionsPage(nullptr, false), m_designerPage(designerPage) { setId(Core::Id::fromString(m_designerPage->name()));