SurfaceFlinger: Ensure relatives are not detached with children.
A misapplication of traverseInZOrder...unfortunately we will have to watch
out for this. This code was also mistakenly accessing mDrawingState.
Test: Transaction_test.cpp
Change-Id: I6aa51885f52edff89f1ed5512408bf0a5a227af5
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 80987a4..22a72f2 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1661,17 +1661,14 @@
}
bool Layer::detachChildren() {
- traverseInZOrder(LayerVector::StateSet::Drawing, [this](Layer* child) {
- if (child == this) {
- return;
- }
-
+ for (const sp<Layer>& child : mCurrentChildren) {
sp<Client> parentClient = mClientRef.promote();
sp<Client> client(child->mClientRef.promote());
if (client != nullptr && parentClient != client) {
- client->detachLayer(child);
+ client->detachLayer(child.get());
+ child->detachChildren();
}
- });
+ }
return true;
}