[Libreoffice-commits] core.git: 3 commits - cui/source include/svl svl/source svl/unx svtools/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Dec 19 07:01:43 UTC 2017
cui/source/dialogs/iconcdlg.cxx | 10 -----
include/svl/svdde.hxx | 7 ++-
svl/source/svdde/ddeimp.hxx | 2 -
svl/source/svdde/ddesvr.cxx | 29 +++++-----------
svl/unx/source/svdde/ddedummy.cxx | 5 ++
svtools/source/graphic/grfcache.cxx | 64 +++++++++---------------------------
6 files changed, 35 insertions(+), 82 deletions(-)
New commits:
commit 327a3ac9b320552ee778b5fb5d1f0d5966d8ea7b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Dec 18 12:55:05 2017 +0200
fix bug in IconChoiceDialog::dispose
after
commit 12bb4bc980863d4338725cf5a5dcaf3acbfddc09
convert HyperLinkPageType to scoped enum
Change-Id: Icb1afcdea38f231bf9b7119eb4c1bedbf7494962
Reviewed-on: https://gerrit.libreoffice.org/46707
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index acf04885b488..1b1009389595 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -224,16 +224,6 @@ void IconChoiceDialog::dispose()
}
maPageList.clear();
- if (m_pIconCtrl)
- {
- // remove Userdata from Icons
- for ( sal_Int32 i=0; i < m_pIconCtrl->GetEntryCount(); i++)
- {
- SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( i );
- delete static_cast<sal_uInt16*>(pEntry->GetUserData());
- }
- }
-
delete pRanges;
pRanges = nullptr;
delete pOutSet;
commit 28e1f3c77fe19091cddf527f7758386dddcdad34
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Sat Nov 18 22:43:41 2017 +0900
svl: Fix possible memleak at deleting DdeService
Change-Id: Ie10d4199999c4331af29dee2a8d98132488caa6e
Reviewed-on: https://gerrit.libreoffice.org/44909
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svl/svdde.hxx b/include/svl/svdde.hxx
index 003a14f83923..2f07eb768117 100644
--- a/include/svl/svdde.hxx
+++ b/include/svl/svdde.hxx
@@ -48,7 +48,7 @@ struct Conversation;
typedef ::std::vector< DdeService* > DdeServices;
typedef ::std::vector< long > DdeFormats;
-typedef ::std::vector< Conversation* > ConvList;
+typedef std::vector<std::unique_ptr<Conversation>> ConvList;
class SVL_DLLPUBLIC DdeData
@@ -297,7 +297,7 @@ private:
DdeFormats aFormats;
DdeTopic* pSysTopic;
DdeString* pName;
- ConvList* pConv;
+ ConvList m_vConv;
short nStatus;
SVL_DLLPRIVATE bool HasCbFormat( sal_uInt16 );
@@ -306,6 +306,9 @@ public:
DdeService( SAL_UNUSED_PARAMETER const OUString& );
virtual ~DdeService();
+ DdeService( const DdeService& ) = delete;
+ DdeService& operator= ( const DdeService& ) = delete;
+
const OUString GetName() const;
short GetError() { return nStatus; }
diff --git a/svl/source/svdde/ddeimp.hxx b/svl/source/svdde/ddeimp.hxx
index 22df0864002e..3e6cf02483b4 100644
--- a/svl/source/svdde/ddeimp.hxx
+++ b/svl/source/svdde/ddeimp.hxx
@@ -37,8 +37,6 @@ struct Conversation
DdeTopic* pTopic;
};
-typedef ::std::vector< Conversation* > ConvList;
-
class DdeInternal
{
diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx
index ce26573988b4..45098bec4764 100644
--- a/svl/source/svdde/ddesvr.cxx
+++ b/svl/source/svdde/ddesvr.cxx
@@ -153,7 +153,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
pC = new Conversation;
pC->hConv = hConv;
pC->pTopic = pTopic;
- pService->pConv->push_back( pC );
+ pService->m_vConv.emplace_back( pC );
}
}
return nullptr;
@@ -162,9 +162,9 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
{
pService = *aI;
- for ( size_t i = 0, n = pService->pConv->size(); i < n; ++i )
+ for ( size_t i = 0, n = pService->m_vConv.size(); i < n; ++i )
{
- pC = (*pService->pConv)[ i ];
+ pC = pService->m_vConv[ i ].get();
if ( pC->hConv == hConv )
goto found;
}
@@ -176,14 +176,13 @@ found:
if ( nCode == XTYP_DISCONNECT)
{
DisconnectTopic(*pC->pTopic, hConv);
- for ( ConvList::iterator it = pService->pConv->begin();
- it != pService->pConv->end();
+ for ( ConvList::iterator it = pService->m_vConv.begin();
+ it != pService->m_vConv.end();
++it
) {
- if ( *it == pC )
+ if ( it->get() == pC )
{
- delete *it;
- pService->pConv->erase( it );
+ pService->m_vConv.erase( it );
break;
}
}
@@ -435,8 +434,6 @@ DdeService::DdeService( const OUString& rService )
else
nStatus = DMLERR_NO_ERROR;
- pConv = new ConvList;
-
if ( pInst->pServicesSvr )
pInst->pServicesSvr->push_back( this );
@@ -482,7 +479,6 @@ DdeService::~DdeService()
ImpDeinitInstData();
}
}
- delete pConv;
}
const OUString DdeService::GetName() const
@@ -513,16 +509,11 @@ void DdeService::RemoveTopic( const DdeTopic& rTopic )
aTopics.erase(iter);
// Delete all conversions!
// Or else we work on deleted topics!
- for( size_t n = pConv->size(); n; )
+ for( size_t n = m_vConv.size(); n; )
{
- Conversation* pC = (*pConv)[ --n ];
+ auto const& pC = m_vConv[ --n ];
if( pC->pTopic == &rTopic )
- {
- ConvList::iterator it = pConv->begin();
- ::std::advance( it, n );
- delete *it;
- pConv->erase( it );
- }
+ m_vConv.erase( m_vConv.begin() + n );
}
break;
}
diff --git a/svl/unx/source/svdde/ddedummy.cxx b/svl/unx/source/svdde/ddedummy.cxx
index 856d79dc5db2..e934b865a857 100644
--- a/svl/unx/source/svdde/ddedummy.cxx
+++ b/svl/unx/source/svdde/ddedummy.cxx
@@ -20,6 +20,10 @@
#include <svl/svdde.hxx>
#include <rtl/instance.hxx>
+struct Conversation
+{
+};
+
struct DdeDataImp
{
};
@@ -202,7 +206,6 @@ const OUString DdeTopic::GetName() const
DdeService::DdeService( const OUString& )
: pSysTopic(nullptr)
, pName(nullptr)
- , pConv(nullptr)
, nStatus(0)
{
}
commit 67bd9382aa17594cb7a6d1fad304ed9f275941b1
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Tue Dec 19 02:11:36 2017 +0900
svtools: Use std::unique_ptr for GraphicCacheEntry
... and GraphicDisplayCacheEntry.
Change-Id: Ic4c4f6078837d96ce56e245caa926c7730034a08
Reviewed-on: https://gerrit.libreoffice.org/46732
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index da41b631fc93..cd42a0aa289a 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -147,9 +147,9 @@ private:
GraphicID maID;
GfxLink maGfxLink;
- BitmapEx* mpBmpEx;
- GDIMetaFile* mpMtf;
- Animation* mpAnimation;
+ std::unique_ptr<BitmapEx> mpBmpEx;
+ std::unique_ptr<GDIMetaFile> mpMtf;
+ std::unique_ptr<Animation> mpAnimation;
bool mbSwappedAll;
// VectorGraphicData support
@@ -178,9 +178,6 @@ public:
GraphicCacheEntry::GraphicCacheEntry( const GraphicObject& rObj ) :
maID ( rObj ),
- mpBmpEx ( nullptr ),
- mpMtf ( nullptr ),
- mpAnimation ( nullptr ),
mbSwappedAll ( true )
{
mbSwappedAll = !ImplInit( rObj );
@@ -193,10 +190,6 @@ GraphicCacheEntry::~GraphicCacheEntry()
maGraphicObjectList.empty(),
"GraphicCacheEntry::~GraphicCacheEntry(): Not all GraphicObjects are removed from this entry"
);
-
- delete mpBmpEx;
- delete mpMtf;
- delete mpAnimation;
}
bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
@@ -207,23 +200,9 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
{
const Graphic& rGraphic = rObj.GetGraphic();
- if( mpBmpEx )
- {
- delete mpBmpEx;
- mpBmpEx = nullptr;
- }
-
- if( mpMtf )
- {
- delete mpMtf;
- mpMtf = nullptr;
- }
-
- if( mpAnimation )
- {
- delete mpAnimation;
- mpAnimation = nullptr;
- }
+ mpBmpEx.reset();
+ mpMtf.reset();
+ mpAnimation.reset();
switch( rGraphic.GetType() )
{
@@ -235,11 +214,11 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
}
else if( rGraphic.IsAnimated() )
{
- mpAnimation = new Animation( rGraphic.GetAnimation() );
+ mpAnimation.reset(new Animation( rGraphic.GetAnimation() ));
}
else
{
- mpBmpEx = new BitmapEx( rGraphic.GetBitmapEx() );
+ mpBmpEx.reset(new BitmapEx( rGraphic.GetBitmapEx() ));
if (rGraphic.getPdfData().hasElements())
maPdfData = rGraphic.getPdfData();
}
@@ -248,7 +227,7 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
case GraphicType::GdiMetafile:
{
- mpMtf = new GDIMetaFile( rGraphic.GetGDIMetaFile() );
+ mpMtf.reset(new GDIMetaFile( rGraphic.GetGDIMetaFile() ));
}
break;
@@ -375,12 +354,9 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut()
if( !mbSwappedAll )
return;
- delete mpBmpEx;
- mpBmpEx = nullptr;
- delete mpMtf;
- mpMtf = nullptr;
- delete mpAnimation;
- mpAnimation = nullptr;
+ mpBmpEx.reset();
+ mpMtf.reset();
+ mpAnimation.reset();
// #119176# also reset VectorGraphicData
maVectorGraphicData.reset();
@@ -399,8 +375,8 @@ private:
::salhelper::TTimeValue maReleaseTime;
const GraphicCacheEntry* mpRefCacheEntry;
- GDIMetaFile* mpMtf;
- BitmapEx* mpBmpEx;
+ std::unique_ptr<GDIMetaFile> mpMtf;
+ std::unique_ptr<BitmapEx> mpBmpEx;
GraphicAttr maAttr;
Size maOutSizePix;
sal_uLong mnCacheSize;
@@ -425,7 +401,7 @@ public:
const GraphicObject& rObj, const GraphicAttr& rAttr,
const BitmapEx& rBmpEx ) :
mpRefCacheEntry( pRefCacheEntry ),
- mpMtf( nullptr ), mpBmpEx( new BitmapEx( rBmpEx ) ),
+ mpBmpEx( new BitmapEx( rBmpEx ) ),
maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ),
mnOutDevDrawMode( pOut->GetDrawMode() ),
@@ -438,7 +414,7 @@ public:
const GraphicObject& rObj, const GraphicAttr& rAttr,
const GDIMetaFile& rMtf ) :
mpRefCacheEntry( pRefCacheEntry ),
- mpMtf( new GDIMetaFile( rMtf ) ), mpBmpEx( nullptr ),
+ mpMtf( new GDIMetaFile( rMtf ) ),
maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ),
mnOutDevDrawMode( pOut->GetDrawMode() ),
@@ -447,8 +423,6 @@ public:
}
- ~GraphicDisplayCacheEntry();
-
sal_uLong GetCacheSize() const { return mnCacheSize; }
const GraphicCacheEntry* GetReferencedCacheEntry() const { return mpRefCacheEntry; }
@@ -797,12 +771,6 @@ sal_uLong GraphicDisplayCacheEntry::GetNeededSize( OutputDevice const * pOut, co
return rGraphic.GetSizeBytes();
}
-GraphicDisplayCacheEntry::~GraphicDisplayCacheEntry()
-{
- delete mpMtf;
- delete mpBmpEx;
-}
-
void GraphicDisplayCacheEntry::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz ) const
{
if( mpMtf )
More information about the Libreoffice-commits
mailing list