Map editor segmentation fault fix (#9564)
Fixed map editor crashing when creating or opening scenario after played local scenario before opening map editor. Resolves #9563. The cause of the bug was that the ai manager singleton pointer was not set to nullptr after it was destructed. Fixed this by making ai manager destructor set singleton to nullptr. Before this the ai_map_ map member has to be cleared in destructor because it might try to access the singleton when destructed. --------- Co-authored-by: SomeName42 <>
This commit is contained in:
parent
9a8520a192
commit
ad563d99e9
2 changed files with 8 additions and 3 deletions
|
@ -348,6 +348,13 @@ manager::manager()
|
|||
singleton_ = this;
|
||||
}
|
||||
|
||||
manager::~manager() {
|
||||
ai_map_.clear();
|
||||
if(singleton_ == this) {
|
||||
singleton_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
manager* manager::singleton_ = nullptr;
|
||||
|
||||
void manager::add_observer( events::observer* event_observer){
|
||||
|
|
|
@ -131,9 +131,7 @@ public:
|
|||
|
||||
manager();
|
||||
|
||||
/* The singleton can't be set to null in the destructor because member objects
|
||||
(which access the singleton) are destroyed *after* the destructor has been run. */
|
||||
~manager() = default;
|
||||
~manager();
|
||||
|
||||
// =======================================================================
|
||||
// ACCESS TO MANAGER
|
||||
|
|
Loading…
Add table
Reference in a new issue