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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu May 27 18:02:38 UTC 2021


 vcl/source/gdi/impanmvw.cxx      |    8 ++++++--
 vcl/source/treelist/transfer.cxx |   16 ++++++++--------
 2 files changed, 14 insertions(+), 10 deletions(-)

New commits:
commit fd7787b6f0f082db320ebe7b29fc5333587b5d2e
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 27 15:21:58 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu May 27 20:02:00 2021 +0200

    no need to allocate these on the heap
    
    Change-Id: I0740f7194c589d6949a816f365cd54403be72118
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116260
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx
index b7329c073ef1..5757d3d36e5c 100644
--- a/vcl/source/gdi/impanmvw.cxx
+++ b/vcl/source/gdi/impanmvw.cxx
@@ -151,7 +151,9 @@ void ImplAnimView::drawToPos( sal_uLong nPos )
     }
 
     ScopedVclPtrInstance<VirtualDevice> aVDev;
-    std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( pRenderContext->GetClipRegion() ) : nullptr);
+    std::optional<vcl::Region> xOldClip;
+    if (!maClip.IsNull())
+        xOldClip = pRenderContext->GetClipRegion();
 
     aVDev->SetOutputSizePixel( maSzPix, false );
     nPos = std::min( nPos, static_cast<sal_uLong>(mpParent->Count()) - 1 );
@@ -270,7 +272,9 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev )
 
         if( !pVDev )
         {
-            std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( pRenderContext->GetClipRegion() ) : nullptr);
+            std::optional<vcl::Region> xOldClip;
+            if (!maClip.IsNull())
+                xOldClip = pRenderContext->GetClipRegion();
 
             if (xOldClip)
                 pRenderContext->SetClipRegion( maClip );
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 5f57a7ff07b6..a917973e1122 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -332,11 +332,11 @@ Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, co
 
                     if( maAny >>= aSeq )
                     {
-                        std::unique_ptr<SvMemoryStream> pSrcStm(new SvMemoryStream( aSeq.getArray(), aSeq.getLength(), StreamMode::WRITE | StreamMode::TRUNC ));
                         GDIMetaFile     aMtf;
-
-                        ReadGDIMetaFile( *pSrcStm, aMtf );
-                        pSrcStm.reset();
+                        {
+                            SvMemoryStream aSrcStm( aSeq.getArray(), aSeq.getLength(), StreamMode::WRITE | StreamMode::TRUNC );
+                            ReadGDIMetaFile( aSrcStm, aMtf );
+                        }
 
                         Graphic         aGraphic( aMtf );
                         SvMemoryStream  aDstStm( 65535, 65535 );
@@ -362,11 +362,11 @@ Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, co
 
                     if( maAny >>= aSeq )
                     {
-                        std::unique_ptr<SvMemoryStream> pSrcStm(new SvMemoryStream( aSeq.getArray(), aSeq.getLength(), StreamMode::WRITE | StreamMode::TRUNC ));
                         GDIMetaFile     aMtf;
-
-                        ReadGDIMetaFile( *pSrcStm, aMtf );
-                        pSrcStm.reset();
+                        {
+                            SvMemoryStream aSrcStm( aSeq.getArray(), aSeq.getLength(), StreamMode::WRITE | StreamMode::TRUNC );
+                            ReadGDIMetaFile( aSrcStm, aMtf );
+                        }
 
                         SvMemoryStream  aDstStm( 65535, 65535 );
 


More information about the Libreoffice-commits mailing list