From 9738fd435437ef6a63fb63ef6e6b02fce943e060 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 16 Nov 2023 14:09:05 +0100 Subject: [PATCH] Fix crash on hot-reload in Editor due to leftover scripting events in `ScriptingEvents::EventsTable` #1925 --- Source/Engine/Scripting/BinaryModule.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Engine/Scripting/BinaryModule.cpp b/Source/Engine/Scripting/BinaryModule.cpp index 5bbaf8d0b..e9465096f 100644 --- a/Source/Engine/Scripting/BinaryModule.cpp +++ b/Source/Engine/Scripting/BinaryModule.cpp @@ -693,6 +693,14 @@ void BinaryModule::Destroy(bool isReloading) } } + // Remove any scripting events + for (auto i = ScriptingEvents::EventsTable.Begin(); i.IsNotEnd(); ++i) + { + const ScriptingTypeHandle type = i->Key.First; + if (type.Module == this) + ScriptingEvents::EventsTable.Remove(i); + } + // Unregister GetModules().RemoveKeepOrder(this); }