fix crash if a JsonReply times out but we still get a result afterwards
This commit is contained in:
parent
028b21fcb8
commit
1451ba9a46
@ -1170,6 +1170,10 @@ void DeviceManager::startMonitoringAutoDevices()
|
||||
void DeviceManager::slotDevicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors)
|
||||
{
|
||||
DevicePlugin *plugin = static_cast<DevicePlugin*>(sender());
|
||||
if (!m_discoveringPlugins.contains(plugin)) {
|
||||
qWarning(dcDeviceManager()) << "Received a devicesDiscovered signal from" << plugin->pluginName() << "but did not expect it. Ignoring.";
|
||||
return;
|
||||
}
|
||||
m_discoveringPlugins.removeOne(plugin);
|
||||
|
||||
foreach (const DeviceDescriptor &descriptor, deviceDescriptors) {
|
||||
|
||||
@ -83,7 +83,9 @@ JsonReply* ActionHandler::ExecuteAction(const QVariantMap ¶ms)
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->executeAction(action);
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
JsonReply *reply = createAsyncReply("ExecuteAction");
|
||||
m_asyncActionExecutions.insert(action.id(), reply);
|
||||
ActionId id = action.id();
|
||||
connect(reply, &JsonReply::finished, [this, id](){ m_asyncActionExecutions.remove(id); });
|
||||
m_asyncActionExecutions.insert(id, reply);
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
||||
@ -336,6 +336,7 @@ JsonReply *DeviceHandler::GetDiscoveredDevices(const QVariantMap ¶ms) const
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(deviceClassId, discoveryParams);
|
||||
if (status == DeviceManager::DeviceErrorAsync ) {
|
||||
JsonReply *reply = createAsyncReply("GetDiscoveredDevices");
|
||||
connect(reply, &JsonReply::finished, [this, deviceClassId](){ m_discoverRequests.remove(deviceClassId); });
|
||||
m_discoverRequests.insert(deviceClassId, reply);
|
||||
return reply;
|
||||
}
|
||||
@ -398,6 +399,7 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
||||
switch (status) {
|
||||
case DeviceManager::DeviceErrorAsync: {
|
||||
JsonReply *asyncReply = createAsyncReply("AddConfiguredDevice");
|
||||
connect(asyncReply, &JsonReply::finished, [this, newDeviceId](){ m_asynDeviceAdditions.remove(newDeviceId); });
|
||||
m_asynDeviceAdditions.insert(newDeviceId, asyncReply);
|
||||
return asyncReply;
|
||||
}
|
||||
@ -446,6 +448,7 @@ JsonReply *DeviceHandler::ConfirmPairing(const QVariantMap ¶ms)
|
||||
JsonReply *reply = 0;
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
reply = createAsyncReply("ConfirmPairing");
|
||||
connect(reply, &JsonReply::finished, [this, pairingTransactionId](){ m_asyncPairingRequests.remove(pairingTransactionId); });
|
||||
m_asyncPairingRequests.insert(pairingTransactionId, reply);
|
||||
return reply;
|
||||
}
|
||||
@ -492,6 +495,7 @@ JsonReply *DeviceHandler::ReconfigureDevice(const QVariantMap ¶ms)
|
||||
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
JsonReply *asyncReply = createAsyncReply("ReconfigureDevice");
|
||||
connect(asyncReply, &JsonReply::finished, [this, deviceId](){ m_asynDeviceEditAdditions.remove(deviceId); });
|
||||
m_asynDeviceEditAdditions.insert(deviceId, asyncReply);
|
||||
return asyncReply;
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ void JsonReply::setCommandId(int commandId)
|
||||
m_commandId = commandId;
|
||||
}
|
||||
|
||||
/*! Start the timeout timer for this \l{JsonReply}. The default timeout is 10 seconds. */
|
||||
/*! Start the timeout timer for this \l{JsonReply}. The default timeout is 15 seconds. */
|
||||
void JsonReply::startWait()
|
||||
{
|
||||
m_timeout.start(15000);
|
||||
|
||||
Reference in New Issue
Block a user