diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2015-04-27 11:06:09 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-04-28 12:32:32 +0200 |
commit | b458df8680443636e3cf07659137f658ba979fb9 (patch) | |
tree | 726b628afbfbb8bdef8858bc756b7eeb06f0a457 /src | |
parent | b6b5e83f6c8e191f25a1afcf19a941b9f96c3e78 (diff) | |
download | network-manager-applet-b458df8680443636e3cf07659137f658ba979fb9.tar.gz |
applet: don't crash if an agent is already registered
GNOME 3.16 makes it possible to run the legacy applets again, making it
possible to develop & debug the applet there. Unfortunately, we crash -- GNOME
registers its own secret agent.
Moreover the error handling in libnm (as of post-1.0 master) is broken. A
separate commit to daemon will address that. For now let's just avoid crashing
and produce a warning message.
Diffstat (limited to 'src')
-rw-r--r-- | src/applet.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/applet.c b/src/applet.c index ba13cbb4..fc5939a5 100644 --- a/src/applet.c +++ b/src/applet.c @@ -3488,9 +3488,20 @@ applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data) static void register_agent (NMApplet *applet) { + GError *error = NULL; + g_return_if_fail (!applet->agent); - applet->agent = applet_agent_new (NULL); + applet->agent = applet_agent_new (&error); + if (!applet->agent) { + if (!error) + error = g_error_new (NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_FAILED, + "Could not register secret agent"); + g_warning ("%s", error->message); + g_error_free (error); + return; + } g_assert (applet->agent); g_signal_connect (applet->agent, APPLET_AGENT_GET_SECRETS, G_CALLBACK (applet_agent_get_secrets_cb), applet); |