From 5399eff2a997f7fabe58a162dc59b080b7c9e988 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 12 Mar 2024 18:19:20 +0100 Subject: [PATCH] BaseQtVersion: Get rid of MacroExpanderWrapper Apparently the reasoning for having it, i.e. make std::unique_ptr "copyable" is not valid anymore. This change also fixes the leak of a MacroExpander returned by QtVersion::createMacroExpander(). Change-Id: I811ecf2eca8e5ce3a1da267da8290ba89df66db6 Reviewed-by: hjk --- src/plugins/qtsupport/baseqtversion.cpp | 29 ++++--------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index cee3f88d8b6..ae0ed49e069 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -249,19 +249,6 @@ static QSet versionedIds(const QVersionNumber &version) version.majorVersion(), version.minorVersion()); } -// Wrapper to make the std::unique_ptr "copyable": -class MacroExpanderWrapper -{ -public: - MacroExpanderWrapper() = default; - MacroExpanderWrapper(const MacroExpanderWrapper &other) { Q_UNUSED(other) } - MacroExpanderWrapper(MacroExpanderWrapper &&other) = default; - - MacroExpander *macroExpander(const QtVersion *qtversion) const; -private: - mutable std::unique_ptr m_expander; -}; - enum HostBinaries { Designer, Linguist, Rcc, Uic, QScxmlc }; class QtVersionPrivate @@ -329,19 +316,9 @@ public: FilePath m_qmlRuntimePath; FilePath m_qmlplugindumpPath; - MacroExpanderWrapper m_expander; + std::unique_ptr m_expander; }; -/////////////// -// MacroExpanderWrapper -/////////////// -MacroExpander *MacroExpanderWrapper::macroExpander(const QtVersion *qtversion) const -{ - if (!m_expander) - m_expander = QtVersion::createMacroExpander([qtversion]() { return qtversion; }); - return m_expander.get(); -} - } // Internal /////////////// @@ -1489,7 +1466,9 @@ FilePaths QtVersion::qtSoPaths() const MacroExpander *QtVersion::macroExpander() const { - return d->m_expander.macroExpander(this); + if (!d->m_expander) + d->m_expander = QtVersion::createMacroExpander([this] { return this; }); + return d->m_expander.get(); } std::unique_ptr