aboutsummaryrefslogtreecommitdiffstats
path: root/Lua
diff options
context:
space:
mode:
Diffstat (limited to 'Lua')
-rw-r--r--Lua/src/lua/ULuaCore.pas24
1 files changed, 23 insertions, 1 deletions
diff --git a/Lua/src/lua/ULuaCore.pas b/Lua/src/lua/ULuaCore.pas
index c5b3a590..919f54b9 100644
--- a/Lua/src/lua/ULuaCore.pas
+++ b/Lua/src/lua/ULuaCore.pas
@@ -147,6 +147,8 @@ type
function GetEventbyName(Name: String): THookableEvent; //< tries to find the event w/ the given name in the list
function GetEventbyHandle(hEvent: Integer): THookableEvent; //< tries to find the event w/ the given handle
+ procedure UnHookByParent(Parent: Integer); //< remove all hooks by given parent id from all events
+
procedure PrepareState(L: Plua_State);
procedure DumpPlugins; //< prints plugin runtime information w/ Log.LogStatus
@@ -399,7 +401,7 @@ begin
end;
{ tries to find the event w/ the given handle }
-function TLuaCore.GetEventbyHandle(hEvent: Integer): THookableEvent;
+function TLuaCore.GetEventbyHandle(hEvent: Integer): THookableEvent;
begin
If (hEvent >= 0) AND (hEvent <= High(EventHandles)) AND (Length(EventHandles[hEvent]) > 0) then
begin //hEvent in bounds and not already deleted
@@ -409,6 +411,24 @@ begin
Result := nil;
end;
+{ remove all hooks by given parent id from all events }
+procedure TLuaCore.UnHookByParent(Parent: Integer);
+ var
+ Cur: PEventListItem;
+begin
+ if (Parent >= 0) and (Parent <= High(Plugins)) then
+ begin
+ // go through event list
+ Cur := EventList;
+
+ While (Cur <> nil) do
+ begin
+ Cur.Event.UnHookByParent(Parent);
+ Cur := Cur.Next;
+ end;
+ end;
+end;
+
{ prepares the given already opened Lua state with the
basic usdx environment, e.g.: base and package Modules,
usdx moduleloader and usdx table }
@@ -813,6 +833,8 @@ begin
lua_close(State);
State := nil; //don't forget to nil it ;)
+ LuaCore.UnHookByParent(iId);
+
if (sStatus = psRunning) then
sStatus := psClosed;
end;