[gupnp-dlna] gupnp-dlna-info: Exit properly in async mode



commit 9007c6920d162c6f53316dc14390358d9a0473cd
Author: Jens Georg <mail jensge org>
Date:   Wed Jul 1 00:26:55 2015 +0200

    gupnp-dlna-info: Exit properly in async mode
    
    If no files could be added to the guesser, it would be stuck in the main loop
    forever.
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751634

 tools/gupnp-dlna-info.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/tools/gupnp-dlna-info.c b/tools/gupnp-dlna-info.c
index 7fc0fb4..6fabafa 100644
--- a/tools/gupnp-dlna-info.c
+++ b/tools/gupnp-dlna-info.c
@@ -51,6 +51,7 @@ typedef struct
         GUPnPDLNAProfileGuesser *guesser;
         int argc;
         char **argv;
+        GMainLoop *ml;
 } PrivStruct;
 
 static void
@@ -212,6 +213,11 @@ async_idle_loop (PrivStruct *ps)
         for (iter = 1; iter < ps->argc; iter++)
                 process_file (ps->guesser, ps->argv[iter]);
 
+        /* No files added to queue, exit program */
+        if (files_to_guess == 0) {
+                g_main_loop_quit (ps->ml);
+        }
+
         return FALSE;
 }
 
@@ -266,6 +272,10 @@ main (int argc,
 
         guesser = gupnp_dlna_profile_guesser_new (relaxed_mode,
                                                   extended_mode);
+        if (guesser == NULL) {
+                g_print ("Failed to create meta-data guesser\n");
+                exit (1);
+        }
 
         if (async == FALSE) {
                 gint iter;
@@ -279,6 +289,7 @@ main (int argc,
                 ps->guesser = guesser;
                 ps->argc = argc;
                 ps->argv = argv;
+                ps->ml = ml;
 
                 g_idle_add ((GSourceFunc) async_idle_loop, ps);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]