[vlc-commits] macosx/open: don't iterate on mounted volumes on the main thread

Felix Paul Kühne git at videolan.org
Tue Jan 29 12:21:05 CET 2019


vlc/vlc-3.0 | branch: master | Felix Paul Kühne <felix at feepk.net> | Tue Jan 29 11:50:01 2019 +0100| [135e7ff2880d7e8c752f7c474c5816d5dda5b496] | committer: Felix Paul Kühne

macosx/open: don't iterate on mounted volumes on the main thread

Asking NSFileManager for the mounted devices can take very long (>6s) when the devices are slow to respond, so let's do that on the background thread and don't delay display of the open panel.

(cherry picked from commit c2a24a2576d3482ab251488043688997dabeb439)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=135e7ff2880d7e8c752f7c474c5816d5dda5b496
---

 modules/gui/macosx/VLCOpenWindowController.m | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/modules/gui/macosx/VLCOpenWindowController.m b/modules/gui/macosx/VLCOpenWindowController.m
index de8722fc4c..1555f90a82 100644
--- a/modules/gui/macosx/VLCOpenWindowController.m
+++ b/modules/gui/macosx/VLCOpenWindowController.m
@@ -312,6 +312,7 @@ static NSString *kCaptureTabViewId  = @"capture";
     [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
 
     [self qtkToggleUIElements:nil];
+    [self updateMediaSelector:nil];
     [self scanOpticalMedia:nil];
 
     [self setMRL: @""];
@@ -810,9 +811,10 @@ static NSString *kCaptureTabViewId  = @"capture";
             image, @"image", nil];
 }
 
-- (void)scanDevicesWithPaths:(NSArray *)paths
+- (void)scanDevices
 {
     @autoreleasepool {
+        NSArray *paths = [NSArray arrayWithArray:[[NSWorkspace sharedWorkspace] mountedRemovableMedia]];
         NSUInteger count = [paths count];
         NSMutableArray *o_result = [NSMutableArray array];
         for (NSUInteger i = 0; i < count; i++)
@@ -841,7 +843,7 @@ static NSString *kCaptureTabViewId  = @"capture";
 
 - (void)scanOpticalMedia:(NSNotification *)o_notification
 {
-    [NSThread detachNewThreadSelector:@selector(scanDevicesWithPaths:) toTarget:self withObject:[NSArray arrayWithArray:[[NSWorkspace sharedWorkspace] mountedRemovableMedia]]];
+    [NSThread detachNewThreadSelector:@selector(scanDevices) toTarget:self withObject:nil];
 }
 
 - (void)updateMediaSelector:(NSNumber *)selection
@@ -879,7 +881,6 @@ static NSString *kCaptureTabViewId  = @"capture";
         [self setMRL:@""];
         [self showOpticalMediaView: _discNoDiscView withIcon: [NSImage imageNamed: @"NSApplicationIcon"]];
     }
-
 }
 
 - (IBAction)discSelectorChanged:(id)sender



More information about the vlc-commits mailing list