[vlc-devel] [PATCH] OSX: don't open items twice
Rafaël Carré
funman at videolan.org
Sat Jun 22 15:22:03 CEST 2013
Closes: #8611
---
modules/gui/macosx/intf.m | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 179aafb..3c634a9 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -782,8 +782,21 @@ static VLCMain *_o_sharedMainInstance = nil;
nib_main_loaded = TRUE;
}
+static BOOL launched = NO;
+static unsigned int items_at_start = 0;
+
+- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
+{
+ playlist_t * p_playlist = pl_Get(VLCIntf);
+ PL_LOCK;
+ items_at_start = p_playlist->p_local_category->i_children;
+ PL_UNLOCK;
+}
+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
+ launched = YES;
+
if (!p_intf)
return;
@@ -1047,9 +1060,15 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)application:(NSApplication *)o_app openFiles:(NSArray *)o_names
{
- BOOL b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
char *psz_uri = vlc_path2uri([[o_names objectAtIndex:0] UTF8String], "file");
+ if (launched == NO) {
+ if (items_at_start) {
+ items_at_start--;
+ return;
+ }
+ }
+
// try to add file as subtitle
if ([o_names count] == 1 && psz_uri) {
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
@@ -1077,10 +1096,8 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_result addObject: o_dic];
}
- if (b_autoplay)
- [o_playlist appendArray: o_result atPos: -1 enqueue: NO];
- else
- [o_playlist appendArray: o_result atPos: -1 enqueue: YES];
+ BOOL b_enqueue = config_GetInt(VLCIntf, "macosx-autoplay") ? NO : YES;
+ [o_playlist appendArray: o_result atPos: -1 enqueue: b_enqueue];
return;
}
--
1.8.1.2
More information about the vlc-devel
mailing list