From 47920220a29e8e00fa8879c7efb1eaa64e598e17 Mon Sep 17 00:00:00 2001 From: mpbreton-silabs <107145920+mpbreton-silabs@users.noreply.github.com> Date: Tue, 15 Aug 2023 17:16:19 -0400 Subject: [PATCH] Validate if the Current Group = RemovedGroup before invalidating scene (#28565) * Validate if the Current Group = RemovedGroup or check if CurrentScene is in RemovedGroup before invalidating the scene. * Fix nonsensical code * ditto * ditto bis * restyle * Remove check that was not specification compliant * Cleanup * Update src/app/clusters/scenes-server/scenes-server.cpp Co-authored-by: Boris Zbarsky --------- Co-authored-by: Boris Zbarsky --- src/app/clusters/scenes-server/scenes-server.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index e0398563982352..1c89884f687246 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -510,7 +510,15 @@ void ScenesServer::GroupWillBeRemoved(FabricIndex aFabricIx, EndpointId aEndpoin SceneTable * sceneTable = scenes::GetSceneTableImpl(aEndpointId); VerifyOrReturn(nullptr != sceneTable); - MakeSceneInvalid(aEndpointId); + chip::GroupId currentGroup; + Attributes::CurrentGroup::Get(aEndpointId, ¤tGroup); + + // If currentGroup is what is being removed, we can't possibly still have a valid scene, + // because the scene we have (if any) will also be removed. + if (aGroupId == currentGroup) + { + MakeSceneInvalid(aEndpointId); + } VerifyOrReturn(nullptr != mGroupProvider); if (0 != aGroupId && !mGroupProvider->HasEndpoint(aFabricIx, aGroupId, aEndpointId))