[Libreoffice-commits] core.git: 2 commits - avmedia/source compilerplugins/clang include/avmedia include/sfx2 sfx2/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon May 14 09:11:54 UTC 2018
avmedia/source/framework/mediaplayer.cxx | 8 +++-----
compilerplugins/clang/useuniqueptr.cxx | 4 ++++
include/avmedia/mediaplayer.hxx | 3 ++-
include/sfx2/tabdlg.hxx | 4 ++--
sfx2/source/dialog/tabdlg.cxx | 27 ++++++++++++---------------
5 files changed, 23 insertions(+), 23 deletions(-)
New commits:
commit 89507e35e1bb4ce390d7550d2bb02edcbf74c5e7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed May 9 09:59:17 2018 +0200
loplugin:useuniqueptr in MediaFloater
Change-Id: Ibdf838b630fdd63f549b59f69ee05c2030326fa5
Reviewed-on: https://gerrit.libreoffice.org/54175
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/avmedia/source/framework/mediaplayer.cxx b/avmedia/source/framework/mediaplayer.cxx
index dad2b2ddbd24..717f99369e7f 100644
--- a/avmedia/source/framework/mediaplayer.cxx
+++ b/avmedia/source/framework/mediaplayer.cxx
@@ -74,8 +74,7 @@ void MediaFloater::dispose()
Show(false, ShowFlags::NoFocusChange);
SetFloatingMode(false);
}
- delete mpMediaWindow;
- mpMediaWindow = nullptr;
+ mpMediaWindow.reset();
SfxDockingWindow::dispose();
}
@@ -93,15 +92,14 @@ void MediaFloater::ToggleFloatingMode()
if (mpMediaWindow)
mpMediaWindow->updateMediaItem( aRestoreItem );
- delete mpMediaWindow;
- mpMediaWindow = nullptr;
+ mpMediaWindow.reset();
SfxDockingWindow::ToggleFloatingMode();
if (isDisposed())
return;
- mpMediaWindow = new MediaWindow( this, true );
+ mpMediaWindow.reset( new MediaWindow( this, true ) );
mpMediaWindow->setPosSize( tools::Rectangle( Point(), GetOutputSizePixel() ) );
mpMediaWindow->executeMediaItem( aRestoreItem );
diff --git a/include/avmedia/mediaplayer.hxx b/include/avmedia/mediaplayer.hxx
index ac45b92d42ed..12164cdc9308 100644
--- a/include/avmedia/mediaplayer.hxx
+++ b/include/avmedia/mediaplayer.hxx
@@ -24,6 +24,7 @@
#include <sfx2/dockwin.hxx>
#include <sfx2/viewfrm.hxx>
#include <avmedia/avmediadllapi.h>
+#include <memory>
namespace avmedia
{
@@ -56,7 +57,7 @@ private:
virtual void Resize() override;
virtual void ToggleFloatingMode() override;
- MediaWindow* mpMediaWindow;
+ std::unique_ptr<MediaWindow> mpMediaWindow;
};
inline MediaFloater * getMediaFloater() {
commit 5c3816cce5054ef41af441f9a280a8025ff6d691
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed May 9 09:40:59 2018 +0200
loplugin:useuniqueptr in SfxTabDialog
Change-Id: I460bf5aac44e6fd08a5bd5ab8af217dedbcc3cf8
Reviewed-on: https://gerrit.libreoffice.org/54174
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index ce09b5873cbb..c7f76fe6b962 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -45,6 +45,10 @@ public:
// too clever
if (fn == SRCDIR "/pyuno/source/module/pyuno_runtime.cxx")
return;
+ // m_pExampleSet here is very badly manageed. sometimes it is owning, sometimes not,
+ // and the logic depends on overriding methods.
+ if (fn == SRCDIR "/sfx2/source/dialog/tabdlg.cxx")
+ return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index d7aaebb49669..51e30e4c0d40 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -97,10 +97,10 @@ friend class SfxTabDialogUIObject;
bool m_bOwnsResetBtn;
bool m_bOwnsBaseFmtBtn;
- SfxItemSet* m_pSet;
+ std::unique_ptr<SfxItemSet> m_pSet;
std::unique_ptr<SfxItemSet> m_pOutSet;
std::unique_ptr< TabDlg_Impl > m_pImpl;
- sal_uInt16* m_pRanges;
+ std::unique_ptr<sal_uInt16[]> m_pRanges;
sal_uInt16 m_nAppPageId;
bool m_bStandardPushed;
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 160af8d6af54..ae8023773e14 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -429,13 +429,11 @@ void SfxTabDialog::dispose()
}
m_pImpl.reset();
- delete m_pSet;
- m_pSet = nullptr;
+ m_pSet.reset();
m_pOutSet.reset();
delete m_pExampleSet;
m_pExampleSet = nullptr;
- delete [] m_pRanges;
- m_pRanges = nullptr;
+ m_pRanges.reset();
if (m_bOwnsBaseFmtBtn)
m_pBaseFmtBtn.disposeAndClear();
@@ -779,7 +777,7 @@ SfxItemSet* SfxTabDialog::GetInputSetImpl()
*/
{
- return m_pSet;
+ return m_pSet.get();
}
@@ -1017,7 +1015,7 @@ IMPL_LINK_NOARG(SfxTabDialog, ResetHdl, Button*, void)
Data_Impl* pDataObject = Find( m_pImpl->aData, nId );
DBG_ASSERT( pDataObject, "Id not known" );
- pDataObject->pTabPage->Reset( m_pSet );
+ pDataObject->pTabPage->Reset( m_pSet.get() );
// Also reset relevant items of ExampleSet and OutSet to initial state
if (pDataObject->fnGetRanges)
{
@@ -1165,7 +1163,7 @@ IMPL_LINK( SfxTabDialog, ActivatePageHdl, TabControl *, pTabCtrl, void )
if ( !pTabPage )
{
if ( m_pSet )
- pTabPage = (pDataObject->fnCreatePage)(static_cast<vcl::Window*>(pTabCtrl), m_pSet);
+ pTabPage = (pDataObject->fnCreatePage)(static_cast<vcl::Window*>(pTabCtrl), m_pSet.get());
else
pTabPage = (pDataObject->fnCreatePage)(pTabCtrl, CreateInputItemSet(nId));
DBG_ASSERT( nullptr == pDataObject->pTabPage, "create TabPage more than once" );
@@ -1197,12 +1195,12 @@ IMPL_LINK( SfxTabDialog, ActivatePageHdl, TabControl *, pTabCtrl, void )
PageCreated( nId, *pTabPage );
- pTabPage->Reset( m_pSet );
+ pTabPage->Reset( m_pSet.get() );
pTabCtrl->SetTabPage( nId, pTabPage );
}
else if ( pDataObject->bRefresh )
- pTabPage->Reset( m_pSet );
+ pTabPage->Reset( m_pSet.get() );
pDataObject->bRefresh = false;
if ( m_pExampleSet )
@@ -1343,7 +1341,7 @@ const sal_uInt16* SfxTabDialog::GetInputRanges( const SfxItemPool& rPool )
}
if ( m_pRanges )
- return m_pRanges;
+ return m_pRanges.get();
std::vector<sal_uInt16> aUS;
for (auto const& elem : m_pImpl->aData)
@@ -1373,10 +1371,10 @@ const sal_uInt16* SfxTabDialog::GetInputRanges( const SfxItemPool& rPool )
std::sort( aUS.begin(), aUS.end() );
}
- m_pRanges = new sal_uInt16[aUS.size() + 1];
- std::copy( aUS.begin(), aUS.end(), m_pRanges );
+ m_pRanges.reset(new sal_uInt16[aUS.size() + 1]);
+ std::copy( aUS.begin(), aUS.end(), m_pRanges.get() );
m_pRanges[aUS.size()] = 0;
- return m_pRanges;
+ return m_pRanges.get();
}
@@ -1389,8 +1387,7 @@ void SfxTabDialog::SetInputSet( const SfxItemSet* pInSet )
{
bool bSet = ( m_pSet != nullptr );
- delete m_pSet;
- m_pSet = pInSet ? new SfxItemSet(*pInSet) : nullptr;
+ m_pSet.reset(pInSet ? new SfxItemSet(*pInSet) : nullptr);
if (!bSet && !m_pExampleSet && !m_pOutSet && m_pSet)
{
More information about the Libreoffice-commits
mailing list