GNOME Bugzilla – Bug 750796
Strange behaviour of GApplication::handle-local-options
Last modified: 2015-09-09 15:31:34 UTC
The GApplication::handle-local-options signal has its own accumulator, g_application_handle_local_options_accumulator(), with a strange behaviour. As soon as a signal handler returns a negative value (e.g. -1), the accumulator returns FALSE, thus aborting signal emission. The default signal handler returns -1. If I connect my signal handler after the default handler, my handler is not called. If I connect it before the default handler, it is called. If it returns >= 0, the accumulator returns TRUE, and the default handler is called. The return value of the signal emission is the return value of the last called signal handler, which will always be -1 as long as the default handler is not overridden. Is this really the intended behaviour? It would be more reasonable to abort the signal emission when a signal handler returns >= 0. Let the accumulator finish with return value < 0; instead of return value >= 0; Alternatively, use g_signal_accumulator_first_wins(), like ::command-line.
Created attachment 305192 [details] [review] patch: gapplication: Abort ::handle-local-options on exit code >= 0
I've just reached to this problem as well. In order to avoid it I had to set the default handler to NULL before connecting to the signal, so my signal handler return value would take priority over the default one.
fixed in 243d740c0430a2fa123c2428bf25ae80768ed633
*** This bug has been marked as a duplicate of bug 751598 ***