From f725baa8f876bf04aef7f423e75777313adc488c Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Mon, 8 Jan 2024 14:31:17 +0100 Subject: Refactor Qt version information retrieval for improved concurrency * Removed unnecessary initialization delays on extension loading. * Ensured thread safety using a semaphore for cache access. * Utilized concurrent dictionary for version information caching. * Cleaned up code for clarity and maintainability. Change-Id: I01f4d8f4b1bd575d28fa3d3f09c46af7f0fe4c32 Reviewed-by: Miguel Costa --- QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs | 12 ++++++------ QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'QtVsTools.Wizards') diff --git a/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs b/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs index 8ece4590..e069dece 100644 --- a/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs +++ b/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs @@ -119,7 +119,7 @@ namespace QtVsTools.Wizards.ProjectWizard private IEnumerable qtVersionList; - readonly QtVersionManager qtVersionManager = QtVersionManager.The(); + readonly QtVersionManager qtVersionManager = QtVersionManager.The; readonly VersionInformation defaultQtVersionInfo; CloneableList defaultConfigs; @@ -147,7 +147,7 @@ namespace QtVsTools.Wizards.ProjectWizard Loaded -= OnLoaded; qtVersionList = new[] { QT_VERSION_DEFAULT, QT_VERSION_BROWSE } - .Union(QtVersionManager.The().GetVersions()); + .Union(QtVersionManager.GetVersions()); if (defaultQtVersionInfo != null) SetupDefaultConfigsAndConfigTable(defaultQtVersionInfo); @@ -343,7 +343,7 @@ namespace QtVsTools.Wizards.ProjectWizard comboBoxQtVersion.Text = config.QtVersionName; break; default: - if (qtVersionManager.GetVersions().Contains(comboBoxQtVersion.Text)) { + if (QtVersionManager.GetVersions().Contains(comboBoxQtVersion.Text)) { config.QtVersion = qtVersionManager.GetVersionInfo(comboBoxQtVersion.Text); config.QtVersionName = comboBoxQtVersion.Text; config.QtVersionPath = qtVersionManager.GetInstallPath(comboBoxQtVersion.Text); @@ -532,15 +532,15 @@ namespace QtVsTools.Wizards.ProjectWizard var versionName = $"{Path.GetFileName(qtVersionDir)}" + $"_{Path.GetFileName(qmakePath)}".Replace(" ", "_"); - qtVersionManager.SaveVersion(versionName, qmakePath); - qtVersionManager.SaveDefaultVersion(versionName); + QtVersionManager.SaveVersion(versionName, qmakePath); + QtVersionManager.SaveDefaultVersion(versionName); versionInfo.name = versionName; } catch (Exception exception) { Messages.Print("Could not save Qt version."); exception.Log(); } - qtVersionList = new[] { QT_VERSION_BROWSE }.Union(QtVersionManager.The().GetVersions()); + qtVersionList = new[] { QT_VERSION_BROWSE }.Union(QtVersionManager.GetVersions()); SetupDefaultConfigsAndConfigTable(versionInfo); diff --git a/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs b/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs index 777893eb..6a6ff696 100644 --- a/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs @@ -183,7 +183,7 @@ namespace QtVsTools.Wizards.ProjectWizard protected TemplateParameters Parameter => Lazy.Get(() => Parameter, () => new TemplateParameters { Template = this }); - protected QtVersionManager VersionManager => QtVersionManager.The(); + protected QtVersionManager VersionManager => QtVersionManager.The; public virtual void ProjectItemFinishedGenerating(ProjectItem projectItem) { } public virtual void BeforeOpeningFile(ProjectItem projectItem) { } -- cgit v1.2.3