diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2015-12-16 11:34:41 -0500 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2015-12-16 11:44:43 -0500 |
commit | aa9a33b0dabb68a6586956d6d4aa0c861e534321 (patch) | |
tree | ba4774bec74618cf0d5a0c88f90b1ba5f01f97e8 /gio/gapplication.c | |
parent | 1f341afa9acfb05afb02b73a4dff8992e0464aaa (diff) | |
download | glib-aa9a33b0dabb68a6586956d6d4aa0c861e534321.tar.gz |
GApplication: Avoid getting the default context repeatidly
This avoids getting a global lock on every main loop iteration.
https://bugzilla.gnome.org/show_bug.cgi?id=759554
Diffstat (limited to 'gio/gapplication.c')
-rw-r--r-- | gio/gapplication.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gio/gapplication.c b/gio/gapplication.c index 05178e28d..e24ab696e 100644 --- a/gio/gapplication.c +++ b/gio/gapplication.c @@ -2269,6 +2269,7 @@ g_application_run (GApplication *application, { gchar **arguments; int status; + GMainContext *context; gboolean acquired_context; g_return_val_if_fail (G_IS_APPLICATION (application), 1); @@ -2297,7 +2298,8 @@ g_application_run (GApplication *application, g_free (prgname); } - acquired_context = g_main_context_acquire (NULL); + context = g_main_context_default (); + acquired_context = g_main_context_acquire (context); g_return_val_if_fail (acquired_context, 0); if (!G_APPLICATION_GET_CLASS (application) @@ -2331,7 +2333,7 @@ g_application_run (GApplication *application, if (application->priv->must_quit_now) break; - g_main_context_iteration (NULL, TRUE); + g_main_context_iteration (context, TRUE); status = 0; } @@ -2355,10 +2357,10 @@ g_application_run (GApplication *application, g_settings_sync (); if (!application->priv->must_quit_now) - while (g_main_context_iteration (NULL, FALSE)) + while (g_main_context_iteration (context, FALSE)) ; - g_main_context_release (NULL); + g_main_context_release (context); return status; } |