Browse Source

Fix possibly hanging pointer to deleted CGObjectInstance

Was stored by CRemoveObjectOperation and accessed on destruction even
though it has been removed by the game
Ivan Savenko 1 year ago
parent
commit
62b564650d
1 changed files with 3 additions and 0 deletions
  1. 3 0
      lib/rmg/CMapGenerator.cpp

+ 3 - 0
lib/rmg/CMapGenerator.cpp

@@ -126,6 +126,9 @@ std::unique_ptr<CMap> CMapGenerator::generate()
 		fillZones();
 		//updated guarded tiles will be calculated in CGameState::initMapObjects()
 		map->getZones().clear();
+
+		// undo manager keeps pointers to object that might be removed during gameplay. Remove them to prevent any hanging pointer after gameplay
+		map->getEditManager()->getUndoManager().clearAll();
 	}
 	catch (rmgException &e)
 	{