mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +00:00
Check for layer parent-child cycles.
This commit is contained in:
parent
d08a03b650
commit
ba6b92f341
@ -69,6 +69,16 @@ static bool strokeProp(rlottie::Property prop)
|
||||
}
|
||||
}
|
||||
|
||||
static bool isGoodParentLayer(LOTLayerItem *parent, LOTLayerItem *child) {
|
||||
do {
|
||||
if (parent == child) {
|
||||
return false;
|
||||
}
|
||||
parent = parent->resolvedParentLayer();
|
||||
} while (parent);
|
||||
return true;
|
||||
}
|
||||
|
||||
LOTCompItem::LOTCompItem(LOTModel *model)
|
||||
: mCurFrameNo(-1)
|
||||
{
|
||||
@ -520,7 +530,10 @@ LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
|
||||
auto search =
|
||||
std::find_if(mLayers.begin(), mLayers.end(),
|
||||
[id](const auto &val) { return val->id() == id; });
|
||||
if (search != mLayers.end()) layer->setParentLayer((*search).get());
|
||||
if (search != mLayers.end() &&
|
||||
isGoodParentLayer((*search).get(), layer.get())) {
|
||||
layer->setParentLayer((*search).get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -107,6 +107,7 @@ public:
|
||||
int id() const {return mLayerData->id();}
|
||||
int parentId() const {return mLayerData->parentId();}
|
||||
void setParentLayer(LOTLayerItem *parent){mParentLayer = parent;}
|
||||
LOTLayerItem *resolvedParentLayer() const {return mParentLayer;}
|
||||
void setComplexContent(bool value) { mComplexContent = value;}
|
||||
bool complexContent() const {return mComplexContent;}
|
||||
virtual void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user