From f0e95ee933d1caf74b790fc85d34212dd3dd2229 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Dec 2019 13:48:16 +0300 Subject: [PATCH] Fix possible assertion violation in animations shutdown. --- ui/effects/animations.cpp | 7 +++++++ ui/effects/animations.h | 1 + 2 files changed, 8 insertions(+) diff --git a/ui/effects/animations.cpp b/ui/effects/animations.cpp index 874f07e..426a085 100644 --- a/ui/effects/animations.cpp +++ b/ui/effects/animations.cpp @@ -113,6 +113,7 @@ void Manager::stop(not_null animation) { const auto i = ranges::find(_active, value, proj); if (i != end(_active)) { *i = nullptr; + _removedWhileUpdating = true; } } else if (empty(_active)) { stopTimer(); @@ -138,6 +139,12 @@ void Manager::update() { }; _active.erase(ranges::remove_if(_active, isFinished), end(_active)); + if (_removedWhileUpdating) { + _removedWhileUpdating = false; + const auto proj = &ActiveBasicPointer::get; + _active.erase(ranges::remove(_active, nullptr, proj), end(_active)); + } + if (!empty(_starting)) { _active.insert( end(_active), diff --git a/ui/effects/animations.h b/ui/effects/animations.h index 41665c3..c7eabf6 100644 --- a/ui/effects/animations.h +++ b/ui/effects/animations.h @@ -198,6 +198,7 @@ private: crl::time _lastUpdateTime = 0; int _timerId = 0; bool _updating = false; + bool _removedWhileUpdating = false; bool _scheduled = false; bool _forceImmediateUpdate = false; std::vector _active;