[vlc-commits] vout_macosx: protect vout_display_SendEvent calls to prevent potential crashes

Felix Paul Kühne git at videolan.org
Mon Jan 21 22:08:59 CET 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Jan 21 22:08:39 2013 +0100| [0a86a76fec01fe495ace7894c4ecb6be32b4fef7] | committer: Felix Paul Kühne

vout_macosx: protect vout_display_SendEvent calls to prevent potential crashes

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0a86a76fec01fe495ace7894c4ecb6be32b4fef7
---

 modules/video_output/macosx.m |   28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index df71ba9..104479b 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -701,9 +701,13 @@ static void OpenglSwap (vlc_gl_t *gl)
 
 - (void)mouseDown:(NSEvent *)o_event
 {
-    if ([o_event type] == NSLeftMouseDown && !([o_event modifierFlags] &  NSControlKeyMask)) {
-        if ([o_event clickCount] <= 1)
-            vout_display_SendEventMousePressed (vd, MOUSE_BUTTON_LEFT);
+    @synchronized (self) {
+        if (vd) {
+            if ([o_event type] == NSLeftMouseDown && !([o_event modifierFlags] &  NSControlKeyMask)) {
+                if ([o_event clickCount] <= 1)
+                    vout_display_SendEventMousePressed (vd, MOUSE_BUTTON_LEFT);
+            }
+        }
     }
 
     [super mouseDown:o_event];
@@ -711,22 +715,32 @@ static void OpenglSwap (vlc_gl_t *gl)
 
 - (void)otherMouseDown:(NSEvent *)o_event
 {
-    vout_display_SendEventMousePressed (vd, MOUSE_BUTTON_CENTER);
+    @synchronized (self) {
+        if (vd)
+            vout_display_SendEventMousePressed (vd, MOUSE_BUTTON_CENTER);
+    }
 
     [super otherMouseDown: o_event];
 }
 
 - (void)mouseUp:(NSEvent *)o_event
 {
-    if ([o_event type] == NSLeftMouseUp)
-        vout_display_SendEventMouseReleased (vd, MOUSE_BUTTON_LEFT);
+    @synchronized (self) {
+        if (vd) {
+            if ([o_event type] == NSLeftMouseUp)
+                vout_display_SendEventMouseReleased (vd, MOUSE_BUTTON_LEFT);
+        }
+    }
 
     [super mouseUp: o_event];
 }
 
 - (void)otherMouseUp:(NSEvent *)o_event
 {
-    vout_display_SendEventMouseReleased (vd, MOUSE_BUTTON_CENTER);
+    @synchronized (self) {
+        if (vd)
+            vout_display_SendEventMouseReleased (vd, MOUSE_BUTTON_CENTER);
+    }
 
     [super otherMouseUp: o_event];
 }



More information about the vlc-commits mailing list