@@ -23,6 +23,7 @@ int send_printer_added(void *_dialog_name, unsigned flags, cups_dest_t *dest);
2323void connect_to_signals ();
2424
2525BackendObj * b ;
26+ GMainLoop * loop ;
2627
2728void update_printer_lists ()
2829{
@@ -130,7 +131,7 @@ int main()
130131 G_CALLBACK (on_printer_added ), NULL );
131132 }
132133
133- GMainLoop * loop = g_main_loop_new (NULL , FALSE);
134+ loop = g_main_loop_new (NULL , FALSE);
134135 g_main_loop_run (loop );
135136
136137 /* Main loop exited */
@@ -342,7 +343,7 @@ int send_printer_added(void *_dialog_name, unsigned flags, cups_dest_t *dest)
342343 return 1 ; //continue enumeration
343344}
344345
345- static void on_handle_do_listing (PrintBackend * interface ,
346+ static gboolean on_handle_do_listing (PrintBackend * interface ,
346347 GDBusMethodInvocation * invocation ,
347348 gboolean is_listed ,
348349 gpointer not_used )
@@ -352,19 +353,24 @@ static void on_handle_do_listing(PrintBackend *interface,
352353 const char * dialog_name = g_dbus_method_invocation_get_sender (invocation );
353354 Dialog * d = find_dialog (b , dialog_name );
354355 if (d && d -> keep_alive )
355- return ;
356+ goto out ;
356357
357358 set_dialog_cancel (b , dialog_name );
358359 remove_frontend (b , dialog_name );
359360 if (no_frontends (b ))
360361 {
362+ // FIXME: this is racy against method calls already in-flight from dbus
361363 g_message ("No frontends connected .. exiting backend.\n" );
362- exit ( EXIT_SUCCESS );
364+ g_idle_add_once (( GSourceOnceFunc ) g_main_loop_quit , loop );
363365 }
364366 }
367+
368+ out :
369+ print_backend_complete_do_listing (interface , invocation );
370+ return TRUE;
365371}
366372
367- static void on_handle_show_remote_printers (PrintBackend * interface ,
373+ static gboolean on_handle_show_remote_printers (PrintBackend * interface ,
368374 GDBusMethodInvocation * invocation ,
369375 gboolean is_visible ,
370376 gpointer not_used )
@@ -386,10 +392,12 @@ static void on_handle_show_remote_printers(PrintBackend *interface,
386392 refresh_printer_list (b , dialog_name );
387393 }
388394 }
395+ print_backend_complete_show_remote_printers (interface , invocation );
396+ return TRUE;
389397}
390398
391399
392- static void on_handle_show_temporary_printers (PrintBackend * interface ,
400+ static gboolean on_handle_show_temporary_printers (PrintBackend * interface ,
393401 GDBusMethodInvocation * invocation ,
394402 gboolean is_visible ,
395403 gpointer not_used )
@@ -411,6 +419,8 @@ static void on_handle_show_temporary_printers(PrintBackend *interface,
411419 refresh_printer_list (b , dialog_name );
412420 }
413421 }
422+ print_backend_complete_show_temporary_printers (interface , invocation );
423+ return TRUE;
414424}
415425
416426static gboolean on_handle_is_accepting_jobs (PrintBackend * interface ,
0 commit comments