[vlc-commits] OSX: don't open items twice
Rafaël Carré
git at videolan.org
Mon Jun 24 00:22:55 CEST 2013
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sat Jun 22 15:22:03 2013 +0200| [07fcd250bffc2972f9aa9fd314e9f5ba027c00f9] | committer: Rafaël Carré
OSX: don't open items twice
Closes: #8611
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=07fcd250bffc2972f9aa9fd314e9f5ba027c00f9
---
modules/gui/macosx/intf.h | 2 ++
modules/gui/macosx/intf.m | 27 ++++++++++++++++++++++-----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 768b149..e26f654 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -82,6 +82,8 @@ struct intf_sys_t
{
intf_thread_t *p_intf; /* The main intf object */
input_thread_t *p_current_input, *p_input_changed;
+ BOOL launched; /* finishedLaunching */
+ int items_at_launch; /* items in playlist after launch */
id o_mainmenu; /* VLCMainMenu */
id o_prefs; /* VLCPrefs */
id o_sprefs; /* VLCSimplePrefs */
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 179aafb..bf9b1b1 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -782,8 +782,18 @@ static VLCMain *_o_sharedMainInstance = nil;
nib_main_loaded = TRUE;
}
+- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
+{
+ playlist_t * p_playlist = pl_Get(VLCIntf);
+ PL_LOCK;
+ items_at_launch = p_playlist->p_local_category->i_children;
+ PL_UNLOCK;
+}
+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
+ launched = YES;
+
if (!p_intf)
return;
@@ -1047,9 +1057,19 @@ 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_launch) {
+ int items = [o_names count];
+ if (items > items_at_launch)
+ items_at_launch = 0;
+ else
+ items_at_launch -= items;
+ return;
+ }
+ }
+
// try to add file as subtitle
if ([o_names count] == 1 && psz_uri) {
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
@@ -1077,10 +1097,7 @@ 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];
+ [o_playlist appendArray: o_result atPos: -1 enqueue: !config_GetInt(VLCIntf, "macosx-autoplay")];
return;
}
More information about the vlc-commits
mailing list