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

Felix Paul Kühne git at videolan.org
Mon Jan 21 23:42:52 CET 2013


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

vout_macosx: protect vout_display_SendEvent calls to prevent potential crashes
(cherry picked from commit 0a86a76fec01fe495ace7894c4ecb6be32b4fef7)

Conflicts:
	modules/video_output/macosx.m

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=7ce065dd2c3817bf278d5044c1c810939a1e6789
---

 NEWS                          |    1 +
 modules/video_output/macosx.m |   29 +++++++++++++++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index d5e0f53..612ffbf 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Mac OS X:
  * Fix listing of the lua interfaces (web, telnet and console)
    in the advanced preferences panel
  * Fix spatializer audio filter panel
+ * Fix crash within the video output code
 
 
 Changes between 2.0.4 and 2.0.5:
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index c25112a..336541a 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -708,10 +708,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];
@@ -719,22 +722,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