From 19e47ef0963de65a8f31bad007d5746bcfd65c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sat, 14 Jun 2025 08:19:52 +0200 Subject: [PATCH] editor: remove trailing whitespace from padded app name (#1130) --- Editor/main_SDL2.cpp | 2 +- Editor/main_Windows.cpp | 2 +- WickedEngine/wiHelper.cpp | 11 ++++++++++- WickedEngine/wiHelper.h | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Editor/main_SDL2.cpp b/Editor/main_SDL2.cpp index 6bd2afc5a..380104c89 100644 --- a/Editor/main_SDL2.cpp +++ b/Editor/main_SDL2.cpp @@ -225,7 +225,7 @@ int main(int argc, char *argv[]) height = std::max(100, height); sdl2::window_ptr_t window = sdl2::make_window( - exe_customization.name_256padded, + wi::helper::StringRemoveTrailingWhitespaces(exe_customization.name_256padded).c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); diff --git a/Editor/main_Windows.cpp b/Editor/main_Windows.cpp index e7df61d9c..2bcf507b5 100644 --- a/Editor/main_Windows.cpp +++ b/Editor/main_Windows.cpp @@ -140,7 +140,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = NULL; wchar_t wname[256] = {}; - wi::helper::StringConvert(exe_customization.name_256padded, wname, arraysize(wname)); + wi::helper::StringConvert(wi::helper::StringRemoveTrailingWhitespaces(exe_customization.name_256padded).c_str(), wname, arraysize(wname)); wcex.lpszClassName = wname; RegisterClassExW(&wcex); diff --git a/WickedEngine/wiHelper.cpp b/WickedEngine/wiHelper.cpp index e38ac3dba..51d4a5d5a 100644 --- a/WickedEngine/wiHelper.cpp +++ b/WickedEngine/wiHelper.cpp @@ -1753,7 +1753,16 @@ namespace wi::helper return written; } - + + std::string StringRemoveTrailingWhitespaces(const std::string& str) + { + size_t found; + found = str.find_last_not_of(" /t"); + if (found == std::string::npos) + return str; + return str.substr(0, found + 1); + } + void DebugOut(const std::string& str, DebugLevel level) { #ifdef _WIN32 diff --git a/WickedEngine/wiHelper.h b/WickedEngine/wiHelper.h index 5633993ee..3f42058dd 100644 --- a/WickedEngine/wiHelper.h +++ b/WickedEngine/wiHelper.h @@ -162,6 +162,8 @@ namespace wi::helper // returns result string length int StringConvert(const wchar_t* from, char* to, int dest_size_in_characters); + std::string StringRemoveTrailingWhitespaces(const std::string& str); + // Prints debug info to the console output enum class DebugLevel {