From 0b9d6132e3aa63d03a96e6d9e9031e61867bf549 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Tue, 27 Apr 2010 19:16:57 +0200 Subject: fixed segfaults when passing filenames in command line; added possibility to queue/open folders from command line --- main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index f0844bc3..48d2df5e 100644 --- a/main.c +++ b/main.c @@ -208,7 +208,7 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi } if (parg < pend) { // add files - if (!queue) { + if (!queue && plt_get_curr () != -1) { pl_clear (); pl_reset_cursor (); } @@ -221,8 +221,10 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi else { pname = parg; } - if (pl_add_file (pname, NULL, NULL) < 0) { - fprintf (stderr, "failed to add file %s\n", pname); + if (pl_add_dir (pname, NULL, NULL) < 0) { + if (pl_add_file (pname, NULL, NULL) < 0) { + fprintf (stderr, "failed to add file or folder %s\n", pname); + } } parg += strlen (parg); parg++; @@ -577,6 +579,8 @@ main (int argc, char *argv[]) { conf_load (); // required by some plugins at startup messagepump_init (); // required to push messages while handling commandline plug_load_all (); // required to add files to playlist from commandline + pl_load_all (); + plt_set_curr (conf_get_int ("playlist.current", 0)); // execute server commands in local context int noloadpl = 0; @@ -599,15 +603,10 @@ main (int argc, char *argv[]) { exit (-1); } signal (SIGTERM, sigterm_handler); - atexit (atexit_handler); // helps to save in simple cases, like xkill + atexit (atexit_handler); // helps to save in simple cases // start all subsystems volume_set_db (conf_get_float ("playback.volume", 0)); - if (!noloadpl) { - pl_load_all (); - } - plt_set_curr (conf_get_int ("playlist.current", 0)); - plug_trigger_event_playlistchanged (); // this is old code left for backwards compatibility { -- cgit v1.2.3