[Libreoffice-commits] core.git: 2 commits - sfx2/source xmloff/inc xmloff/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 21 06:35:56 UTC 2018
sfx2/source/control/bindings.cxx | 17 +++++++++--------
sfx2/source/control/itemdel.cxx | 10 +++++-----
sfx2/source/control/request.cxx | 15 ++++-----------
sfx2/source/control/shell.cxx | 11 ++++++-----
sfx2/source/inc/itemdel.hxx | 4 +++-
xmloff/inc/txtflde.hxx | 2 +-
xmloff/source/text/txtflde.cxx | 4 ++--
xmloff/source/text/txtparae.cxx | 3 ++-
8 files changed, 32 insertions(+), 34 deletions(-)
New commits:
commit b1da360e9230f5a1d1d5e03bd8f83f65e7e14edc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 20 09:53:56 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 21 08:35:43 2018 +0200
loplugin:useuniqueptr in XMLTextFieldExport
Change-Id: Ib525cc596429f61740f567445296dcf71c19acf2
Reviewed-on: https://gerrit.libreoffice.org/59350
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx
index 909da05499ca..16f6c799ed06 100644
--- a/xmloff/inc/txtflde.hxx
+++ b/xmloff/inc/txtflde.hxx
@@ -161,7 +161,7 @@ public:
XMLTextFieldExport( SvXMLExport& rExp,
/// XMLPropertyState for the combined characters field
- XMLPropertyState* pCombinedCharState );
+ std::unique_ptr<XMLPropertyState> pCombinedCharState );
~XMLTextFieldExport();
/// Export this field and the surrounding span element with the formatting.
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index f65f26943a62..55a4368eadc1 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -273,7 +273,7 @@ inline Sequence<OUString> const GetStringSequenceProperty(
XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
- XMLPropertyState* pCombinedCharState)
+ std::unique_ptr<XMLPropertyState> pCombinedCharState)
: rExport(rExp),
sServicePrefix("com.sun.star.text.textfield."),
sFieldMasterPrefix("com.sun.star.text.FieldMaster."),
@@ -346,7 +346,7 @@ XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
sPropertyHelp("Help"),
sPropertyTooltip("Tooltip"),
sPropertyTextRange("TextRange"),
- pCombinedCharactersPropertyState(pCombinedCharState)
+ pCombinedCharactersPropertyState(std::move(pCombinedCharState))
{
SetExportOnlyUsedFieldDeclarations();
}
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 1f06a8eec257..93d5fe16424c 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
#include <tools/debug.hxx>
#include <rtl/ustrbuf.hxx>
@@ -1312,7 +1313,7 @@ XMLTextParagraphExport::XMLTextParagraphExport(
sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex(
"", XML_NAMESPACE_STYLE,
GetXMLToken(XML_TEXT_COMBINE));
- pFieldExport.reset( new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, uno::makeAny(true) ) ) );
+ pFieldExport.reset( new XMLTextFieldExport( rExp, o3tl::make_unique<XMLPropertyState>( nIndex, uno::makeAny(true) ) ) );
PushNewTextListsHelper();
}
commit 06765e45cbf83a865cabb3ce6c418f497e87e099
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 20 09:53:33 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 21 08:35:33 2018 +0200
loplugin:useuniqueptr in DeleteItemOnIdle
Change-Id: I6a72417bcab1ac48b5d8a73005104c8627dde32b
Reviewed-on: https://gerrit.libreoffice.org/59349
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index f6454d2a31f3..b65ccbf08892 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -925,14 +925,15 @@ const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem*
// cache binds to an external dispatch provider
sal_Int16 eRet = pCache->Dispatch( aReq.GetArgs(), nCallMode == SfxCallMode::SYNCHRON );
- SfxPoolItem *pPool;
+ std::unique_ptr<SfxPoolItem> pPool;
if ( eRet == css::frame::DispatchResultState::DONTKNOW )
- pPool = new SfxVoidItem( nId );
+ pPool.reset( new SfxVoidItem( nId ) );
else
- pPool = new SfxBoolItem( nId, eRet == css::frame::DispatchResultState::SUCCESS);
+ pPool.reset( new SfxBoolItem( nId, eRet == css::frame::DispatchResultState::SUCCESS) );
- DeleteItemOnIdle( pPool );
- return pPool;
+ auto pTemp = pPool.get();
+ DeleteItemOnIdle( std::move(pPool) );
+ return pTemp;
}
// slot is handled internally by SfxDispatcher
@@ -976,9 +977,9 @@ const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem*
const SfxPoolItem* pRet = aReq.GetReturnValue();
if ( !pRet )
{
- SfxPoolItem *pVoid = new SfxVoidItem( nId );
- DeleteItemOnIdle( pVoid );
- pRet = pVoid;
+ std::unique_ptr<SfxPoolItem> pVoid(new SfxVoidItem( nId ));
+ pRet = pVoid.get();
+ DeleteItemOnIdle( std::move(pVoid) );
}
return pRet;
diff --git a/sfx2/source/control/itemdel.cxx b/sfx2/source/control/itemdel.cxx
index d0555950dd39..4dbd6bb22171 100644
--- a/sfx2/source/control/itemdel.cxx
+++ b/sfx2/source/control/itemdel.cxx
@@ -33,15 +33,15 @@ private:
DECL_LINK( Delete, Timer*, void );
public:
- explicit SfxItemDisruptor_Impl(SfxPoolItem *pItemToDesrupt);
+ explicit SfxItemDisruptor_Impl(std::unique_ptr<SfxPoolItem> pItemToDesrupt);
void LaunchDeleteOnIdle();
~SfxItemDisruptor_Impl();
SfxItemDisruptor_Impl(const SfxItemDisruptor_Impl&) = delete;
SfxItemDisruptor_Impl& operator=(const SfxItemDisruptor_Impl&) = delete;
};
-SfxItemDisruptor_Impl::SfxItemDisruptor_Impl(SfxPoolItem *const pItemToDisrupt)
- : pItem(pItemToDisrupt)
+SfxItemDisruptor_Impl::SfxItemDisruptor_Impl(std::unique_ptr<SfxPoolItem> pItemToDisrupt)
+ : pItem(std::move(pItemToDisrupt))
, m_Idle("sfx SfxItemDisruptor_Impl::Delete")
{
m_Idle.SetInvokeHandler(LINK(this, SfxItemDisruptor_Impl, Delete));
@@ -72,10 +72,10 @@ IMPL_LINK_NOARG(SfxItemDisruptor_Impl, Delete, Timer*, void)
delete this;
}
-void DeleteItemOnIdle(SfxPoolItem* pItem)
+void DeleteItemOnIdle(std::unique_ptr<SfxPoolItem> pItem)
{
DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" );
- SfxItemDisruptor_Impl *pDesruptor = new SfxItemDisruptor_Impl(pItem);
+ SfxItemDisruptor_Impl *pDesruptor = new SfxItemDisruptor_Impl(std::move(pItem));
pDesruptor->LaunchDeleteOnIdle();
// coverity[leaked_storage] - pDesruptor takes care of its own destruction at idle time
}
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index ece383994c26..7c73d3664c8e 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -57,7 +57,7 @@ struct SfxRequest_Impl: public SfxListener
SfxRequest* pAnti; // Owner because of dying pool
OUString aTarget; // if possible from target object set by App
SfxItemPool* pPool; // ItemSet build with this pool
- SfxPoolItem* pRetVal; // Return value belongs to itself
+ std::unique_ptr<SfxPoolItem> pRetVal; // Return value belongs to itself
SfxShell* pShell; // run from this shell
const SfxSlot* pSlot; // executed Slot
sal_uInt16 nModifier; // which Modifier was pressed?
@@ -76,7 +76,6 @@ struct SfxRequest_Impl: public SfxListener
explicit SfxRequest_Impl( SfxRequest *pOwner )
: pAnti( pOwner)
, pPool(nullptr)
- , pRetVal(nullptr)
, pShell(nullptr)
, pSlot(nullptr)
, nModifier(0)
@@ -125,7 +124,7 @@ SfxRequest::~SfxRequest()
// Clear object
pArgs.reset();
if ( pImpl->pRetVal )
- DeleteItemOnIdle(pImpl->pRetVal);
+ DeleteItemOnIdle(std::move(pImpl->pRetVal));
}
@@ -141,7 +140,6 @@ SfxRequest::SfxRequest
pImpl->bAllowRecording = rOrig.pImpl->bAllowRecording;
pImpl->bDone = false;
pImpl->bIgnored = false;
- pImpl->pRetVal = nullptr;
pImpl->pShell = nullptr;
pImpl->pSlot = nullptr;
pImpl->nCallMode = rOrig.pImpl->nCallMode;
@@ -198,7 +196,6 @@ SfxRequest::SfxRequest
pImpl->bDone = false;
pImpl->bIgnored = false;
pImpl->SetPool( &pViewFrame->GetPool() );
- pImpl->pRetVal = nullptr;
pImpl->pShell = nullptr;
pImpl->pSlot = nullptr;
pImpl->nCallMode = SfxCallMode::SYNCHRON;
@@ -232,7 +229,6 @@ SfxRequest::SfxRequest
pImpl->bDone = false;
pImpl->bIgnored = false;
pImpl->SetPool( &rPool );
- pImpl->pRetVal = nullptr;
pImpl->pShell = nullptr;
pImpl->pSlot = nullptr;
pImpl->nCallMode = nMode;
@@ -252,7 +248,6 @@ SfxRequest::SfxRequest
pImpl->bDone = false;
pImpl->bIgnored = false;
pImpl->SetPool( &rPool );
- pImpl->pRetVal = nullptr;
pImpl->pShell = nullptr;
pImpl->pSlot = nullptr;
pImpl->nCallMode = nMode;
@@ -276,7 +271,6 @@ SfxRequest::SfxRequest
pImpl->bDone = false;
pImpl->bIgnored = false;
pImpl->SetPool( rSfxArgs.GetPool() );
- pImpl->pRetVal = nullptr;
pImpl->pShell = nullptr;
pImpl->pSlot = nullptr;
pImpl->nCallMode = nMode;
@@ -432,14 +426,13 @@ void SfxRequest::RemoveItem( sal_uInt16 nID )
void SfxRequest::SetReturnValue(const SfxPoolItem &rItem)
{
DBG_ASSERT(!pImpl->pRetVal, "Set Return value multiple times?");
- delete pImpl->pRetVal;
- pImpl->pRetVal = rItem.Clone();
+ pImpl->pRetVal.reset(rItem.Clone());
}
const SfxPoolItem* SfxRequest::GetReturnValue() const
{
- return pImpl->pRetVal;
+ return pImpl->pRetVal.get();
}
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 42ff95827f77..6d5e1fd137c7 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -491,7 +491,7 @@ const SfxPoolItem* SfxShell::GetSlotState
eState = SfxItemState::UNKNOWN;
// Evaluate Item and item status and possibly maintain them in pStateSet
- SfxPoolItem *pRetItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pRetItem;
if ( eState <= SfxItemState::DISABLED )
{
if ( pStateSet )
@@ -502,17 +502,18 @@ const SfxPoolItem* SfxShell::GetSlotState
{
if ( pStateSet )
pStateSet->ClearItem(nSlotId);
- pRetItem = new SfxVoidItem(0);
+ pRetItem.reset( new SfxVoidItem(0) );
}
else
{
if ( pStateSet && pStateSet->Put( *pItem ) )
return &pStateSet->Get( pItem->Which() );
- pRetItem = pItem->Clone();
+ pRetItem.reset(pItem->Clone());
}
- DeleteItemOnIdle(pRetItem);
+ auto pTemp = pRetItem.get();
+ DeleteItemOnIdle(std::move(pRetItem));
- return pRetItem;
+ return pTemp;
}
SFX_EXEC_STUB(SfxShell, VerbExec)
diff --git a/sfx2/source/inc/itemdel.hxx b/sfx2/source/inc/itemdel.hxx
index cd5d14de170e..1884c83c38cc 100644
--- a/sfx2/source/inc/itemdel.hxx
+++ b/sfx2/source/inc/itemdel.hxx
@@ -19,9 +19,11 @@
#ifndef INCLUDED_SFX2_ITEMDEL_HXX
#define INCLUDED_SFX2_ITEMDEL_HXX
+#include <memory>
+
class SfxPoolItem;
-void DeleteItemOnIdle( SfxPoolItem* pItem );
+void DeleteItemOnIdle( std::unique_ptr<SfxPoolItem> pItem );
#endif
More information about the Libreoffice-commits
mailing list