diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index bd96bfa242..ded1637012 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -84,6 +84,8 @@ #include "midi++/port.h" #include "midi++/mmc.h" +#include "LuaBridge/LuaBridge.h" + #include "ardour/analyser.h" #include "ardour/audio_library.h" #include "ardour/audio_backend.h" @@ -423,6 +425,12 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir return true; } +#ifndef NDEBUG + if (getenv("LUA_METATABLES")) { + luabridge::Security::setHideMetatables (false); + } +#endif + if (!PBD::init()) return false; #ifdef ENABLE_NLS diff --git a/libs/lua/LuaBridge/detail/Namespace.h b/libs/lua/LuaBridge/detail/Namespace.h index a8e190da43..5ea139ee22 100644 --- a/libs/lua/LuaBridge/detail/Namespace.h +++ b/libs/lua/LuaBridge/detail/Namespace.h @@ -363,7 +363,7 @@ private: if (Security::hideMetatables ()) { - lua_pushnil (L); + lua_pushboolean (L, false); rawsetfield (L, -2, "__metatable"); } } @@ -400,7 +400,7 @@ private: if (Security::hideMetatables ()) { - lua_pushnil (L); + lua_pushboolean (L, false); rawsetfield (L, -2, "__metatable"); } } @@ -442,7 +442,7 @@ private: if (Security::hideMetatables ()) { - lua_pushnil (L); + lua_pushboolean (L, false); rawsetfield (L, -2, "__metatable"); } } @@ -1161,8 +1161,14 @@ private: lua_setfield(L, -2, "__index"); lua_pushcclosure (L, CFunc::array_newindex, 0); lua_setfield(L, -2, "__newindex"); + if (Security::hideMetatables ()) + { + lua_pushboolean (L, false); + rawsetfield (L, -2, "__metatable"); + } lua_pop (L, 1); + createConstTable (name); lua_pushcfunction (L, &CFunc::gcMetaMethod ); rawsetfield (L, -2, "__gc"); @@ -1532,6 +1538,12 @@ private: lua_pushcfunction (L, &tostringMetaMethod); rawsetfield (L, -2, "__tostring"); #endif + if (Security::hideMetatables ()) + { + lua_pushboolean (L, false); + rawsetfield (L, -2, "__metatable"); + } + } }