[Libreoffice-commits] core.git: 5 commits - include/svx svx/source sw/source vcl/source

Caolán McNamara caolanm at redhat.com
Thu Jun 15 11:44:45 UTC 2017


 include/svx/xbtmpit.hxx          |    2 ++
 svx/source/xoutdev/xattrbmp.cxx  |   26 ++++++++++++++++----------
 sw/source/filter/ww8/ww8par2.hxx |    4 ++--
 sw/source/filter/ww8/ww8par6.cxx |   17 ++++++++---------
 vcl/source/gdi/bitmapex.cxx      |   15 +++++++++++++--
 5 files changed, 41 insertions(+), 23 deletions(-)

New commits:
commit 03e750a73273239e238d8dd8f6f01aa59a8f6cca
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 15 12:41:14 2017 +0100

    ofz: fix another leak
    
    Change-Id: I488ee070ab781011e357db6858188d2b706cb348

diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx
index d532a580634e..a097b62ba774 100644
--- a/sw/source/filter/ww8/ww8par2.hxx
+++ b/sw/source/filter/ww8/ww8par2.hxx
@@ -67,7 +67,7 @@ struct WW8SwFlyPara
 
                 // part 2: changes found during reading
     long nNewNetWidth;
-    SwPosition* pMainTextPos;   // to return to main text after apo
+    std::unique_ptr<SwPosition> xMainTextPos;   // to return to main text after apo
     sal_uInt16 nLineSpace;          // line space in tw for graf apos
     bool bAutoWidth;
     bool bToggelPos;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 67282c3a1150..508245c17fc2 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2399,7 +2399,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
         }
 
         // remember Pos in body text
-        m_xSFlyPara->pMainTextPos = new SwPosition( *m_pPaM->GetPoint() );
+        m_xSFlyPara->xMainTextPos.reset(new SwPosition(*m_pPaM->GetPoint()));
 
         //remove fltanchors, otherwise they will be closed inside the
         //frame, which makes no sense, restore them after the frame is
@@ -2488,9 +2488,9 @@ void SwWW8ImplReader::StopApo()
     }
     else
     {
-        if (!m_xSFlyPara->pMainTextPos)
+        if (!m_xSFlyPara->xMainTextPos)
         {
-            OSL_ENSURE( m_xSFlyPara->pMainTextPos, "StopApo: pMainTextPos is 0" );
+            OSL_ENSURE(m_xSFlyPara->xMainTextPos.get(), "StopApo: xMainTextPos is nullptr");
             return;
         }
 
@@ -2511,7 +2511,7 @@ void SwWW8ImplReader::StopApo()
         SwNodeIndex aPref(m_pPaM->GetPoint()->nNode, -1);
 
         SwTwips nNewWidth =
-            MoveOutsideFly(m_xSFlyPara->pFlyFormat, *m_xSFlyPara->pMainTextPos);
+            MoveOutsideFly(m_xSFlyPara->pFlyFormat, *m_xSFlyPara->xMainTextPos);
         if (nNewWidth)
             m_xSFlyPara->BoxUpWidth(nNewWidth);
 
@@ -2584,7 +2584,7 @@ void SwWW8ImplReader::StopApo()
 
             aFlySet.ClearItem(RES_FRM_SIZE);
 
-            CalculateFlySize(aFlySet, m_xSFlyPara->pMainTextPos->nNode,
+            CalculateFlySize(aFlySet, m_xSFlyPara->xMainTextPos->nNode,
                 m_xSFlyPara->nWidth);
 
             nNewWidth = ItemGet<SwFormatFrameSize>(aFlySet, RES_FRM_SIZE).GetWidth();
@@ -2595,8 +2595,7 @@ void SwWW8ImplReader::StopApo()
             m_xSFlyPara->pFlyFormat->SetFormatAttr(aSize);
         }
 
-        delete m_xSFlyPara->pMainTextPos;
-        m_xSFlyPara->pMainTextPos = nullptr;
+        m_xSFlyPara->xMainTextPos.reset();
 // To create the SwFrames when inserting into an existing document, fltshell.cxx
 // will call pFlyFrame->MakeFrames() when setting the FltAnchor attribute
 
commit d47719a7a8558db9502b84e3e64c4a1bb7af3e7c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 15 12:39:47 2017 +0100

    ofz: fix a leak
    
    Change-Id: Ifd730a0f162ab5032665926d66debe716b0579df

diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx
index f2c98070d24e..d532a580634e 100644
--- a/sw/source/filter/ww8/ww8par2.hxx
+++ b/sw/source/filter/ww8/ww8par2.hxx
@@ -83,7 +83,7 @@ struct WW8SwFlyPara
                   const sal_Int32 nIniFlyDy );
 
     void BoxUpWidth( long nWidth );
-    SwWW8FltAnchorStack *pOldAnchorStck;
+    std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
 };
 
 class WW8RStyle: public WW8Style
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 3c05190a8c17..67282c3a1150 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2404,7 +2404,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
         //remove fltanchors, otherwise they will be closed inside the
         //frame, which makes no sense, restore them after the frame is
         //closed
-        m_xSFlyPara->pOldAnchorStck = m_pAnchorStck;
+        m_xSFlyPara->xOldAnchorStck.reset(m_pAnchorStck);
         m_pAnchorStck = new SwWW8FltAnchorStack(&m_rDoc, m_nFieldFlags);
 
         if (m_xSFlyPara->pFlyFormat)
@@ -2554,7 +2554,7 @@ void SwWW8ImplReader::StopApo()
             m_xSFlyPara->pFlyFormat->SetFormatAttr(SvxBrushItem(aBg, RES_BACKGROUND));
 
         DeleteAnchorStack();
-        m_pAnchorStck = m_xSFlyPara->pOldAnchorStck;
+        m_pAnchorStck = m_xSFlyPara->xOldAnchorStck.release();
 
         // When inserting a graphic into the fly frame using the auto
         // function, the extension of the SW-fly has to be set
commit 1323a62d2156a551eae46d249e37d9d84bc280b0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 15 11:05:13 2017 +0100

    use SetGraphic instead of temporary GraphicObject
    
    Change-Id: I220600e110e7bd2b602092c4a6f98521b0d8d43c

diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index bf2ed0f4b16e..e6c35df791eb 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -455,11 +455,11 @@ bool XFillBitmapItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
     {
         if(xBmp.is())
         {
-            maGraphicObject = Graphic(VCLUnoHelper::GetBitmap(xBmp));
+            maGraphicObject.SetGraphic(VCLUnoHelper::GetBitmap(xBmp));
         }
         else if(xGraphic.is())
         {
-            maGraphicObject = Graphic(xGraphic);
+            maGraphicObject.SetGraphic(xGraphic);
         }
     }
 
commit a4fd6f2eb41176abe34d1f82a9b9d4561f3336ac
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 15 10:55:09 2017 +0100

    skip a default dtor + assign with copy ctor
    
    Change-Id: Ibf685ff915dacedfbc9ecfa4b119115142cb68c0

diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx
index fb9cebdd01b3..e1e65229e60a 100644
--- a/include/svx/xbtmpit.hxx
+++ b/include/svx/xbtmpit.hxx
@@ -41,6 +41,8 @@ class SVX_DLLPUBLIC XFillBitmapItem : public NameOrIndex
 private:
     GraphicObject   maGraphicObject;
 
+    GraphicObject makeGraphicObject(SvStream& rIn, sal_uInt16 nVer) const;
+
 public:
             static SfxPoolItem* CreateDefault();
             XFillBitmapItem() : NameOrIndex(XATTR_FILLBITMAP, -1 ) {}
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index a1dc1b56685c..bf2ed0f4b16e 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -214,8 +214,7 @@ bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColo
     return bRet;
 }
 
-XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
-:   NameOrIndex(XATTR_FILLBITMAP, rIn)
+GraphicObject XFillBitmapItem::makeGraphicObject(SvStream& rIn, sal_uInt16 nVer) const
 {
     if (!IsIndex())
     {
@@ -225,7 +224,7 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
             Bitmap aBmp;
 
             ReadDIB(aBmp, rIn, true);
-            maGraphicObject = Graphic(aBmp);
+            return Graphic(aBmp);
         }
         else if(1 == nVer)
         {
@@ -239,7 +238,7 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
                 Bitmap aBmp;
 
                 ReadDIB(aBmp, rIn, true);
-                maGraphicObject = Graphic(aBmp);
+                return Graphic(aBmp);
             }
             else if(XBitmapType::N8x8 == (XBitmapType)iTmp)
             {
@@ -258,7 +257,7 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
 
                 const Bitmap aBitmap(createHistorical8x8FromArray(aArray, aColorPix, aColorBack));
 
-                maGraphicObject = Graphic(aBitmap);
+                return Graphic(aBitmap);
             }
         }
         else if(2 == nVer)
@@ -266,14 +265,21 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
             BitmapEx aBmpEx;
 
             ReadDIBBitmapEx(aBmpEx, rIn);
-            maGraphicObject = Graphic(aBmpEx);
+            return Graphic(aBmpEx);
         }
     }
+    return GraphicObject();
+}
+
+XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
+    : NameOrIndex(XATTR_FILLBITMAP, rIn)
+    , maGraphicObject(makeGraphicObject(rIn, nVer))
+{
 }
 
 XFillBitmapItem::XFillBitmapItem(const GraphicObject& rGraphicObject)
-:   NameOrIndex( XATTR_FILLBITMAP, -1),
-    maGraphicObject(rGraphicObject)
+    : NameOrIndex(XATTR_FILLBITMAP, -1)
+    , maGraphicObject(rGraphicObject)
 {
 }
 
commit d712a4f8225c872451ec3f76e0909825489abaf0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 15 10:27:26 2017 +0100

    continue if theme cannot be determined
    
    Change-Id: Ia5b6e77b66357dd74c5163472e07a5c31166e8d2

diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index a2034944ae88..62c571ebe855 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -96,9 +96,20 @@ BitmapEx::BitmapEx( const OUString& rIconName )
 
 void BitmapEx::loadFromIconTheme( const OUString& rIconName )
 {
-    OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
+    bool bSuccess;
+    OUString aIconTheme;
 
-    if (!ImageTree::get().loadImage(rIconName, aIconTheme, *this, true))
+    try
+    {
+        aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
+        bSuccess = ImageTree::get().loadImage(rIconName, aIconTheme, *this, true);
+    }
+    catch (...)
+    {
+        bSuccess = false;
+    }
+
+    if (!bSuccess)
     {
 #ifdef DBG_UTIL
         OStringBuffer aErrorStr(


More information about the Libreoffice-commits mailing list