[network-manager-applet] applet: don't crash if an agent is already registered



commit b458df8680443636e3cf07659137f658ba979fb9
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Apr 27 11:06:09 2015 +0200

    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.

 src/applet.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index ba13cbb..fc5939a 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]