From 573a2c061ab09379f262dfd1d3ca4a8ed6a251f2 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 17 Jun 2020 15:19:27 +0200 Subject: [PATCH] Don't call thingRemoved() on the plugin in case of reconfiguring Reasoning: a) Currently, the API behaves inconsistently. While reconfiguring a "justAdd" thing, it did call thingRemoved, however, reconfiguring a thing that uses pairing did not. b) The old implementation did not consider childs. Reconfiguring a justAdd thing which has childs was calling thingRemoved on the parent only but not its childs. c) If we'd fix this by calling thingRemoved() for all flows and childs we'd end up in hells kitchen as we can't know about the new state of childs after the reconfiguration, so we can't just automatically add all the childs back ourselves, the plugin needs to do that. This in turn would mean that childs would get new ids which then breaks rules and stuff. So the conclusion has been to just re-run the setup and the plugin implementation is in charge for then checking the existing childs and calling autoThingDisappeared() as needed. WARNING: This also implies that we need to fix some plugins which currently rely on thingRemoved to be called for reconfiguration and might create duplicate connections or similar now. --- libnymea-core/integrations/thingmanagerimplementation.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/libnymea-core/integrations/thingmanagerimplementation.cpp b/libnymea-core/integrations/thingmanagerimplementation.cpp index 62c1c304..86c3b82f 100644 --- a/libnymea-core/integrations/thingmanagerimplementation.cpp +++ b/libnymea-core/integrations/thingmanagerimplementation.cpp @@ -402,9 +402,6 @@ ThingSetupInfo *ThingManagerImplementation::reconfigureThingInternal(Thing *thin } ParamList finalParams = buildParams(thing->thingClass().paramTypes(), params); - // first remove the thing in the plugin - plugin->thingRemoved(thing); - // mark setup as incomplete thing->setSetupStatus(Thing::ThingSetupStatusInProgress, Thing::ThingErrorNoError);