From 3622f364e05c2338413bc09a91385531a8655e63 Mon Sep 17 00:00:00 2001 From: Christophe Date: Tue, 1 Oct 2024 12:55:59 +0200 Subject: [PATCH] vkconfig2: SDK 296 bugfixing - Fix renaming configuration with the same name but different cases - Fix launch button saying Tarminate instead of launch --- vkconfig/CHANGELOG.md | 1 + vkconfig/mainwindow.cpp | 1 - vkconfig_core/util.h | 66 +++++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/vkconfig/CHANGELOG.md b/vkconfig/CHANGELOG.md index d74d6b5cdd..dafd5b5365 100644 --- a/vkconfig/CHANGELOG.md +++ b/vkconfig/CHANGELOG.md @@ -20,6 +20,7 @@ - Fix flag settings dependencies - Fix filesystem settings update - Fix overridden implicit layer ordering +- Fix renaming configuration with the same name but different cases ## [Vulkan Configurator 2.6.1](https://github.com/LunarG/VulkanTools/tree/vulkan-sdk-1.3.290.0) - July 2024 diff --git a/vkconfig/mainwindow.cpp b/vkconfig/mainwindow.cpp index a0239a1d66..89d4167a65 100644 --- a/vkconfig/mainwindow.cpp +++ b/vkconfig/mainwindow.cpp @@ -416,7 +416,6 @@ void MainWindow::UpdateUI() { // Launcher states const bool has_application_list = !environment.GetApplications().empty(); ui->push_button_launcher->setEnabled(has_application_list); - ui->push_button_launcher->setText(_launch_application ? "Terminate" : "Launch"); ui->check_box_clear_on_launch->setChecked(environment.Get(LAYOUT_LAUNCHER_NOT_CLEAR) != "true"); ui->launcher_loader_debug->blockSignals(true); // avoid calling again UpdateUI ui->launcher_loader_debug->setCurrentIndex(GetLoaderMessageType(environment.GetLoaderMessageTypes())); diff --git a/vkconfig_core/util.h b/vkconfig_core/util.h index e5e4feb773..75eb60eb70 100644 --- a/vkconfig_core/util.h +++ b/vkconfig_core/util.h @@ -60,35 +60,6 @@ bool IsNumber(const std::string& s); bool IsFloat(const std::string& s); -template -T* FindByKey(std::vector& container, const char* key) { - assert(key != nullptr); - assert(std::strcmp(key, "") != 0); - - for (std::size_t i = 0, n = container.size(); i < n; ++i) { - if (container[i].key == key) return &container[i]; - } - - return nullptr; -} - -template -const T* FindByKey(const std::vector& container, const char* key) { - assert(key != nullptr); - assert(std::strcmp(key, "") != 0); - - for (std::size_t i = 0, n = container.size(); i < n; ++i) { - if (container[i].key == key) return &container[i]; - } - - return nullptr; -} - -template -bool IsFound(const std::vector& container, const char* key) { - return FindByKey(container, key) != nullptr; -} - // Remove a value if it's present void RemoveString(std::vector& list, const std::string& value); @@ -167,3 +138,40 @@ bool IsValueFound(const std::vector& list, const NumberOr QStringList ConvertValues(const std::vector& values); std::string GetLayerSettingPrefix(const std::string& key); + +template +T* FindByKey(std::vector& container, const char* key) { + assert(key != nullptr); + assert(std::strcmp(key, "") != 0); + + const std::string low_key = ToLowerCase(std::string(key)); + + for (std::size_t i = 0, n = container.size(); i < n; ++i) { + if (ToLowerCase(container[i].key) == low_key) { + return &container[i]; + } + } + + return nullptr; +} + +template +const T* FindByKey(const std::vector& container, const char* key) { + assert(key != nullptr); + assert(std::strcmp(key, "") != 0); + + const std::string low_key = ToLowerCase(std::string(key)); + + for (std::size_t i = 0, n = container.size(); i < n; ++i) { + if (ToLowerCase(container[i].key) == low_key) { + return &container[i]; + } + } + + return nullptr; +} + +template +bool IsFound(const std::vector& container, const char* key) { + return FindByKey(container, key) != nullptr; +}