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