From f5efd9acc09a62a22e53471816d5940a469c9346 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 18 Nov 2022 15:24:26 +0100 Subject: [PATCH] JSON wizards: Don't add paths from environment over and over It would add the paths from the environment variable again, each time the searchPaths are requested Change-Id: I2650ba832e23b5fcd6bfd363389e1eaf3beddb9d Reviewed-by: Christian Stenger Reviewed-by: --- .../jsonwizard/jsonwizardfactory.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 7c169519e48..673e3bea0ae 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -505,10 +505,15 @@ static QStringList environmentTemplatesPaths() FilePaths &JsonWizardFactory::searchPaths() { - static FilePaths m_searchPaths = {Core::ICore::userResourcePath(WIZARD_PATH), - Core::ICore::resourcePath(WIZARD_PATH)}; - for (const QString &environmentTemplateDirName : environmentTemplatesPaths()) - m_searchPaths << FilePath::fromString(environmentTemplateDirName); + static FilePaths m_searchPaths; + static bool searchPathsInitialized = false; + if (!searchPathsInitialized) { + searchPathsInitialized = true; + m_searchPaths = {Core::ICore::userResourcePath(WIZARD_PATH), + Core::ICore::resourcePath(WIZARD_PATH)}; + for (const QString &environmentTemplateDirName : environmentTemplatesPaths()) + m_searchPaths << FilePath::fromString(environmentTemplateDirName); + } return m_searchPaths; }