From 82088f3496eed01d393a3e8d99dbe8ab4d9bfe1b Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 3 Oct 2022 20:02:27 +0200 Subject: [PATCH] Fix #17664: Ride music channel data leaks when stopping inactive music --- distribution/changelog.txt | 1 + src/openrct2/ride/RideAudio.cpp | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 30b46901a5..057d39a1e5 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -58,6 +58,7 @@ - Fix: [#17600] Notifications are not properly cleared when loading a park. - Fix: [#17605] Crash when opening parks which have had objects removed externally. - Fix: [#17639, 17735] When building upside down, the special elements list contains many items twice (original bug). +- Fix: [#17664] Unable to save after an extended period of time due to inactive ride music data leaking. - Fix: [#17703] (undefined string) when building on invalid height. - Fix: [#17776] “Other Parks” tab uses separate lists for SC4/SC6 and .park scenarios. - Fix: [#17784] Colour preset RNG is biased (original bug). diff --git a/src/openrct2/ride/RideAudio.cpp b/src/openrct2/ride/RideAudio.cpp index 0c5bc302c7..4f38cb41bf 100644 --- a/src/openrct2/ride/RideAudio.cpp +++ b/src/openrct2/ride/RideAudio.cpp @@ -77,6 +77,8 @@ namespace OpenRCT2::RideAudio RideMusicChannel& operator=(RideMusicChannel&& src) noexcept { + using std::swap; + RideId = src.RideId; TrackIndex = src.TrackIndex; @@ -85,15 +87,8 @@ namespace OpenRCT2::RideAudio Pan = src.Pan; Frequency = src.Frequency; - if (Channel != nullptr) - { - Channel->Stop(); - } - Channel = src.Channel; - src.Channel = nullptr; - - Source = src.Source; - src.Source = nullptr; + swap(Channel, src.Channel); + swap(Source, src.Source); return *this; } @@ -103,12 +98,10 @@ namespace OpenRCT2::RideAudio if (Channel != nullptr) { Channel->Stop(); - Channel = nullptr; - if (Source != nullptr) - { - Source->Release(); - Source = nullptr; - } + } + if (Source != nullptr) + { + Source->Release(); } }