Ver código fonte

event manager: fix event propagation issues introduced in 3a85ea62 and b04ab8c8

Felix Paul Kühne 11 anos atrás
pai
commit
5f9893863c
1 arquivos alterados com 8 adições e 8 exclusões
  1. 8 8
      Sources/VLCEventManager.m

+ 8 - 8
Sources/VLCEventManager.m

@@ -321,17 +321,17 @@ static void * EventDispatcherMainLoop(void * user_data)
 {
     // Check that we were not cancelled, ie, target was released
     if ([self markMessageHandledOnMainThreadIfExists:message]) {
+        NSString *notificationName = message.name;
         id target = message.target;
-        if (message.object == NULL)
-            return;
+        SEL targetSelector = message.sel;
+        [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:notificationName object:target]];
 
-        [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:message.object object:target]];
+        id delegate = [message.target delegate];
+        if (!delegate || ![delegate respondsToSelector:targetSelector])
+            return;
 
-        id delegate = [target delegate];
-        if ([delegate respondsToSelector:message.sel]) {
-            void (*method)(id, SEL, id) = (void (*)(id, SEL, id)) [delegate methodForSelector:message.sel];
-            method(delegate, message.sel, [NSNotification notificationWithName:message.object object:target]);
-        }
+        void (*method)(id, SEL, id) = (void (*)(id, SEL, id))[delegate methodForSelector:targetSelector];
+        method(delegate, targetSelector, [NSNotification notificationWithName:notificationName object:target]);
     }
 }