[Libreoffice-commits] core.git: vcl/source
Adrien Ollier (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 21 18:45:45 UTC 2020
vcl/source/animate/Animation.cxx | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
New commits:
commit e03abf9f97a251174dbb81445fbd5f66ae695cd4
Author: Adrien Ollier <adr.ollier at hotmail.fr>
AuthorDate: Sat Jan 18 17:46:25 2020 +0100
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Jan 21 19:45:12 2020 +0100
rework ImplAnimView cleanup using STL algorithms
Change-Id: Ie8c857f992d27bb0d70968256eea5d8f2491405e
Signed-off-by: Adrien Ollier <adr.ollier at hotmail.fr>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87030
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
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())
More information about the Libreoffice-commits
mailing list