Merge "SurfaceFlinger: Fix destruction of relatively Z-ordered layers." into oc-dev am: edcc0c28f4
am: 6fa90b1577
Change-Id: Iaf67f4476864bf9d1a012991be366186706b9be4
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 15accc8..6b09df2 100755
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -287,6 +287,14 @@
// the layer has been remove from the current state list (and just before
// it's removed from the drawing state list)
void Layer::onRemoved() {
+ if (mCurrentState.zOrderRelativeOf != nullptr) {
+ sp<Layer> strongRelative = mCurrentState.zOrderRelativeOf.promote();
+ if (strongRelative != nullptr) {
+ strongRelative->removeZOrderRelative(this);
+ }
+ mCurrentState.zOrderRelativeOf = nullptr;
+ }
+
mSurfaceFlingerConsumer->abandon();
for (const auto& child : mCurrentChildren) {
child->onRemoved();
@@ -2555,11 +2563,6 @@
sp<Layer> strongRelative = weakRelative.promote();
if (strongRelative != nullptr) {
traverse.add(strongRelative);
- } else {
- // We need to erase from current state instead of drawing
- // state so we don't overwrite when copying
- // the current state to the drawing state.
- mCurrentState.zOrderRelatives.remove(weakRelative);
}
}