Skip to content

Commit

Permalink
Avahi Client - fix crashing is avahi daemon is not running.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbagg committed May 6, 2023
1 parent 7b066b1 commit 473d852
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions avahiclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ QZeroConf::~QZeroConf()

void QZeroConf::startServicePublish(const char *name, const char *type, const char *domain, quint16 port, quint32 interface)
{
if (pri->group) {
if (!pri->client || pri->group) { // check client is ok (avahi daemon is running) and group is not already configured
emit error(QZeroConf::serviceRegistrationFailed);
return;
}
Expand Down Expand Up @@ -295,8 +295,10 @@ void QZeroConf::clearServiceTxtRecords()

void QZeroConf::startBrowser(QString type, QAbstractSocket::NetworkLayerProtocol protocol)
{
if (pri->browser)
if (!pri->client || pri->browser) { // check client is ok (avahi daemon is running) and browser is not already started
emit error(QZeroConf::browserFailed);
return;
}

switch (protocol) {
case QAbstractSocket::IPv4Protocol: pri->aProtocol = AVAHI_PROTO_INET; break;
Expand Down

0 comments on commit 473d852

Please sign in to comment.