mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added some assertions to catch event-based objects being used before the message manager has been initialised
This commit is contained in:
parent
11b652e35a
commit
c2bd54aefc
2 changed files with 12 additions and 4 deletions
|
|
@ -33,10 +33,8 @@ public:
|
|||
owner.handleAsyncUpdate();
|
||||
}
|
||||
|
||||
Atomic<int> shouldDeliver;
|
||||
|
||||
private:
|
||||
AsyncUpdater& owner;
|
||||
Atomic<int> 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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue