1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Made the logMessage() method in UnitTestsDemo thread-safe

This commit is contained in:
ed 2019-04-03 15:13:02 +01:00
parent fc392ee3a5
commit 132295bdb3

View file

@ -171,10 +171,13 @@ private:
void logMessage (const String& message)
{
MessageManagerLock mm (this);
WeakReference<UnitTestsDemo> safeOwner (&owner);
if (mm.lockWasGained()) // this lock may fail if this thread has been told to stop
owner.logMessage (message);
MessageManager::callAsync ([=]
{
if (auto* o = safeOwner.get())
o->logMessage (message);
});
}
void timerCallback() override
@ -224,5 +227,6 @@ private:
testResultsBox.applyFontToAllText (testResultsBox.getFont());
}
JUCE_DECLARE_WEAK_REFERENCEABLE (UnitTestsDemo)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UnitTestsDemo)
};