fix refcnts for singleton fontconfig-direct
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 22 Apr 2013 18:45:12 +0000 (18:45 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 22 Apr 2013 18:45:12 +0000 (18:45 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@8807 2bbb7eff-a529-9590-31e7-b0007b416f81

src/ports/SkFontConfigInterface_direct.cpp
src/ports/SkFontHost_fontconfig.cpp

index 1dcf932..d4bb3e6 100644 (file)
@@ -41,7 +41,12 @@ private:
 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() {
     static SkFontConfigInterface* gDirect;
     if (NULL == gDirect) {
-        gDirect = new SkFontConfigInterfaceDirect;
+        static SkMutex gMutex;
+        SkAutoMutexAcquire ac(gMutex);
+
+        if (NULL == gDirect) {
+            gDirect = new SkFontConfigInterfaceDirect;
+        }
     }
     return gDirect;
 }
index 9a0f654..0092ebd 100644 (file)
@@ -43,7 +43,7 @@ static SkFontConfigInterface* RefFCI() {
             return fci;
         }
         fci = SkFontConfigInterface::GetSingletonDirectInterface();
-        SkFontConfigInterface::SetGlobal(fci)->unref();
+        SkFontConfigInterface::SetGlobal(fci);
     }
 }