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
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);
}