aboutsummaryrefslogtreecommitdiffstats
path: root/Lua/src
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-05-04 12:50:21 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-05-04 12:50:21 +0000
commit3dc85900d3b6f2bdd269229683452702c3d37cae (patch)
tree5d9b345f4660684852e767a1ab54fc5e04853e69 /Lua/src
parent0d68e084b810972ab0bc47d726b21bc886a235fe (diff)
downloadusdx-3dc85900d3b6f2bdd269229683452702c3d37cae.tar.gz
usdx-3dc85900d3b6f2bdd269229683452702c3d37cae.tar.xz
usdx-3dc85900d3b6f2bdd269229683452702c3d37cae.zip
automaticaly remove hooks from unloaded plugins
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1712 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Lua/src')
-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;