mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Fixed bug where ScriptEngine would complain about double-added libraries
Correct application of default keybinding
This commit is contained in:
@@ -85,7 +85,7 @@ private:
|
||||
bool registerLuaLibrary(lua_State* state, const LuaLibrary& library);
|
||||
void addLibraryFunctions(lua_State* state, const LuaLibrary& library, bool replace);
|
||||
|
||||
bool isLibraryNameAllowed(const std::string& name);
|
||||
bool isLibraryNameAllowed(lua_State* state, const std::string& name);
|
||||
|
||||
void addBaseLibrary();
|
||||
void remapPrintFunction();
|
||||
|
||||
@@ -10,7 +10,7 @@ openspace.time.setTime("2007 FEB 27 16:40:00") -- This is the start tim
|
||||
|
||||
openspace.time.setDeltaTime(10) -- How many seconds pass per second of realtime, changeable in the GUI
|
||||
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))() -- Load the default keybindings
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) -- Load the default keybindings
|
||||
|
||||
-- openspace.time.setDeltaTime(50);
|
||||
|
||||
|
||||
@@ -324,17 +324,16 @@ bool ScriptEngine::hasLibrary(const std::string& name)
|
||||
//return false;
|
||||
}
|
||||
|
||||
bool ScriptEngine::isLibraryNameAllowed(const std::string& name)
|
||||
{
|
||||
bool ScriptEngine::isLibraryNameAllowed(lua_State* state, const std::string& name) {
|
||||
bool result = false;
|
||||
lua_getglobal(_state, _openspaceLibraryName.c_str());
|
||||
const bool hasOpenSpaceLibrary = lua_istable(_state, -1);
|
||||
lua_getglobal(state, _openspaceLibraryName.c_str());
|
||||
const bool hasOpenSpaceLibrary = lua_istable(state, -1);
|
||||
if (!hasOpenSpaceLibrary) {
|
||||
LFATAL("OpenSpace library was not created in initialize method");
|
||||
return false;
|
||||
}
|
||||
lua_getfield(_state, -1, name.c_str());
|
||||
const int type = lua_type(_state, -1);
|
||||
lua_getfield(state, -1, name.c_str());
|
||||
const int type = lua_type(state, -1);
|
||||
switch (type) {
|
||||
case LUA_TNONE:
|
||||
case LUA_TNIL:
|
||||
@@ -370,7 +369,7 @@ bool ScriptEngine::isLibraryNameAllowed(const std::string& name)
|
||||
break;
|
||||
}
|
||||
|
||||
lua_pop(_state, 2);
|
||||
lua_pop(state, 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -496,7 +495,7 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& librar
|
||||
//ghoul::lua::logStack(_state);
|
||||
}
|
||||
else {
|
||||
const bool allowed = isLibraryNameAllowed(library.name);
|
||||
const bool allowed = isLibraryNameAllowed(state, library.name);
|
||||
if (!allowed)
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user