1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

Fix EditorObjectSelection opening of TrackManager

Calling `Close()` on a window deletes its object, rendering any future
uses of its members invalid.

In this case `WindowsCloseAll` closed Editor window itself rendering
call to `ManageTracks` on a deleted pointer. Previously
`WindowsCloseAll` was called, but earlier in the same function we have
already closed all windows but Editor itself. It is sufficient to close
the editor once we have opened `TrackDesignList`.

When this got fixed, I noticed `TrackDesignList` could not locate any
rides, which was happening due to calls to `ObjectManager::UnloadAll`
in several places. Code to load the selected ride back was added.
This commit is contained in:
Michał Janiszewski
2023-03-27 23:48:43 +02:00
parent 1670de0a4e
commit be82582063

View File

@@ -599,12 +599,14 @@ public:
if (!objectSelectResult.Successful)
return;
// Close any other open windows such as options/colour schemes to prevent a crash.
WindowCloseAll();
// WindowClose(*w);
auto& objRepository = OpenRCT2::GetContext()->GetObjectRepository();
_loadedObject = objRepository.LoadObject(listItem->repositoryItem);
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
objManager.LoadObject(_loadedObject.get()->GetIdentifier());
// This function calls window_track_list_open
ManageTracks();
Close();
return;
}