From 6a0f7d988d8b548385c639ca4e3a277db549d630 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 18 Jul 2012 18:10:25 +0300 Subject: [PATCH] Script: Fixed that GetMeter/GetMeasure/GetVariable functions do not correctly return nil on error --- Library/lua/glue/LuaMeterWindow.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Library/lua/glue/LuaMeterWindow.cpp b/Library/lua/glue/LuaMeterWindow.cpp index 19ea0cb7..0ee1d589 100644 --- a/Library/lua/glue/LuaMeterWindow.cpp +++ b/Library/lua/glue/LuaMeterWindow.cpp @@ -74,10 +74,13 @@ static int GetMeter(lua_State* L) *(CMeter**)lua_newuserdata(L, sizeof(CMeter*)) = meter; lua_getglobal(L, "CMeter"); lua_setmetatable(L, -2); - return 1; + } + else + { + lua_pushnil(L); } - return 0; + return 1; } static int GetMeasure(lua_State* L) @@ -91,10 +94,13 @@ static int GetMeasure(lua_State* L) *(CMeasure**)lua_newuserdata(L, sizeof(CMeasure*)) = measure; lua_getglobal(L, "CMeasure"); lua_setmetatable(L, -2); - return 1; + } + else + { + lua_pushnil(L); } - return 0; + return 1; } static int GetVariable(lua_State* L) @@ -105,10 +111,13 @@ static int GetVariable(lua_State* L) if (self->GetParser().GetVariable(strTmp, strTmp)) { LuaManager::PushWide(L, strTmp.c_str()); - return 1; + } + else + { + lua_pushnil(L); } - return 0; + return 1; } static int ReplaceVariables(lua_State* L)