diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index f0cc00ece2..0ff4b1d46d 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -35,6 +35,7 @@ sgct::Engine* _sgctEngine; +int main_main(int argc, char** argv); void mainInitFunc(); void mainPreSyncFunc(); void mainPostSyncPreDrawFunc(); @@ -82,6 +83,30 @@ namespace { } int main(int argc, char** argv) { + try { + return main_main(argc, argv); + } + catch (const ghoul::RuntimeError& e) { + // Write out all of the information about the exception, flush the logs, and throw + LFATALC(e.component, e.message); + LogMgr.flushLogs(); + throw; + } + catch (const std::exception& e) { + // Write out all of the information about the exception, flush the logs, and throw + LFATALC("Exception", e.what()); + LogMgr.flushLogs(); + throw; + } + catch (...) { + // Write out all of the information about the exception, flush the logs, and throw + LFATALC("Exception", "Unknown exception"); + LogMgr.flushLogs(); + throw; + } +} + +int main_main(int argc, char** argv) { auto glVersion = supportedOpenGLVersion(); // create the OpenSpace engine and get arguments for the sgct engine @@ -99,8 +124,9 @@ int main(int argc, char** argv) { // create sgct engine c arguments int newArgc = static_cast(sgctArguments.size()); char** newArgv = new char*[newArgc]; - for (int i = 0; i < newArgc; ++i) + for (int i = 0; i < newArgc; ++i) { newArgv[i] = const_cast(sgctArguments.at(i).c_str()); + } // Need to set this before the creation of the sgct::Engine sgct::MessageHandler::instance()->setLogToConsole(false); @@ -168,29 +194,9 @@ int main(int argc, char** argv) { } // Main loop - try { - LDEBUG("Starting rendering loop"); - _sgctEngine->render(); - LDEBUG("Ending rendering loop"); - } - catch (const ghoul::RuntimeError& e) { - // Write out all of the information about the exception, flush the logs, and throw - LFATALC(e.component, e.message); - LogMgr.flushLogs(); - throw; - } - catch (const std::exception& e) { - // Write out all of the information about the exception, flush the logs, and throw - LFATALC("Exception", e.what()); - LogMgr.flushLogs(); - throw; - } - catch (...) { - // Write out all of the information about the exception, flush the logs, and throw - LFATALC("Exception", "Unknown exception"); - LogMgr.flushLogs(); - throw; - } + LDEBUG("Starting rendering loop"); + _sgctEngine->render(); + LDEBUG("Ending rendering loop"); //clear function bindings to avoid crash after destroying the OpenSpace Engine sgct::MessageHandler::instance()->setLogToCallback(false); diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index 0b06d6f858..5aa8886d51 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -73,6 +73,7 @@ void ModuleEngine::registerModule(std::unique_ptr module) { LDEBUG("Registering module '" << module->name() << "'"); module->initialize(); + LDEBUG("Registered module '" << module->name() << "'"); _modules.push_back(std::move(module)); } diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 5b20b44cc9..773b034e8c 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -975,7 +975,9 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { } void OpenSpaceEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix) { + LTRACE("OpenSpaceEngine::render(begin)"); _renderEngine->render(projectionMatrix, viewMatrix); + LTRACE("OpenSpaceEngine::render(end)"); } void OpenSpaceEngine::postDraw() { diff --git a/src/util/openspacemodule.cpp b/src/util/openspacemodule.cpp index 06e0ca5009..9482490ba5 100644 --- a/src/util/openspacemodule.cpp +++ b/src/util/openspacemodule.cpp @@ -39,7 +39,7 @@ namespace openspace { OpenSpaceModule::OpenSpaceModule(std::string name) { ghoul_assert(!name.empty(), "Name must not be empty"); - setName(name); + setName(std::move(name)); } void OpenSpaceModule::initialize() { @@ -77,8 +77,9 @@ std::string OpenSpaceModule::modulePath() const { std::string moduleName = name(); std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), tolower); - if (FileSys.directoryExists("${MODULES}/" + moduleName)) + if (FileSys.directoryExists("${MODULES}/" + moduleName)) { return absPath("${MODULES}/" + moduleName); + } #ifdef EXTERNAL_MODULES_PATHS