vlc | branch: master | Marvin Scholz <epira...@gmail.com> | Thu Sep 28 21:01:42 2017 +0200| [3210a76eaa5c9769ffa218d518f265975aa2b63c] | committer: Marvin Scholz
macosx: Fix ignoring arguments in application:openFiles: In the past, it was relied on the playlist item count to ignore items that were already parsed by libvlc, but this is not enough as with some command line flag combinations, like -v --video-splitter clone --clone-count 5 libvlc would not add any files, but Cocoa would try to open "clone" as a file. Therefore we need to ignore the intersection of the launch arguments and the files to open. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3210a76eaa5c9769ffa218d518f265975aa2b63c --- modules/gui/macosx/VLCMain.m | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/gui/macosx/VLCMain.m b/modules/gui/macosx/VLCMain.m index ce1591a53d..6a77dab9f3 100644 --- a/modules/gui/macosx/VLCMain.m +++ b/modules/gui/macosx/VLCMain.m @@ -159,7 +159,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, { intf_thread_t *p_intf; BOOL launched; - int items_at_launch; BOOL b_active_videoplayback; @@ -273,11 +272,6 @@ static VLCMain *sharedInstance = nil; { _coreinteraction = [VLCCoreInteraction sharedInstance]; - playlist_t * p_playlist = pl_Get(getIntf()); - PL_LOCK; - items_at_launch = p_playlist->p_playing->i_children; - PL_UNLOCK; - #ifdef HAVE_SPARKLE [[SUUpdater sharedUpdater] setDelegate:self]; #endif @@ -413,18 +407,19 @@ static VLCMain *sharedInstance = nil; // or are given at startup. If a file is passed via command line, libvlccore // will add the item, but cocoa also calls this function. In this case, the // invocation is ignored here. + NSArray *resultItems = o_names; 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; + NSArray *launchArgs = [[NSProcessInfo processInfo] arguments]; + + if (launchArgs) { + NSSet *launchArgsSet = [NSSet setWithArray:launchArgs]; + NSMutableSet *itemSet = [NSMutableSet setWithArray:o_names]; + [itemSet minusSet:launchArgsSet]; + resultItems = [itemSet allObjects]; } } - NSArray *o_sorted_names = [o_names sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)]; + NSArray *o_sorted_names = [resultItems sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)]; NSMutableArray *o_result = [NSMutableArray arrayWithCapacity: [o_sorted_names count]]; for (NSUInteger i = 0; i < [o_sorted_names count]; i++) { char *psz_uri = vlc_path2uri([[o_sorted_names objectAtIndex:i] UTF8String], "file"); _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits