Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-28 17:05:15 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-28 17:05:15 +0400
commit0d7dbbb6e1fc0bb85d236ca1e04ff966f4ad39c9 (patch)
tree2bce40d958d1ac50361d6d3c58aab714dbb0a55b /source/blender/blenfont/intern/blf_font.c
parentca33bea285c1ffe74e9f6d3c6b28d7b26ebc84ab (diff)
Fix #35884: crash opening .blend with generated color grid image and preview render.
Printing text on the color grid image would initialize font glyphs from a thread at the same time as the UI, causing conflicts. The freetype glyph renderer needs to be mutex locked because it uses a shared buffer internally even when rendering for different fonts. Also needed to change the image generate function to use the render monospace font to avoid conflicts in blenfont. What's still weak in the blenfont API is that there is no distinction between a font and a thread using that font to render with some particular size, style, etc.
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r--source/blender/blenfont/intern/blf_font.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index f346478889b..56a77d643d6 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -48,6 +48,7 @@
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
+#include "BLI_threads.h"
#include "BLI_linklist.h" /* linknode */
#include "BIF_gl.h"
@@ -64,15 +65,18 @@
/* freetype2 handle ONLY for this file!. */
static FT_Library ft_lib;
+static SpinLock ft_lib_mutex;
int blf_font_init(void)
{
+ BLI_spin_init(&ft_lib_mutex);
return FT_Init_FreeType(&ft_lib);
}
void blf_font_exit(void)
{
FT_Done_FreeType(ft_lib);
+ BLI_spin_end(&ft_lib_mutex);
}
void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi)
@@ -572,6 +576,7 @@ static void blf_font_fill(FontBLF *font)
font->buf_info.col[3] = 0;
font->ft_lib = ft_lib;
+ font->ft_lib_mutex = &ft_lib_mutex;
}
FontBLF *blf_font_new(const char *name, const char *filename)