diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-03-02 15:44:50 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-03-05 11:35:45 +0000 |
commit | 779095a587bbf389f34fdd569c7c17781971d407 (patch) | |
tree | e18c87bb62a7d89c68d5134554b555b1433c7918 /src/plugins/qtsupport/qtkitinformation.cpp | |
parent | 5f682095415d1918c115e0d3937ddf38f24f1baa (diff) |
Fix crash in kit's variable chooser if Qt version is removed
Currently the variable chooser cannot update itself if a sub-expander
changes or even is deleted, leading to inconsistencies and crashes if
that happens.
Make the Qt version sub-macroexpander be available for the kit even if
currently is no Qt version selected. For this we create a macro expander
that delegates to the kit's Qt version if possible at variable
substitution time, instead of taking the Qt version's expander directly.
Task-number: QTCREATORBUG-19900
Task-number: QTCREATORBUG-19901
Change-Id: I2bd9b3db60bf6e292abf2a29e0697dc5385709cd
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/qtsupport/qtkitinformation.cpp')
-rw-r--r-- | src/plugins/qtsupport/qtkitinformation.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/qtsupport/qtkitinformation.cpp b/src/plugins/qtsupport/qtkitinformation.cpp index 1653b48a16d..3e55fb3fd04 100644 --- a/src/plugins/qtsupport/qtkitinformation.cpp +++ b/src/plugins/qtsupport/qtkitinformation.cpp @@ -124,14 +124,26 @@ ProjectExplorer::IOutputParser *QtKitInformation::createOutputParser(const Proje return nullptr; } +class QtMacroSubProvider +{ +public: + QtMacroSubProvider(Kit *kit) + : expander(BaseQtVersion::createMacroExpander( + [kit] { return QtKitInformation::qtVersion(kit); })) + {} + + MacroExpander *operator()() const + { + return expander.get(); + } + + std::shared_ptr<MacroExpander> expander; +}; + void QtKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const { QTC_ASSERT(kit, return); - expander->registerSubProvider( - [kit]() -> MacroExpander * { - BaseQtVersion *version = qtVersion(kit); - return version ? version->macroExpander() : nullptr; - }); + expander->registerSubProvider(QtMacroSubProvider(kit)); expander->registerVariable("Qt:Name", tr("Name of Qt Version"), [kit]() -> QString { |