From 449e988a59fcb31ed6d8990b72bc9112629e30b4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 20 Oct 2024 23:25:38 +0200 Subject: [PATCH] Add workaround for debug command text memory bug due to managed handles gc --- Source/Engine/Debug/DebugCommands.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Engine/Debug/DebugCommands.cpp b/Source/Engine/Debug/DebugCommands.cpp index 8ea17f177..4702971d2 100644 --- a/Source/Engine/Debug/DebugCommands.cpp +++ b/Source/Engine/Debug/DebugCommands.cpp @@ -242,6 +242,10 @@ DebugCommandsService DebugCommandsServiceInstance; void DebugCommands::Execute(StringView command) { + // TODO: fix missing string handle on 1st command execution (command gets invalid after InitCommands due to dotnet GC or dotnet interop handles flush) + String commandCopy = command; + command = commandCopy; + // Preprocess command text while (command.HasChars() && StringUtils::IsWhitespace(command[0])) command = StringView(command.Get() + 1, command.Length() - 1); @@ -281,6 +285,9 @@ void DebugCommands::Search(StringView searchText, Array& matches, bo { if (searchText.IsEmpty()) return; + // TODO: fix missing string handle on 1st command execution (command gets invalid after InitCommands due to dotnet GC or dotnet interop handles flush) + String searchTextCopy = searchText; + searchText = searchTextCopy; ScopeLock lock(Locker); if (!Inited)