diff options
author | jstebbins <[email protected]> | 2010-04-09 18:17:51 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-04-09 18:17:51 +0000 |
commit | 31916b1e9e513a4791587fb133cb076d61559715 (patch) | |
tree | 1f31a34f7ba2df5f4e726240cecff0e8f77607d0 /gtk/src/queuehandler.c | |
parent | 50fe6dd131c74884207ed10e660de6351024ef56 (diff) |
LinGui: allow multiple instances of the gui to run
Each instance has a queue named "queue.<pid>". On startup, the gui
opens and locks with lockf a file "ghb.pid.<pid>". Then it searches
for any other ghb.pid.<pid> files that exist that are not locked. If
it finds one, then some instance of ghb exited and may have left behind
a queue. Try to reload it. If there are no items in the queue, continue
looking for unlocked ghb.pid.<pid> files.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3212 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/queuehandler.c')
-rw-r--r-- | gtk/src/queuehandler.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 24eded5d6..3b91a2464 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -1259,13 +1259,20 @@ ghb_reload_queue(signal_user_data_t *ud) GValue *queue; gint unfinished = 0; gint count, ii; + gint pid; gint status; GValue *settings; gchar *message; g_debug("ghb_reload_queue"); - queue = ghb_load_queue(); +find_pid: + pid = ghb_find_pid_file(); + if (pid < 0) + return FALSE; + + queue = ghb_load_old_queue(pid); + ghb_remove_old_queue_file(pid); // Look for unfinished entries count = ghb_array_len(queue); for (ii = 0; ii < count; ii++) @@ -1277,6 +1284,9 @@ ghb_reload_queue(signal_user_data_t *ud) unfinished++; } } + if (!unfinished) + goto find_pid; + if (unfinished) { message = g_strdup_printf( @@ -1314,11 +1324,11 @@ ghb_reload_queue(signal_user_data_t *ud) add_to_queue_list(ud, settings, NULL); } ghb_queue_buttons_grey(ud); + ghb_save_queue(ud->queue); } else { ghb_value_free(queue); - ghb_remove_queue_file(); } g_free(message); } |