Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/lottie/lottieitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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)
{
Expand Down Expand Up @@ -435,7 +445,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());
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/lottie/lottieitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class LOTLayerItem
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);
Expand Down