From dd1e991602ac3558b6dbab03073523eac3f556de Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 3 Oct 2014 13:16:16 +0300 Subject: [PATCH] extensions/urho3d: Fix UnsubscribeFromEvent() so that uistack's SubscribeToStackEvent() works like it should --- doc/todo.txt | 1 - extensions/urho3d/init.lua | 22 +++------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/doc/todo.txt b/doc/todo.txt index 46ff6a7..a4a3dc9 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -24,7 +24,6 @@ Buildat TODO - Normal block size should be definable to be a multiple of the voxel size - "Continuation voxels" - Support Cereal's shared pointer serialization in Lua -- Something in uistack's global nil focus handling has broken - Automatically fetch and build and patch Urho3D when building buildat - Handle module load order properly in reloads (unload by popping from top, then reload everything until top) diff --git a/extensions/urho3d/init.lua b/extensions/urho3d/init.lua index a825a74..324dfdc 100644 --- a/extensions/urho3d/init.lua +++ b/extensions/urho3d/init.lua @@ -216,7 +216,7 @@ function Safe.SubscribeToEvent(x, y, z) local object = x local sub_event_type = y local callback = z - if callback == nil then + if z == nil then object = nil sub_event_type = x callback = y @@ -291,24 +291,8 @@ function Safe.SubscribeToEvent(x, y, z) return global_callback_name end -function Safe.UnsubscribeFromEvent(x, y) - local object = x - local sub_event_type = y - if callback == nil then - object = nil - sub_event_type = x - end - if object then - if not getmetatable(object) or not getmetatable(object).unsafe then - error("SubscribeToEvent(): Object must be sandboxed") - end - end - if object then - local unsafe_object = getmetatable(object).unsafe - UnsubscribeFromEvent(unsafe_object, sub_event_type) - else - UnsubscribeFromEvent(sub_event_type) - end +function Safe.UnsubscribeFromEvent(sub_event_type, cb_name) + UnsubscribeFromEvent(sub_event_type, cb_name) -- TODO: Delete the generated global callback end