gapplication: Acquire the main context before running
commita379a0ad59df0b377bd7b047d2e5a56417252992
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 28 Jul 2015 07:14:08 +0000 (28 00:14 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 16 Dec 2015 14:15:43 +0000 (16 09:15 -0500)
tree4bf4791380ca9314fb1cadc9a4234eadd4c885ab
parent5e73ca974d37ce2cc2204d1fdf0bf13284668963
gapplication: Acquire the main context before running

Otherwise, we'll acquire it on every loop iteration, which can leave us
vulnerable to racing another thread for the acquisition of the main
context.

This can break methods like g_main_context_invoke, which try to acquire
a context to figure out if it can invoke the method synchronously or
need to defer to an idle. In these cases, it isn't guaranteed that the
invocation function will be invoked in the default main context,
e.g. the one that GApplication is holding.

This also matches what GMainLoop is doing.

https://bugzilla.gnome.org/show_bug.cgi?id=752983
gio/gapplication.c