[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sd/source

Caolán McNamara caolanm at redhat.com
Fri Jun 30 16:17:21 UTC 2017


 sd/source/ui/view/drviews6.cxx |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

New commits:
commit c00af602013b840f4f92c15b259ce6cdeeaabcae
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 22 09:10:14 2017 +0100

    Resolves: tdf#107959 SdrGrafObj leak triggers later crash
    
    if the graphic doesn't change, then the cloned SdrGrafObj
    persists beyond stylesheet destruction and blows up
    
    Change-Id: I0013e7e118985c1334ab460507bc5c8271700160
    (cherry picked from commit 118401aae4516bf4cc122e96b376d129ab3a3d5e)
    (cherry picked from commit e4db2fc10ba4447fa5393853d0cfed795b260f0b)
    Reviewed-on: https://gerrit.libreoffice.org/39261
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sd/source/ui/view/drviews6.cxx b/sd/source/ui/view/drviews6.cxx
index 1e137982404e..ec445e75fe37 100644
--- a/sd/source/ui/view/drviews6.cxx
+++ b/sd/source/ui/view/drviews6.cxx
@@ -276,20 +276,17 @@ void DrawViewShell::ExecBmpMask( SfxRequest& rReq )
 
             if ( pObj && !mpDrawView->IsTextEdit() )
             {
-                SdrGrafObj* pNewObj = pObj->Clone();
+                std::unique_ptr<SdrGrafObj> xNewObj(pObj->Clone());
                 bool bCont = true;
 
-                if( pNewObj->IsLinkedGraphic() )
+                if (xNewObj->IsLinkedGraphic())
                 {
                     ScopedVclPtrInstance< MessageDialog > aQueryBox( static_cast<vcl::Window*>(GetActiveWindow()),"QueryUnlinkImageDialog","modules/sdraw/ui/queryunlinkimagedialog.ui");
 
                     if (RET_YES == aQueryBox->Execute())
-                        pNewObj->ReleaseGraphicLink();
+                        xNewObj->ReleaseGraphicLink();
                     else
-                    {
-                        delete pNewObj;
                         bCont = false;
-                    }
                 }
 
                 SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(
@@ -298,21 +295,21 @@ void DrawViewShell::ExecBmpMask( SfxRequest& rReq )
                 assert(pBmpMask);
                 if (bCont && pBmpMask)
                 {
-                    const Graphic&  rOldGraphic = pNewObj->GetGraphic();
+                    const Graphic&  rOldGraphic = xNewObj->GetGraphic();
                     const Graphic   aNewGraphic(pBmpMask->Mask(rOldGraphic));
 
                     if( aNewGraphic != rOldGraphic )
                     {
                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
 
-                        pNewObj->SetEmptyPresObj( false );
-                        pNewObj->SetGraphic(pBmpMask->Mask(pNewObj->GetGraphic()));
+                        xNewObj->SetEmptyPresObj(false);
+                        xNewObj->SetGraphic(pBmpMask->Mask(xNewObj->GetGraphic()));
 
                         OUString aStr( mpDrawView->GetDescriptionOfMarkedObjects() );
                         aStr += " " + SD_RESSTR(STR_EYEDROPPER);
 
                         mpDrawView->BegUndo( aStr );
-                        mpDrawView->ReplaceObjectAtView( pObj, *pPV, pNewObj );
+                        mpDrawView->ReplaceObjectAtView(pObj, *pPV, xNewObj.release());
                         mpDrawView->EndUndo();
                     }
                 }


More information about the Libreoffice-commits mailing list