[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sd/source

Bryan Quigley gquigs at gmail.com
Fri Aug 8 13:22:11 PDT 2014


 sd/source/ui/remotecontrol/AvahiNetworkService.cxx |   28 +++++++++++++--------
 1 file changed, 18 insertions(+), 10 deletions(-)

New commits:
commit 8de2e9b4bc53e6c097897142bad223c100d36292
Author: Bryan Quigley <gquigs at gmail.com>
Date:   Mon Aug 4 12:26:00 2014 -0400

    fdo#81552 Fail nicely if avahi doesn't let libreoffice publish items
    
    Needed some minor changes for 4-2.
    
    Reviewed-on: https://gerrit.libreoffice.org/10735
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 3c57701cf0a169bd8d1893d1b2271d48b8072147)
    
    Change-Id: Ie264a032a71bda336158e18bd2b14c569f23f42d
    Reviewed-on: https://gerrit.libreoffice.org/10822
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
index 04d8e57..43ee31b 100644
--- a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
+++ b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
@@ -35,7 +35,7 @@ static AvahiThreadedPoll *threaded_poll = NULL;
 static AvahiEntryGroup *group = NULL;
 static AvahiNetworkService *avahiService = NULL;
 
-static void create_services(AvahiClient *c);
+static bool create_services(AvahiClient *c);
 
 static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
     assert(g == group || group == NULL);
@@ -78,16 +78,19 @@ static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state,
     }
 }
 
-static void create_services(AvahiClient *c) {
+static bool create_services(AvahiClient *c) {
     assert(c);
 
     /* If this is the first time we're called, let's create a new
      * entry group if necessary */
+    if(!client)
+        return false;
 
     if (!group)
         if (!(group = avahi_entry_group_new(c, entry_group_callback, NULL))) {
             fprintf(stderr, "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_client_errno(c)));
             avahiService->clear();
+            return false;
         }
 
     /* If the group is empty (either because it was just created, or
@@ -113,22 +116,23 @@ static void create_services(AvahiClient *c) {
 
                 avahi_entry_group_reset(group);
 
-                create_services(c);
-                return;
+                return create_services(c);
             }
 
             fprintf(stderr, "Failed to add _impressremote._tcp service: %s\n", avahi_strerror(ret));
             avahiService->clear();
+            return false;
         }
 
         /* Tell the server to register the service */
         if ((ret = avahi_entry_group_commit(group)) < 0) {
             fprintf(stderr, "Failed to commit entry group: %s\n", avahi_strerror(ret));
             avahiService->clear();
+            return false;
         }
     }
 
-    return;
+    return true; //Services we're already created
 }
 
 static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) {
@@ -174,7 +178,8 @@ void AvahiNetworkService::setup() {
      return;
    }
 
-   create_services(client);
+   if(!create_services(client))
+        return;
 
    /* Finally, start the event loop thread */
    if (avahi_threaded_poll_start(threaded_poll) < 0) {
@@ -184,8 +189,11 @@ void AvahiNetworkService::setup() {
 }
 
 void AvahiNetworkService::clear() {
-  /* Call this when the app shuts down */
-  avahi_threaded_poll_stop(threaded_poll);
-  avahi_client_free(client);
-  avahi_threaded_poll_free(threaded_poll);
+    /* Call this when the app shuts down */
+        if(threaded_poll)
+            avahi_threaded_poll_stop(threaded_poll);
+        if(client)
+            avahi_client_free(client);
+        if(threaded_poll)
+            avahi_threaded_poll_free(threaded_poll);
 }


More information about the Libreoffice-commits mailing list