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 cc88302309.

Change-Id: Ie881f532c3f0e397147d99ce368066cdce01a612
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2018-04-10 12:28:18 +02:00
parent a2c362af31
commit 1b993e40e3
3 changed files with 9 additions and 7 deletions

View File

@@ -138,13 +138,14 @@ QIcon Core::IOptionsPage::categoryIcon() const
static QList<Core::IOptionsPage *> g_optionsPages; static QList<Core::IOptionsPage *> 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) Core::IOptionsPage::IOptionsPage(QObject *parent, bool registerGlobally)
: QObject(parent), : QObject(parent)
m_keywordsInitialized(false)
{ {
g_optionsPages.append(this); if (registerGlobally)
g_optionsPages.append(this);
} }
/*! /*!

View File

@@ -44,7 +44,7 @@ class CORE_EXPORT IOptionsPage : public QObject
Q_OBJECT Q_OBJECT
public: public:
IOptionsPage(QObject *parent = 0); IOptionsPage(QObject *parent = nullptr, bool registerGlobally = true);
virtual ~IOptionsPage(); virtual ~IOptionsPage();
static const QList<IOptionsPage *> allOptionsPages(); static const QList<IOptionsPage *> allOptionsPages();
@@ -73,7 +73,7 @@ protected:
QString m_displayCategory; QString m_displayCategory;
Utils::Icon m_categoryIcon; Utils::Icon m_categoryIcon;
mutable bool m_keywordsInitialized; mutable bool m_keywordsInitialized = false;
mutable QStringList m_keywords; mutable QStringList m_keywords;
}; };

View File

@@ -37,6 +37,7 @@
using namespace Designer::Internal; using namespace Designer::Internal;
SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) : SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) :
Core::IOptionsPage(nullptr, false),
m_designerPage(designerPage) m_designerPage(designerPage)
{ {
setId(Core::Id::fromString(m_designerPage->name())); setId(Core::Id::fromString(m_designerPage->name()));