소스 검색

VLCEventManager: synchronize creation of shared object

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Gleb Pinigin 12 년 전
부모
커밋
86741aaff1
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      Sources/VLCEventManager.m

+ 5 - 4
Sources/VLCEventManager.m

@@ -166,11 +166,12 @@ static void * EventDispatcherMainLoop(void * user_data)
 @implementation VLCEventManager
 + (id)sharedManager
 {
-    static VLCEventManager *defaultManager = NULL;
+    static VLCEventManager *defaultManager = nil;
 
-    /* We do want a lock here to avoid leaks */
-    if (!defaultManager)
-        defaultManager = [[VLCEventManager alloc] init];
+    if (defaultManager == nil)
+        @synchronized([VLCEventManager class]) {
+            defaultManager = [[VLCEventManager alloc] init];
+        }
 
     return defaultManager;
 }