From 3c49081df34fb1801063c0b538d12d4422fcf3f0 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 20 Dec 2024 14:33:43 -0500 Subject: Fixed remaining thread unsafe APState/IPCState reads Still would like to add some kind of wrapper object that TrackerState could use to read APState without locking, since it'll only ever be called from the thread that would do the mutating, but this is fine for now. --- src/ap_state.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ap_state.cpp') diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 908c3a8..4ac0cce 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -675,7 +675,9 @@ bool AP_IsPaintingShuffle() { return GetState().painting_shuffle; } -const std::map& AP_GetPaintingMapping() { +std::map AP_GetPaintingMapping() { + std::lock_guard state_guard(GetState().state_mutex); + return GetState().painting_mapping; } @@ -685,7 +687,7 @@ bool AP_IsPaintingMappedTo(const std::string& painting_id) { return GetState().painting_codomain.count(painting_id); } -const std::set& AP_GetCheckedPaintings() { +std::set AP_GetCheckedPaintings() { return GetState().GetCheckedPaintings(); } @@ -778,7 +780,7 @@ bool AP_IsSunwarpShuffle() { return GetState().sunwarp_shuffle; } -const std::map& AP_GetSunwarpMapping() { +std::map AP_GetSunwarpMapping() { return GetState().sunwarp_mapping; } -- cgit 1.4.1