1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-01 03:10:06 +00:00

Added some assertions to catch use of some Font methods on background threads

This commit is contained in:
jules 2017-07-06 11:45:26 +01:00
parent a45855f7c3
commit 66fa7e7411

View file

@ -625,6 +625,10 @@ int Font::getStringWidth (const String& text) const
float Font::getStringWidthFloat (const String& text) const
{
// This call isn't thread-safe when there's a message thread running
jassert (MessageManager::getInstanceWithoutCreating() == nullptr
|| MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager());
auto w = getTypeface()->getStringWidth (text);
if (font->kerning != 0.0f)
@ -635,6 +639,10 @@ float Font::getStringWidthFloat (const String& text) const
void Font::getGlyphPositions (const String& text, Array<int>& glyphs, Array<float>& xOffsets) const
{
// This call isn't thread-safe when there's a message thread running
jassert (MessageManager::getInstanceWithoutCreating() == nullptr
|| MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager());
getTypeface()->getGlyphPositions (text, glyphs, xOffsets);
if (auto num = xOffsets.size())