fixed segfault on setup error
This commit is contained in:
parent
44d4029a32
commit
afd68b0285
@ -87,8 +87,11 @@ QHostAddress AvrConnection::hostAddress() const
|
|||||||
|
|
||||||
void AvrConnection::setHostAddress(const QHostAddress &hostAddress)
|
void AvrConnection::setHostAddress(const QHostAddress &hostAddress)
|
||||||
{
|
{
|
||||||
m_hostAddress = hostAddress;
|
if (!m_hostAddress.isEqual(hostAddress)) {
|
||||||
connectDevice();
|
disconnectDevice();
|
||||||
|
m_hostAddress = hostAddress;
|
||||||
|
connectDevice();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int AvrConnection::port() const
|
int AvrConnection::port() const
|
||||||
@ -98,8 +101,11 @@ int AvrConnection::port() const
|
|||||||
|
|
||||||
void AvrConnection::setPort(int port)
|
void AvrConnection::setPort(int port)
|
||||||
{
|
{
|
||||||
m_port = port;
|
if (m_port != port) {
|
||||||
connectDevice();
|
disconnectDevice();
|
||||||
|
m_port = port;
|
||||||
|
connectDevice();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvrConnection::connected()
|
bool AvrConnection::connected()
|
||||||
|
|||||||
@ -59,10 +59,10 @@ void IntegrationPluginDenon::init()
|
|||||||
foreach (Thing *thing, myThings().filterByThingClassId(AVRX1000ThingClassId)) {
|
foreach (Thing *thing, myThings().filterByThingClassId(AVRX1000ThingClassId)) {
|
||||||
|
|
||||||
if (entry.txt().contains("am=AVRX1000")) {
|
if (entry.txt().contains("am=AVRX1000")) {
|
||||||
QString thingId = thing->paramValue(AVRX1000ThingIdParamTypeId).toString();
|
QString existingId = thing->paramValue(AVRX1000ThingIdParamTypeId).toString();
|
||||||
QString id = entry.name().split("@").first();
|
QString discoveredId = entry.name().split("@").first();
|
||||||
QHostAddress address = entry.hostAddress();
|
QHostAddress address = entry.hostAddress();
|
||||||
if (thingId == id) {
|
if (existingId == discoveredId && m_avrConnections.contains(thing->id())) {
|
||||||
AvrConnection *avrConnection = m_avrConnections.value(thing->id());
|
AvrConnection *avrConnection = m_avrConnections.value(thing->id());
|
||||||
avrConnection->setHostAddress(address);
|
avrConnection->setHostAddress(address);
|
||||||
}
|
}
|
||||||
@ -753,16 +753,17 @@ void IntegrationPluginDenon::onAvrPlayBackModeChanged(AvrConnection::PlayBackMod
|
|||||||
|
|
||||||
void IntegrationPluginDenon::onAvrSocketError()
|
void IntegrationPluginDenon::onAvrSocketError()
|
||||||
{
|
{
|
||||||
AvrConnection *denonConnection = static_cast<AvrConnection *>(sender());
|
AvrConnection *avrConnection = static_cast<AvrConnection *>(sender());
|
||||||
|
|
||||||
// Check if setup running for this thing
|
// Check if setup running for this thing
|
||||||
if (m_asyncAvrSetups.contains(denonConnection)) {
|
if (m_asyncAvrSetups.contains(avrConnection)) {
|
||||||
ThingSetupInfo *info = m_asyncAvrSetups.take(denonConnection);
|
ThingSetupInfo *info = m_asyncAvrSetups.take(avrConnection);
|
||||||
|
m_avrConnections.remove(info->thing()->id());
|
||||||
qCWarning(dcDenon()) << "Could not add thing. The setup failed.";
|
qCWarning(dcDenon()) << "Could not add thing. The setup failed.";
|
||||||
info->finish(Thing::ThingErrorHardwareFailure);
|
info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
// Delete the connection, the thing will not be added and
|
// Delete the connection, the thing will not be added and
|
||||||
// the connection will be created in the next setup
|
// the connection will be created in the next setup
|
||||||
denonConnection->deleteLater();
|
avrConnection->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user