Skip to content

Commit

Permalink
Update safe_exit
Browse files Browse the repository at this point in the history
Apparently the destructor of a static object gets called on std::exit
  • Loading branch information
DolphyWind committed May 26, 2023
1 parent da37e51 commit a6c70b7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
2 changes: 1 addition & 1 deletion include/Argparser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.

#define ELECTRA_VERSION_MAJOR 2
#define ELECTRA_VERSION_MINOR 0
#define ELECTRA_VERSION_PATCH 2
#define ELECTRA_VERSION_PATCH 4

#include <string>
#include <vector>
Expand Down
3 changes: 0 additions & 3 deletions include/Electra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ class Electra
/// - Create new currents
void mainLoop();

/// @brief cleans up maps, vectors etc.
void cleanup();

/// @brief Safely exits the program
void safe_exit(int exit_code);

Expand Down
20 changes: 1 addition & 19 deletions src/Electra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Electra &Electra::instance()

Electra::~Electra()
{
cleanup();

}

void Electra::run()
Expand Down Expand Up @@ -331,26 +331,8 @@ void Electra::mainLoop()
defaultlogger.log(LogType::INFO, L"Program finished. Total ticks: {}", tickCount);
}

void Electra::cleanup()
{
m_components.clear();
m_generatorDataMap.clear();
m_generatorChars.clear();
m_generators.clear();
m_currents.clear();
m_filename.clear();
m_currentPath.clear();
m_sourceCode.clear();
m_includedParts.clear();
m_deadCurrentIndexes.clear();
m_newCurrents.clear();
m_stacks.clear();
m_portalMap.clear();
}

void Electra::safe_exit(int exit_code)
{
cleanup();
std::exit(exit_code);
}

Expand Down

0 comments on commit a6c70b7

Please sign in to comment.