Merge PR #142: Fix TimeDescriptors getting lost when updating a rule

pull/152/head
Jenkins 2019-04-12 13:42:30 +02:00
commit c442eb3592
2 changed files with 7 additions and 4 deletions

View File

@ -251,12 +251,13 @@ void NymeaCore::destroy()
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicyList. */ /*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicyList. */
QPair<DeviceManager::DeviceError, QList<RuleId> > NymeaCore::removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList) QPair<DeviceManager::DeviceError, QList<RuleId> > NymeaCore::removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList)
{ {
// Check if this is a child device
Device *device = m_deviceManager->findConfiguredDevice(deviceId); Device *device = m_deviceManager->findConfiguredDevice(deviceId);
if (!device) if (!device) {
return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorDeviceNotFound, QList<RuleId>()); return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorDeviceNotFound, QList<RuleId>());
}
// Check if this is a child device
if (!device->parentId().isNull()) { if (!device->parentId().isNull()) {
qCWarning(dcDeviceManager) << "The device is a child of" << device->parentId().toString() << ". Please remove the parent device."; qCWarning(dcDeviceManager) << "The device is a child of" << device->parentId().toString() << ". Please remove the parent device.";
return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorDeviceIsChild, QList<RuleId>()); return QPair<DeviceManager::DeviceError, QList<RuleId> > (DeviceManager::DeviceErrorDeviceIsChild, QList<RuleId>());
@ -347,12 +348,13 @@ QPair<DeviceManager::DeviceError, QList<RuleId> > NymeaCore::removeConfiguredDev
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicy. */ /*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicy. */
DeviceManager::DeviceError NymeaCore::removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy) DeviceManager::DeviceError NymeaCore::removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy)
{ {
// Check if this is a child device
Device *device = m_deviceManager->findConfiguredDevice(deviceId); Device *device = m_deviceManager->findConfiguredDevice(deviceId);
if (!device) if (!device) {
return DeviceManager::DeviceErrorDeviceNotFound; return DeviceManager::DeviceErrorDeviceNotFound;
}
// Check if this is a child device
if (!device->parentId().isNull()) { if (!device->parentId().isNull()) {
qCWarning(dcDeviceManager) << "The device is a child of" << device->parentId().toString() << ". Please remove the parent device."; qCWarning(dcDeviceManager) << "The device is a child of" << device->parentId().toString() << ". Please remove the parent device.";
return DeviceManager::DeviceErrorDeviceIsChild; return DeviceManager::DeviceErrorDeviceIsChild;

View File

@ -903,6 +903,7 @@ void RuleEngine::removeDeviceFromRule(const RuleId &id, const DeviceId &deviceId
newRule.setName(rule.name()); newRule.setName(rule.name());
newRule.setEventDescriptors(eventDescriptors); newRule.setEventDescriptors(eventDescriptors);
newRule.setStateEvaluator(stateEvalatuator); newRule.setStateEvaluator(stateEvalatuator);
newRule.setTimeDescriptor(rule.timeDescriptor());
newRule.setActions(actions); newRule.setActions(actions);
newRule.setExitActions(exitActions); newRule.setExitActions(exitActions);
m_rules[id] = newRule; m_rules[id] = newRule;