[Orxonox-commit 3282] r7973 - code/branches/kicklib/src/libraries/core
rgrieder at orxonox.net
rgrieder at orxonox.net
Sat Feb 26 21:13:00 CET 2011
Author: rgrieder
Date: 2011-02-26 21:12:59 +0100 (Sat, 26 Feb 2011)
New Revision: 7973
Modified:
code/branches/kicklib/src/libraries/core/GUIManager.cc
Log:
Fix for "error in error handling" when a Lua error occurs.
Untested and does not seem to be required by MSVC or Windows systems, so I cannot test. Please do so.
Modified: code/branches/kicklib/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/kicklib/src/libraries/core/GUIManager.cc 2011-02-26 19:50:06 UTC (rev 7972)
+++ code/branches/kicklib/src/libraries/core/GUIManager.cc 2011-02-26 20:12:59 UTC (rev 7973)
@@ -48,6 +48,9 @@
#ifdef ORXONOX_OLD_CEGUI
# include <CEGUILua.h>
# include <ogreceguirenderer/OgreCEGUIRenderer.h>
+extern "C" {
+# include <lauxlib.h>
+}
#else
# include <ScriptingModules/LuaScriptModule/CEGUILua.h>
# include <RendererModules/Ogre/CEGUIOgreImageCodec.h>
@@ -101,6 +104,28 @@
}
};
+#ifdef ORXONOX_OLD_CEGUI
+ /** Class with the same memory layout as CEGUI::LuaScriptModule. <br>
+ We need this to fix a problem with an uninitialised member variable
+ in CEGUI < 0.7 <br>
+ Notice that "public" modifier for the otherwise private variables.
+ */
+ class CEGUILUA_API LuaScriptModuleWorkaround : public CEGUI::ScriptModule
+ {
+ public:
+ LuaScriptModuleWorkaround();
+ ~LuaScriptModuleWorkaround();
+
+ public:
+ bool d_ownsState;
+ lua_State* d_state;
+ CEGUI::String d_errFuncName;
+ int d_errFuncIndex;
+ CEGUI::String d_activeErrFuncName;
+ int d_activeErrFuncIndex;
+ };
+#endif
+
static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
GUIManager* GUIManager::singletonPtr_s = 0;
@@ -156,6 +181,11 @@
luaState_->setDefaultResourceInfo(this->rootFileInfo_);
#ifdef ORXONOX_OLD_CEGUI
scriptModule_ = new LuaScriptModule(luaState_->getInternalLuaState());
+ // Ugly workaround: older CEGUILua versions don't initialise the member
+ // d_activeErrFuncIndex at all. That leads to "error in error handling"
+ // problems when a Lua error occurs.
+ // We fix this by setting the member manually.
+ reinterpret_cast<LuaScriptModuleWorkaround*>(scriptModule_)->d_activeErrFuncIndex = LUA_NOREF;
luaState_->doString("ORXONOX_OLD_CEGUI = true");
#else
scriptModule_ = &LuaScriptModule::create(luaState_->getInternalLuaState());
More information about the Orxonox-commit
mailing list