From 5d7a8b9d1ba444cd18dd3e7e9830b1e72a572ef3 Mon Sep 17 00:00:00 2001 From: trompetin17 Date: Sat, 28 Jan 2023 22:42:00 +0000 Subject: [PATCH] Fix: Crash atlas in relation to Terrain.cpp CalcPosition Patch by: @trompetin17 Differential revision: https://code.wildfiregames.com/D4900 Comments by: @Langbart, @Stan, @Vladislav Fixes #6550 This was SVN commit r27499. --- .../atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp index 3ad6545143..74b6e88f87 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -718,6 +718,11 @@ void MapSidebar::OnRandomGenerate(wxCommandEvent& WXUNUSED(evt)) // Copy the old map settings, so we don't lose them if the map generation fails AtObj oldSettings = settings; + // Deactivate tools, so they don't carry forwards into the new CWorld + // and crash. + m_ScenarioEditor.GetToolManager().SetCurrentTool(_T("")); + // TODO: clear the undo buffer, etc + AtlasMessage::qGenerateMap qry((std::wstring)scriptName.wc_str(), json); qry.Post(); @@ -729,6 +734,8 @@ void MapSidebar::OnRandomGenerate(wxCommandEvent& WXUNUSED(evt)) } m_ScenarioEditor.NotifyOnMapReload(); + + m_ScenarioEditor.GetCommandProc().ClearCommands(); } void MapSidebar::OnOpenPlayerPanel(wxCommandEvent& WXUNUSED(evt))