Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: src/core/SkTypeface.cpp

Issue 419113002: Fix thread unsafe mutex initialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 48be651fd6a8e80c5467d86c5320067d45fe40a1..01b534c95fa4adb28f216b4818e4ef9c42b957cd 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -76,13 +76,13 @@ protected:
}
};
+SK_DECLARE_STATIC_MUTEX(gCreateDefaultMutex);
SkTypeface* SkTypeface::CreateDefault(int style) {
// If backed by fontconfig, it's not safe to call SkFontHost::CreateTypeface concurrently.
// To be safe, we serialize here with a mutex so only one call to
// CreateTypeface is happening at any given time.
// TODO(bungeman, mtklein): This is sad. Make our fontconfig code safe?
- SK_DECLARE_STATIC_MUTEX(mutex);
- SkAutoMutexAcquire lock(&mutex);
+ SkAutoMutexAcquire lock(&gCreateDefaultMutex);
SkTypeface* t = SkFontHost::CreateTypeface(NULL, NULL, (Style)style);
return t ? t : SkEmptyTypeface::Create();

Powered by Google App Engine
This is Rietveld 408576698