[vlc-commits] Fix host destructor call.
Antoine Cellerier
git at videolan.org
Sat Feb 11 12:50:37 CET 2012
vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sat Feb 11 12:22:24 2012 +0100| [2d20c3d3069a7c21b7dbaba17742768d2e7dd4e2] | committer: Antoine Cellerier
Fix host destructor call.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d20c3d3069a7c21b7dbaba17742768d2e7dd4e2
---
share/lua/intf/modules/host.lua | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/share/lua/intf/modules/host.lua b/share/lua/intf/modules/host.lua
index aeadc02..6b31037 100644
--- a/share/lua/intf/modules/host.lua
+++ b/share/lua/intf/modules/host.lua
@@ -319,7 +319,7 @@ function host()
local function destructor( h )
for _,client in pairs(clients) do
- client:send("Shutting down.")
+ --client:send("Cleaning up.")
if client.type == client_type.net
or client.type == client_type.telnet then
if client.wfd ~= client.rfd then
@@ -336,6 +336,14 @@ function host()
end
end
+ if setfenv then
+ -- We're running Lua 5.1
+ -- See http://lua-users.org/wiki/HiddenFeatures for more info.
+ local proxy = newproxy(true)
+ getmetatable(proxy).__gc = destructor
+ destructor = proxy
+ end
+
-- the instance
local h = setmetatable(
{ -- data
@@ -348,7 +356,7 @@ function host()
broadcast = _broadcast,
},
{ -- metatable
- __gc = destructor,
+ __gc = destructor, -- Should work in Lua 5.2 without the new proxytrick as __gc is also called on tables (needs to be tested)
__metatable = "",
})
return h
More information about the vlc-commits
mailing list