mirror of
https://github.com/got-feedBack/feedBack-desktop.git
synced 2026-09-10 22:14:10 +00:00
fix(audio): fail runDeviceLifecycleOp when the MessageManager is gone
A null MessageManager (pre-init or mid-shutdown) previously fell through to inline execution on the caller's thread while reporting success - exactly the unserialised device teardown this helper prevents. Return false instead, per the documented unavailable/timeout contract. Addresses CodeRabbit review on #113. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
354052bc7c
commit
aa0bb9d173
@@ -84,9 +84,15 @@ template <typename Func>
|
||||
inline bool runDeviceLifecycleOp(Func&& func)
|
||||
{
|
||||
#if JUCE_WINDOWS
|
||||
if (auto* mm = juce::MessageManager::getInstanceWithoutCreating())
|
||||
if (!mm->isThisTheMessageThread())
|
||||
return dispatchOnMessageThread(std::forward<Func>(func));
|
||||
// No MessageManager means the pump is gone (pre-init or mid-shutdown):
|
||||
// report failure instead of running the mutation unserialised on the
|
||||
// caller's thread — that would reintroduce the race this helper exists
|
||||
// to prevent (CodeRabbit #113 review).
|
||||
auto* mm = juce::MessageManager::getInstanceWithoutCreating();
|
||||
if (mm == nullptr)
|
||||
return false;
|
||||
if (!mm->isThisTheMessageThread())
|
||||
return dispatchOnMessageThread(std::forward<Func>(func));
|
||||
#endif
|
||||
func();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user