I just update juce_graphics module to Juce 5 developer branch.
And I find the “new” clever assert in Font::getStringWidthFloat and Font::getGlyphPositions:
// This call isn't thread-safe when there's a message thread running jassert (MessageManager::getInstanceWithoutCreating() == nullptr || MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager());
I’m wondering why this is not thread safe ?
Is it because of
or because of
If it is related to TypefaceCache, may be we should move this assert in
method instead because there is other extra callers that should be protected:
Font::getAscent() Font::getAvailableStyles() Font::getHeightToPointsFactor()
I’m looking at this code because I made some offscreen Juce::Image Font rendering in my OpenGL thread, so I protect my caller code with:
juce::MessageManager::Lock managerLock; managerLock.enter(); ... // text rendering managerLock.exit();
Hoping that client of my code already start the dispatch loop. (I do not know the way to check it, help is welcome here)
Thanks in advance for your advices.
NB: I already have related issue 3 years before with Juce 4 here:
All the bests