mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
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
This commit is contained in:
parent
1f341afa9a
commit
aa9a33b0da
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user