Skip to content

Commit

Permalink
software: Fix possible segfault when plugins load debugging failed
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert committed Oct 18, 2024
1 parent c18e840 commit 9afb250
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions software/talipot/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,16 @@ int main(int argc, char **argv) {
exit(1);
}

auto cleanup = []() {
// We need to clear allocated OpenGL resources to avoid a
// segfault when we close talipot
GlTextureManager::deleteAllTextures();
GlOffscreenRenderer::instance().deleteEarly();
PythonInterpreter::instance().deleteEarly();
};

if (debugPluginsLoad && !pluginErrors.isEmpty()) {
cleanup();
return 1;
}

Expand Down Expand Up @@ -240,11 +249,7 @@ int main(int argc, char **argv) {

mainWindow.deleteEarly();

// We need to clear allocated OpenGL resources to avoid a
// segfault when we close talipot
GlTextureManager::deleteAllTextures();
GlOffscreenRenderer::instance().deleteEarly();
PythonInterpreter::instance().deleteEarly();
cleanup();

return result;
}

0 comments on commit 9afb250

Please sign in to comment.