Browse Source

Reinitialize on failure

Girish Ramakrishnan 8 years ago
parent
commit
d66513e4b8
1 changed files with 3 additions and 1 deletions
  1. 3 1
      qavahiservicepublisher.cpp

+ 3 - 1
qavahiservicepublisher.cpp

@@ -35,7 +35,6 @@ QAvahiServicePublisher::~QAvahiServicePublisher()
     uninitialize();
 }
 
-            
 void QAvahiServicePublisher::initialize()
 {
     const AvahiPoll *poll_api = avahi_qt_poll_get();
@@ -51,6 +50,7 @@ void QAvahiServicePublisher::uninitialize()
 {
     if (m_group) {
         avahi_entry_group_free(m_group);
+        m_group = 0;
     }
     if (m_client) {
         avahi_client_free(m_client);
@@ -134,6 +134,7 @@ void QAvahiServicePublisher::clientCallback(AvahiClient *client, AvahiClientStat
         m_errorString = avahi_strerror(avahi_client_errno(client));
         emit changeNotification(Error);
         uninitialize();
+        initialize();
         break;
     case AVAHI_CLIENT_CONNECTING:
         QAPDEBUG("Client is connecting");
@@ -187,6 +188,7 @@ void QAvahiServicePublisher::entryGroupCallback(AvahiEntryGroup *group, AvahiEnt
         m_errorString = avahi_strerror(m_error);
         emit changeNotification(Error);
         uninitialize();
+        initialize();
         return;
     case AVAHI_ENTRY_GROUP_REGISTERING:
         QAPDEBUG("Registring the group");