Do not crash if a non-existing kernel file is loaded through the Lua interface (closing #279)

This commit is contained in:
Alexander Bock
2017-04-06 23:27:41 -04:00
parent 9f3bbe324d
commit 7f2aa891d1
3 changed files with 16 additions and 2 deletions

View File

@@ -497,6 +497,11 @@ void InteractionHandler::writeKeyboardDocumentation(const std::string& type,
}
}
std::string generationTime;
try {
generationTime = Time::now().ISO8601();
}
catch (...) {}
std::stringstream html;
html << "<!DOCTYPE html>\n"
@@ -511,7 +516,7 @@ void InteractionHandler::writeKeyboardDocumentation(const std::string& type,
<< "\t<script>\n"
<< "var keybindings = JSON.parse('" << jsonString << "');\n"
<< "var version = [" << OPENSPACE_VERSION_MAJOR << ", " << OPENSPACE_VERSION_MINOR << ", " << OPENSPACE_VERSION_PATCH << "];\n"
<< "var generationTime = '" << Time::now().ISO8601() << "';\n"
<< "var generationTime = '" << generationTime << "';\n"
<< jsContent << "\n"
<< "\t</script>\n"
<< "\t<style type=\"text/css\">\n"

View File

@@ -400,6 +400,12 @@ void Scene::writePropertyDocumentation(const std::string& filename, const std::s
}
}
std::string generationTime;
try {
generationTime = Time::now().ISO8601();
}
catch (...) {}
std::stringstream html;
html << "<!DOCTYPE html>\n"
<< "<html>\n"
@@ -417,7 +423,7 @@ void Scene::writePropertyDocumentation(const std::string& filename, const std::s
<< "var propertyOwners = JSON.parse('" << jsonString << "');\n"
<< "var version = [" << OPENSPACE_VERSION_MAJOR << ", " << OPENSPACE_VERSION_MINOR << ", " << OPENSPACE_VERSION_PATCH << "];\n"
<< "var sceneFilename = '" << sceneFilename << "';\n"
<< "var generationTime = '" << Time::now().ISO8601() << "';\n"
<< "var generationTime = '" << generationTime << "';\n"
<< jsContent << "\n"
<< "\t</script>\n"
<< "\t<style type=\"text/css\">\n"

View File

@@ -45,6 +45,9 @@ int loadKernel(lua_State* L) {
}
std::string argument = lua_tostring(L, -1);
if (!FileSys.fileExists(argument)) {
return luaL_error(L, "Kernel file '%s' did not exist", argument.c_str());
}
unsigned int result = SpiceManager::ref().loadKernel(argument);
lua_pushnumber(L, result);