Skip to content

Commit 9969e09

Browse files
committed
fix: Accidentally removed early exit when UnregisterHook is called from within a pre-callback
1 parent de007bc commit 9969e09

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

UE4SS/src/Mod/LuaMod.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ namespace RC
247247
// Fetch the data corresponding to this UFunction
248248
auto& lua_data = *static_cast<LuaUnrealScriptFunctionData*>(custom_data);
249249

250-
auto remove_if_scheduled = [&] {
250+
// Returns true if a hooks were removed.
251+
auto remove_if_scheduled = [&] -> bool {
251252
if (lua_data.scheduled_for_removal)
252253
{
253254
const auto function_name_no_prefix = get_function_name_without_prefix(lua_data.unreal_function->GetFullName());
@@ -269,12 +270,19 @@ namespace RC
269270
return elem.get() == &lua_data;
270271
});
271272

272-
return;
273+
return true;
274+
}
275+
else
276+
{
277+
return false;
273278
}
274279
};
275280

276281
// Removes pre & post-hook callbacks if UnregisterHook was called in the pre-callback.
277-
remove_if_scheduled();
282+
if (remove_if_scheduled())
283+
{
284+
return;
285+
}
278286

279287
// This is a promise that we're in the game thread, used by other functions to ensure that we don't execute when unsafe
280288
set_is_in_game_thread(lua_data.lua, true);

0 commit comments

Comments
 (0)