summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorAdrien Ollier <adr.ollier@hotmail.fr>2020-01-18 17:46:25 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2020-01-21 19:45:12 +0100
commite03abf9f97a251174dbb81445fbd5f66ae695cd4 (patch)
tree19766b82e7d4475321ae262e212e5cc2dd103cc5 /vcl
parent671adb82426fa8b880e5b8208bb753b36dd1c6e0 (diff)
rework ImplAnimView cleanup using STL algorithms
Change-Id: Ie8c857f992d27bb0d70968256eea5d8f2491405e Signed-off-by: Adrien Ollier <adr.ollier@hotmail.fr> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87030 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/animate/Animation.cxx35
1 files changed, 14 insertions, 21 deletions
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index 7326def3ba5d..80115aa730ce 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -279,8 +279,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
if (nAnimCount)
{
- ImplAnimView* pView;
- bool bGlobalPause = true;
+ bool bGlobalPause = false;
if (maNotifyLink.IsSet())
{
@@ -294,6 +293,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
// set view state from AInfo structure
for (auto& pAInfo : aAInfoList)
{
+ ImplAnimView* pView = nullptr;
if (!pAInfo->pViewData)
{
pView = new ImplAnimView(this, pAInfo->pOutDev, pAInfo->aStartOrg,
@@ -308,26 +308,19 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
pView->setMarked(true);
}
- // delete all unmarked views and reset marked state
- for (size_t i = 0; i < maViewList.size();)
- {
- pView = maViewList[i].get();
- if (!pView->isMarked())
- {
- maViewList.erase(maViewList.begin() + i);
- }
- else
- {
- if (!pView->isPause())
- bGlobalPause = false;
+ // delete all unmarked views
+ auto removeStart = std::remove_if(maViewList.begin(), maViewList.end(),
+ [](const auto& pView) { return !pView->isMarked(); });
+ maViewList.erase(removeStart, maViewList.cend());
- pView->setMarked(false);
- i++;
- }
- }
+ // check if every remaining view is paused
+ bGlobalPause = std::all_of(maViewList.cbegin(), maViewList.cend(),
+ [](const auto& pView) { return pView->isPause(); });
+
+ // reset marked state
+ std::for_each(maViewList.cbegin(), maViewList.cend(),
+ [](const auto& pView) { pView->setMarked(false); });
}
- else
- bGlobalPause = false;
if (maViewList.empty())
Stop();
@@ -363,7 +356,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
// set from view itself
for (size_t i = 0; i < maViewList.size();)
{
- pView = maViewList[i].get();
+ ImplAnimView* pView = maViewList[i].get();
pView->draw(mnPos);
if (pView->isMarked())