[Libreoffice-commits] .: 3 commits - canvas/source slideshow/source

Thorsten Behrens thorsten at kemper.freedesktop.org
Mon Jan 9 09:39:19 PST 2012


 canvas/source/directx/dx_impltools.cxx                       |    4 -
 canvas/source/tools/spriteredrawmanager.cxx                  |   31 +++++------
 canvas/source/vcl/textlayout.cxx                             |    4 -
 slideshow/source/engine/animationnodes/basecontainernode.cxx |    3 -
 slideshow/source/engine/eventmultiplexer.cxx                 |    4 -
 slideshow/source/engine/tools.cxx                            |    2 
 6 files changed, 23 insertions(+), 25 deletions(-)

New commits:
commit 53ec7e3b2c1e0fdcd72c30a36ede77319bab4969
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Mon Jan 9 18:35:27 2012 +0100

    Avoid pointless const_cast, use getConstArray in all cases.
    
    Another code-review follow-up fix from fdo#44533 - don't use
    Sequence::getArray, that tends to create a new copy everytime you
    call.

diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx
index 946a9b2..63bcabe 100644
--- a/canvas/source/directx/dx_impltools.cxx
+++ b/canvas/source/directx/dx_impltools.cxx
@@ -452,8 +452,8 @@ namespace dxcanvas
                     // TODO(F1): Closed/open polygons
 
                     // convert from RealPoint2D array to Gdiplus::PointF array
-                    ::std::transform( const_cast< uno::Sequence< geometry::RealPoint2D >& >(points[nCurrPoly]).getArray(),
-                                      const_cast< uno::Sequence< geometry::RealPoint2D >& >(points[nCurrPoly]).getArray()+nCurrSize,
+                    ::std::transform( points[nCurrPoly].getConstArray(),
+                                      points[nCurrPoly].getConstArray()+nCurrSize,
                                       aPoints.begin(),
                                       implGdiPlusPointFromRealPoint2D );
 
diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx
index 89711e5..4dd036f 100644
--- a/canvas/source/vcl/textlayout.cxx
+++ b/canvas/source/vcl/textlayout.cxx
@@ -465,8 +465,8 @@ namespace vclcanvas
                                                      renderState);
 
         // fill integer offsets
-        ::std::transform( const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray(),
-                          const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray()+inputOffsets.getLength(),
+        ::std::transform( inputOffsets.getConstArray(),
+                          inputOffsets.getConstArray()+inputOffsets.getLength(),
                           outputOffsets,
                           OffsetTransformer( aMatrix ) );
     }
commit c85142eb63c61de68aa7dbb10b2bcb8b48b870f9
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Mon Jan 9 18:04:58 2012 +0100

    Fix more incorrect iterator re-use.
    
    Follow-up fix for 540963d879296ef81f883305057e63465b2ff586
    std::algos use iterator arguments by value, and may change them.

diff --git a/canvas/source/tools/spriteredrawmanager.cxx b/canvas/source/tools/spriteredrawmanager.cxx
index 25accbe..2af5b34 100644
--- a/canvas/source/tools/spriteredrawmanager.cxx
+++ b/canvas/source/tools/spriteredrawmanager.cxx
@@ -412,16 +412,11 @@ namespace canvas
         if( nNumSprites > 3 || nNumSprites < 1 )
             return false;
 
-        const SpriteConnectedRanges::ComponentListType::const_iterator aBegin(
-            rUpdateArea.maComponentList.begin() );
-        const SpriteConnectedRanges::ComponentListType::const_iterator aEnd(
-            rUpdateArea.maComponentList.end() );
-
         // now, calc the _true_ update area, by merging all sprite's
         // true update areas into one rectangle
-        ::basegfx::B2DRange aTrueArea( aBegin->second.getUpdateArea() );
-        ::std::for_each( aBegin,
-                         aEnd,
+        ::basegfx::B2DRange aTrueArea( rUpdateArea.maComponentList.begin()->second.getUpdateArea() );
+        ::std::for_each( rUpdateArea.maComponentList.begin(),
+                         rUpdateArea.maComponentList.end(),
                          ::boost::bind( (void (basegfx::B2DRange::*)(const basegfx::B2DRange&))(
                                             &basegfx::B2DRange::expand),
                                         aTrueArea,
@@ -429,9 +424,12 @@ namespace canvas
                                                        ::boost::bind( ::o3tl::select2nd<AreaComponent>(),
                                                                       _1 ) ) ) );
 
+        const SpriteConnectedRanges::ComponentListType::const_iterator aEnd(
+            rUpdateArea.maComponentList.end() );
+
         // and check whether _any_ of the sprites tells that its area
         // update will not be opaque.
-        return (::std::find_if( aBegin,
+        return (::std::find_if( rUpdateArea.maComponentList.begin(),
                                 aEnd,
                                 ::boost::bind( &SpriteRedrawManager::isAreaUpdateNotOpaque,
                                                this,
diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx
index bf00001..fd81654 100644
--- a/slideshow/source/engine/animationnodes/basecontainernode.cxx
+++ b/slideshow/source/engine/animationnodes/basecontainernode.cxx
@@ -113,10 +113,9 @@ void BaseContainerNode::appendChildNode( AnimationNodeSharedPtr const& pNode )
 bool BaseContainerNode::isChildNode( AnimationNodeSharedPtr const& pNode ) const
 {
     // find given notifier in child vector
-    VectorOfNodes::const_iterator const iBegin( maChildren.begin() );
     VectorOfNodes::const_iterator const iEnd( maChildren.end() );
     VectorOfNodes::const_iterator const iFind(
-        std::find( iBegin, iEnd, pNode ) );
+        std::find( maChildren.begin(), iEnd, pNode ) );
     return (iFind != iEnd);
 }
 
diff --git a/slideshow/source/engine/eventmultiplexer.cxx b/slideshow/source/engine/eventmultiplexer.cxx
index 8bb0f08..d162718 100644
--- a/slideshow/source/engine/eventmultiplexer.cxx
+++ b/slideshow/source/engine/eventmultiplexer.cxx
@@ -617,10 +617,10 @@ bool EventMultiplexerImpl::notifyMouseHandlers(
     // find corresponding view (to map mouse position into user
     // coordinate space)
     UnoViewVector::const_iterator       aIter;
-    const UnoViewVector::const_iterator aBegin( mrViewContainer.begin() );
     const UnoViewVector::const_iterator aEnd  ( mrViewContainer.end() );
     if( (aIter=::std::find_if(
-             aBegin, aEnd,
+             mrViewContainer.begin(),
+             aEnd,
              boost::bind( std::equal_to< uno::Reference<
                           presentation::XSlideShowView > >(),
                           boost::cref( xView ),
diff --git a/slideshow/source/engine/tools.cxx b/slideshow/source/engine/tools.cxx
index e36f4ee..7dabb90 100644
--- a/slideshow/source/engine/tools.cxx
+++ b/slideshow/source/engine/tools.cxx
@@ -472,7 +472,7 @@ namespace slideshow
                                                               pArray + nLen,
                                                               NamedValueComparator( rSearchKey ) );
 
-            if( pFound == pArray + nLen )
+            if( pFound == rSequence.getConstArray() + nLen )
                 return false;
 
             return true;
commit 540963d879296ef81f883305057e63465b2ff586
Author: julien2412 <serval2412 at yahoo.fr>
Date:   Mon Jan 9 18:03:11 2012 +0100

    Fix crash when play particular presentation with sound
    
    This fixes fdo#44533.

diff --git a/canvas/source/tools/spriteredrawmanager.cxx b/canvas/source/tools/spriteredrawmanager.cxx
index af2c279..25accbe 100644
--- a/canvas/source/tools/spriteredrawmanager.cxx
+++ b/canvas/source/tools/spriteredrawmanager.cxx
@@ -271,18 +271,18 @@ namespace canvas
             ++aCurrRecord;
         }
 
-        VectorOfSprites::iterator aBegin( aUpdatableSprites.begin() );
-        VectorOfSprites::iterator aEnd  ( aUpdatableSprites.end() );
-        ::std::sort( aBegin,
-                     aEnd,
+        ::std::sort( aUpdatableSprites.begin(),
+                     aUpdatableSprites.end(),
                      aSpriteComparator );
 
-        aEnd = ::std::unique( aBegin, aEnd );
+        VectorOfSprites::iterator aEnd=
+            ::std::unique( aUpdatableSprites.begin(),
+                           aUpdatableSprites.end() );
 
         // for each unique sprite, check the change event vector,
         // calculate the update operation from that, and add the
         // result to the aUpdateArea.
-        ::std::for_each( aBegin,
+        ::std::for_each( aUpdatableSprites.begin(),
                          aEnd,
                          SpriteUpdater( rUpdateAreas,
                                         maChangeRecords) );
@@ -298,7 +298,8 @@ namespace canvas
         VectorOfSprites aUnchangedSprites;
         ::std::set_difference( aSortedSpriteVector.begin(),
                                aSortedSpriteVector.end(),
-                               aBegin, aEnd,
+                               aUpdatableSprites.begin(),
+                               aEnd,
                                ::std::back_insert_iterator< VectorOfSprites >(aUnchangedSprites) );
 
         // add each remaining unchanged sprite to connected ranges,


More information about the Libreoffice-commits mailing list