Browse Source

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

tags/2021-05-28
jules 8 years ago
parent
commit
66fa7e7411
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      modules/juce_graphics/fonts/juce_Font.cpp

+ 8
- 0
modules/juce_graphics/fonts/juce_Font.cpp 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())


Loading…
Cancel
Save