mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 04:24:28 +00:00
lottie: fix a data-race problem
make it sync call before accessing the composition data from marker and segments. issue: https://github.com/thorvg/thorvg/issues/2462
This commit is contained in:
parent
dcf67e9c14
commit
f3469350b9
1 changed files with 9 additions and 8 deletions
|
@ -269,7 +269,7 @@ Paint* LottieLoader::paint()
|
||||||
|
|
||||||
bool LottieLoader::override(const char* slot)
|
bool LottieLoader::override(const char* slot)
|
||||||
{
|
{
|
||||||
if (!comp) done();
|
done();
|
||||||
|
|
||||||
if (!comp || comp->slots.count == 0) return false;
|
if (!comp || comp->slots.count == 0) return false;
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ float LottieLoader::duration()
|
||||||
|
|
||||||
void LottieLoader::sync()
|
void LottieLoader::sync()
|
||||||
{
|
{
|
||||||
this->done();
|
done();
|
||||||
|
|
||||||
if (rebuild) run(0);
|
if (rebuild) run(0);
|
||||||
}
|
}
|
||||||
|
@ -369,15 +369,15 @@ void LottieLoader::sync()
|
||||||
|
|
||||||
uint32_t LottieLoader::markersCnt()
|
uint32_t LottieLoader::markersCnt()
|
||||||
{
|
{
|
||||||
if (!comp) done();
|
done();
|
||||||
if (!comp) return 0;
|
return comp ? comp->markers.count : 0;
|
||||||
return comp->markers.count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* LottieLoader::markers(uint32_t index)
|
const char* LottieLoader::markers(uint32_t index)
|
||||||
{
|
{
|
||||||
if (!comp) done();
|
done();
|
||||||
|
|
||||||
if (!comp || index >= comp->markers.count) return nullptr;
|
if (!comp || index >= comp->markers.count) return nullptr;
|
||||||
auto marker = comp->markers.begin() + index;
|
auto marker = comp->markers.begin() + index;
|
||||||
return (*marker)->name;
|
return (*marker)->name;
|
||||||
|
@ -386,9 +386,10 @@ const char* LottieLoader::markers(uint32_t index)
|
||||||
|
|
||||||
bool LottieLoader::segment(const char* marker, float& begin, float& end)
|
bool LottieLoader::segment(const char* marker, float& begin, float& end)
|
||||||
{
|
{
|
||||||
if (!comp) done();
|
done();
|
||||||
|
|
||||||
if (!comp) return false;
|
if (!comp) return false;
|
||||||
|
|
||||||
for (auto m = comp->markers.begin(); m < comp->markers.end(); ++m) {
|
for (auto m = comp->markers.begin(); m < comp->markers.end(); ++m) {
|
||||||
if (!strcmp(marker, (*m)->name)) {
|
if (!strcmp(marker, (*m)->name)) {
|
||||||
begin = (*m)->time / frameCnt;
|
begin = (*m)->time / frameCnt;
|
||||||
|
|
Loading…
Add table
Reference in a new issue