summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-27 19:16:57 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-27 19:16:57 +0200
commit0b9d6132e3aa63d03a96e6d9e9031e61867bf549 (patch)
tree89c6d7920187b7d1b544600410133147c6396bac /main.c
parentcb7f7437433ce64a2fb030e520e9cbda717c99e5 (diff)
fixed segfaults when passing filenames in command line;
added possibility to queue/open folders from command line
Diffstat (limited to 'main.c')
-rw-r--r--main.c17
1 files changed, 8 insertions, 9 deletions
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
{