[Libreoffice-commits] core.git: vcl/source

Adrien Ollier (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 20 09:01:09 UTC 2020


 vcl/source/animate/Animation.cxx |   34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

New commits:
commit ec1c08a68e45306d455b9df0432b8e915d74d124
Author:     Adrien Ollier <adr.ollier at hotmail.fr>
AuthorDate: Sat Jan 18 20:30:43 2020 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jan 20 10:00:36 2020 +0100

    rewrite of Animation::Start using the STL
    
    Change-Id: Ieca520db4e3ea754dd8574809e366db11c451c2d
    Signed-off-by: Adrien Ollier <adr.ollier at hotmail.fr>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87031
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index e3fb37125af9..7326def3ba5d 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -169,28 +169,24 @@ bool Animation::Start(OutputDevice* pOut, const Point& rDestPt, const Size& rDes
         if ((pOut->GetOutDevType() == OUTDEV_WINDOW) && !mbLoopTerminated
             && (ANIMATION_TIMEOUT_ON_CLICK != maList[mnPos]->mnWait))
         {
-            ImplAnimView* pView;
-            ImplAnimView* pMatch = nullptr;
+            bool differs = true;
 
-            for (size_t i = 0; i < maViewList.size(); ++i)
+            auto itAnimView = std::find_if(
+                maViewList.begin(), maViewList.end(),
+                [pOut, nExtraData](const std::unique_ptr<ImplAnimView>& pAnimView) -> bool {
+                    return pAnimView->matches(pOut, nExtraData);
+                });
+
+            if (itAnimView != maViewList.end())
             {
-                pView = maViewList[i].get();
-                if (pView->matches(pOut, nExtraData))
+                if ((*itAnimView)->getOutPos() == rDestPt
+                    && (*itAnimView)->getOutSizePix() == pOut->LogicToPixel(rDestSz))
                 {
-                    if (pView->getOutPos() == rDestPt
-                        && pView->getOutSizePix() == pOut->LogicToPixel(rDestSz))
-                    {
-                        pView->repaint();
-                        pMatch = pView;
-                    }
-                    else
-                    {
-                        maViewList.erase(maViewList.begin() + i);
-                        pView = nullptr;
-                    }
-
-                    break;
+                    (*itAnimView)->repaint();
+                    differs = false;
                 }
+                else
+                    maViewList.erase(itAnimView);
             }
 
             if (maViewList.empty())
@@ -200,7 +196,7 @@ bool Animation::Start(OutputDevice* pOut, const Point& rDestPt, const Size& rDes
                 mnPos = 0;
             }
 
-            if (!pMatch)
+            if (differs)
                 maViewList.emplace_back(
                     new ImplAnimView(this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev));
 


More information about the Libreoffice-commits mailing list