[vlc-devel] [PATCH] OSX: don't open items twice

David Fuhrmann david.fuhrmann at gmail.com
Sun Jun 23 15:53:00 CEST 2013


Am 22.06.2013 um 15:22 schrieb Rafaël Carré <funman at videolan.org>:

> 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;
> +        }
> +    }

Hi,

I was hoping that a more clean solution can be found, but this hack will probably work, too.
As it seems, only all items from the second one onwards are duplicated, not the first one.

I am not sure if this can be an issue in this scenario, but you might want to decrease the variable by [o_names count], to be on the safe side.

And, auto start of the items added by command line is now completely broken with this patch, but that is another issue, and it was already quite ugly before.

With best regards,
David


More information about the vlc-devel mailing list