瀏覽代碼

event manager: fix incomplete coalescing to avoid an unreasonably large number of messages on the main thread, which could lead to a memory impact

Felix Paul Kühne 11 年之前
父節點
當前提交
188b7fc619
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      Sources/VLCEventManager.m

+ 7 - 4
Sources/VLCEventManager.m

@@ -207,12 +207,15 @@ static void * EventDispatcherMainLoop(void * user_data)
 
             pthread_mutex_unlock(&_queueLock);
 
-            dispatch_async(dispatch_get_main_queue(), ^{
-                if (message.type == VLCNotification)
+            if (message.type == VLCNotification) {
+                dispatch_async(dispatch_get_main_queue(), ^{
                     [self callDelegateOfObjectAndSendNotificationWithArgs:message];
-                else
+                });
+            } else {
+                dispatch_sync(dispatch_get_main_queue(), ^{
                     [self callObjectMethodWithArgs:message];
-            });
+                });
+            }
         }
 
         /* Sleep a bit not to flood the interface */