diff --git a/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp b/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp index 64acb79da2..8c67b003ca 100644 --- a/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp +++ b/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp @@ -33,10 +33,8 @@ public: owner.handleAsyncUpdate(); } - Atomic shouldDeliver; - -private: AsyncUpdater& owner; + Atomic shouldDeliver; JUCE_DECLARE_NON_COPYABLE (AsyncUpdaterMessage) }; @@ -53,13 +51,19 @@ AsyncUpdater::~AsyncUpdater() // pending on the main event thread - that's pretty dodgy threading, as the callback could // happen after this destructor has finished. You should either use a MessageManagerLock while // deleting this object, or find some other way to avoid such a race condition. - jassert ((! isUpdatePending()) || MessageManager::getInstance()->currentThreadHasLockedMessageManager()); + jassert ((! isUpdatePending()) + || MessageManager::getInstanceWithoutCreating() == nullptr + || MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()); activeMessage->shouldDeliver.set (0); } void AsyncUpdater::triggerAsyncUpdate() { + // If you're calling this before (or after) the MessageManager is + // running, then you're not going to get any callbacks! + jassert (MessageManager::getInstanceWithoutCreating() != nullptr); + if (activeMessage->shouldDeliver.compareAndSetBool (1, 0)) if (! activeMessage->post()) cancelPendingUpdate(); // if the message queue fails, this avoids getting diff --git a/modules/juce_events/timers/juce_Timer.cpp b/modules/juce_events/timers/juce_Timer.cpp index 5d9c38c438..61b60b7419 100644 --- a/modules/juce_events/timers/juce_Timer.cpp +++ b/modules/juce_events/timers/juce_Timer.cpp @@ -294,6 +294,10 @@ Timer::~Timer() void Timer::startTimer (const int interval) noexcept { + // If you're calling this before (or after) the MessageManager is + // running, then you're not going to get any timer callbacks! + jassert (MessageManager::getInstanceWithoutCreating() != nullptr); + const TimerThread::LockType::ScopedLockType sl (TimerThread::lock); if (timerPeriodMs == 0)