diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-17 10:13:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-17 10:48:27 +0000 |
commit | 49bfc59272f8482ca37abc631d2c3777518fd1d5 (patch) | |
tree | e01cb4a3fa03b6dbd7107e409de83de19813d804 /sfx2/source/appl/linksrc.cxx | |
parent | 88c755e37cd36ddfe6d0d651540d9f2bd8a029a6 (diff) |
new loplugin: useuniqueptr: sfx2
Change-Id: I544c615105d14fa258fed7f30790d305e987f523
Reviewed-on: https://gerrit.libreoffice.org/33206
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/appl/linksrc.cxx')
-rw-r--r-- | sfx2/source/appl/linksrc.cxx | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/sfx2/source/appl/linksrc.cxx b/sfx2/source/appl/linksrc.cxx index d146fe92c7d5..e7c5a38f97e9 100644 --- a/sfx2/source/appl/linksrc.cxx +++ b/sfx2/source/appl/linksrc.cxx @@ -53,14 +53,14 @@ void SvLinkSourceTimer::Invoke() pOwner->SendDataChanged(); } -static void StartTimer( SvLinkSourceTimer ** ppTimer, SvLinkSource * pOwner, +static void StartTimer( std::unique_ptr<SvLinkSourceTimer>& pTimer, SvLinkSource * pOwner, sal_uIntPtr nTimeout ) { - if( !*ppTimer ) + if( !pTimer ) { - *ppTimer = new SvLinkSourceTimer( pOwner ); - (*ppTimer)->SetTimeout( nTimeout ); - (*ppTimer)->Start(); + pTimer.reset( new SvLinkSourceTimer( pOwner ) ); + pTimer->SetTimeout( nTimeout ); + pTimer->Start(); } } @@ -182,11 +182,12 @@ struct SvLinkSource_Impl { SvLinkSource_Array_Impl aArr; OUString aDataMimeType; - SvLinkSourceTimer * pTimer; + std::unique_ptr<SvLinkSourceTimer> + pTimer; sal_uIntPtr nTimeout; css::uno::Reference<css::io::XInputStream> - m_xInputStreamToLoadFrom; - bool m_bIsReadOnly; + m_xInputStreamToLoadFrom; + bool m_bIsReadOnly; SvLinkSource_Impl() : pTimer(nullptr) @@ -199,7 +200,6 @@ struct SvLinkSource_Impl SvLinkSource_Impl::~SvLinkSource_Impl() { - delete pTimer; } SvLinkSource::SvLinkSource() @@ -279,18 +279,14 @@ void SvLinkSource::SendDataChanged() } } } - if( pImpl->pTimer ) - { - delete pImpl->pTimer; - pImpl->pTimer = nullptr; - } + pImpl->pTimer.reset(); pImpl->aDataMimeType.clear(); } void SvLinkSource::NotifyDataChanged() { if( pImpl->nTimeout ) - StartTimer( &pImpl->pTimer, this, pImpl->nTimeout ); // New timeout + StartTimer( pImpl->pTimer, this, pImpl->nTimeout ); // New timeout else { SvLinkSource_EntryIter_Impl aIter( pImpl->aArr ); @@ -313,11 +309,7 @@ void SvLinkSource::NotifyDataChanged() } } - if( pImpl->pTimer ) - { - delete pImpl->pTimer; - pImpl->pTimer = nullptr; - } + pImpl->pTimer.reset(); } } @@ -330,7 +322,7 @@ void SvLinkSource::DataChanged( const OUString & rMimeType, { // only when no data was included // fire all data to the sink, independent of the requested format pImpl->aDataMimeType = rMimeType; - StartTimer( &pImpl->pTimer, this, pImpl->nTimeout ); // New timeout + StartTimer( pImpl->pTimer, this, pImpl->nTimeout ); // New timeout } else { @@ -351,11 +343,7 @@ void SvLinkSource::DataChanged( const OUString & rMimeType, } } - if( pImpl->pTimer ) - { - delete pImpl->pTimer; - pImpl->pTimer = nullptr; - } + pImpl->pTimer.reset(); } } |