printoperation: fix case where operation may complete multiple twice

If we are the final backend, then after removing ourselves there is no
backend remaining. We will schedule the idle even if it has already been
scheduled. This idle is required to run exactly once and executing it
twices results in a double free that crashes loupe when printing. It
also causes the user callback to execute twice, which could cause
similar problems.

Fixes #6122
This commit is contained in:
Michael Catanzaro
2023-09-26 18:47:01 -05:00
committed by Matthias Clasen
parent d4d0883a92
commit 29a243e3d7

View File

@@ -1135,7 +1135,10 @@ printer_list_done_cb (GtkPrintBackend *backend,
gtk_print_backend_destroy (backend);
g_object_unref (backend);
if (finder->backends == NULL)
/* If there are no more backends left after removing ourselves from the list
* above, then we're finished.
*/
if (finder->backends == NULL && !finder->found_printer)
g_idle_add (find_printer_idle, finder);
}