include/vcl/i18nhelp.hxx | 5 ++- include/vcl/tabctrl.hxx | 2 - vcl/inc/listbox.hxx | 4 +- vcl/source/app/i18nhelp.cxx | 17 ++++------- vcl/source/control/imp_listbox.cxx | 4 +- vcl/source/control/tabctrl.cxx | 5 +-- vcl/source/gdi/pngwrite.cxx | 54 ++++++++++++++++++------------------- 7 files changed, 43 insertions(+), 48 deletions(-)
New commits: commit ab2b4c0e1378072f05eee6b2c1bf6df311d6f1b3 Author: Noel Grandin <[email protected]> Date: Mon Apr 23 14:28:27 2018 +0200 loplugin:useuniqueptr in I18nHelper Change-Id: I46ba0150bc4ca39fd781b8b979e960df0cffc7d4 Reviewed-on: https://gerrit.libreoffice.org/53355 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/vcl/i18nhelp.hxx b/include/vcl/i18nhelp.hxx index b3a14255ca06..a18d7fcd4958 100644 --- a/include/vcl/i18nhelp.hxx +++ b/include/vcl/i18nhelp.hxx @@ -25,6 +25,7 @@ #include <osl/mutex.hxx> #include <rtl/ustring.hxx> #include <vcl/dllapi.h> +#include <memory> namespace com { namespace sun { @@ -51,8 +52,8 @@ class VCL_DLLPUBLIC I18nHelper LanguageTag maLanguageTag; css::uno::Reference< css::uno::XComponentContext > m_xContext; - LocaleDataWrapper* mpLocaleDataWrapper; - utl::TransliterationWrapper* mpTransliterationWrapper; + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; + std::unique_ptr<utl::TransliterationWrapper> mpTransliterationWrapper; bool mbTransliterateIgnoreCase; diff --git a/vcl/source/app/i18nhelp.cxx b/vcl/source/app/i18nhelp.cxx index ca4ddbbfcca8..acbb9311d03b 100644 --- a/vcl/source/app/i18nhelp.cxx +++ b/vcl/source/app/i18nhelp.cxx @@ -48,11 +48,8 @@ vcl::I18nHelper::~I18nHelper() void vcl::I18nHelper::ImplDestroyWrappers() { - delete mpLocaleDataWrapper; - mpLocaleDataWrapper = nullptr; - - delete mpTransliterationWrapper; - mpTransliterationWrapper= nullptr; + mpLocaleDataWrapper.reset(); + mpTransliterationWrapper.reset(); } utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() const @@ -63,7 +60,7 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co if ( mbTransliterateIgnoreCase ) nModules |= TransliterationFlags::IGNORE_CASE; - const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = new utl::TransliterationWrapper( m_xContext, nModules ); + const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(new utl::TransliterationWrapper( m_xContext, nModules )); const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper->loadModuleIfNeeded( maLanguageTag.getLanguageType() ); } return *mpTransliterationWrapper; @@ -73,7 +70,7 @@ LocaleDataWrapper& vcl::I18nHelper::ImplGetLocaleDataWrapper() const { if ( !mpLocaleDataWrapper ) { - const_cast<vcl::I18nHelper*>(this)->mpLocaleDataWrapper = new LocaleDataWrapper( m_xContext, maLanguageTag ); + const_cast<vcl::I18nHelper*>(this)->mpLocaleDataWrapper.reset(new LocaleDataWrapper( m_xContext, maLanguageTag )); } return *mpLocaleDataWrapper; } @@ -118,8 +115,7 @@ sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString& // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = false; - delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper; - const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr; + const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(); } OUString aStr1( filterFormattingChars(rStr1) ); @@ -136,8 +132,7 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2 // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = true; - delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper; - const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr; + const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(); } OUString aStr1( filterFormattingChars(rStr1) ); commit 4acc2daacbb83869f5e576427b3743ddf80a5578 Author: Noel Grandin <[email protected]> Date: Mon Apr 23 13:30:32 2018 +0200 loplugin:useuniqueptr in PNGWriterImpl Change-Id: Iad753bfeeba7b0b0c1069bbb1411e41612d72f67 Reviewed-on: https://gerrit.libreoffice.org/53352 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx index b5c6178eb1bd..d40e68a137b0 100644 --- a/vcl/source/gdi/pngwrite.cxx +++ b/vcl/source/gdi/pngwrite.cxx @@ -70,9 +70,9 @@ private: BitmapReadAccess* mpMaskAccess; ZCodec mpZCodec; - sal_uInt8* mpDeflateInBuf; // as big as the size of a scanline + alphachannel + 1 - sal_uInt8* mpPreviousScan; // as big as mpDeflateInBuf - sal_uInt8* mpCurrentScan; + std::unique_ptr<sal_uInt8[]> mpDeflateInBuf; // as big as the size of a scanline + alphachannel + 1 + std::unique_ptr<sal_uInt8[]> mpPreviousScan; // as big as mpDeflateInBuf + std::unique_ptr<sal_uInt8[]> mpCurrentScan; sal_uLong mnDeflateInSize; sal_uLong mnWidth; @@ -379,12 +379,12 @@ void PNGWriterImpl::ImplWriteIDAT() mnDeflateInSize = mnBBP * mnWidth + 1; - mpDeflateInBuf = new sal_uInt8[mnDeflateInSize]; + mpDeflateInBuf.reset(new sal_uInt8[mnDeflateInSize]); if (mnFilterType) // using filter type 4 we need memory for the scanline 3 times { - mpPreviousScan = new sal_uInt8[mnDeflateInSize]; - mpCurrentScan = new sal_uInt8[mnDeflateInSize]; + mpPreviousScan.reset(new sal_uInt8[mnDeflateInSize]); + mpCurrentScan.reset(new sal_uInt8[mnDeflateInSize]); ImplClearFirstScanline(); } mpZCodec.BeginCompression(mnCompLevel, true); @@ -394,7 +394,7 @@ void PNGWriterImpl::ImplWriteIDAT() { for (sal_uLong nY = 0; nY < mnHeight; nY++) { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY)); } } else @@ -403,13 +403,13 @@ void PNGWriterImpl::ImplWriteIDAT() sal_uLong nY; for (nY = 0; nY < mnHeight; nY += 8) // pass 1 { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY, 0, 8)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY, 0, 8)); } ImplClearFirstScanline(); for (nY = 0; nY < mnHeight; nY += 8) // pass 2 { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY, 4, 8)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY, 4, 8)); } ImplClearFirstScanline(); @@ -417,14 +417,14 @@ void PNGWriterImpl::ImplWriteIDAT() { for (nY = 4; nY < mnHeight; nY += 8) { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY, 0, 4)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY, 0, 4)); } ImplClearFirstScanline(); } for (nY = 0; nY < mnHeight; nY += 4) // pass 4 { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY, 2, 4)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY, 2, 4)); } ImplClearFirstScanline(); @@ -432,14 +432,14 @@ void PNGWriterImpl::ImplWriteIDAT() { for (nY = 2; nY < mnHeight; nY += 4) { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY, 0, 2)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY, 0, 2)); } ImplClearFirstScanline(); } for (nY = 0; nY < mnHeight; nY += 2) // pass 6 { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter(nY, 1, 2)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter(nY, 1, 2)); } ImplClearFirstScanline(); @@ -447,7 +447,7 @@ void PNGWriterImpl::ImplWriteIDAT() { for (nY = 1; nY < mnHeight; nY += 2) { - mpZCodec.Write(aOStm, mpDeflateInBuf, ImplGetFilter (nY)); + mpZCodec.Write(aOStm, mpDeflateInBuf.get(), ImplGetFilter (nY)); } } } @@ -456,10 +456,10 @@ void PNGWriterImpl::ImplWriteIDAT() if (mnFilterType) // using filter type 4 we need memory for the scanline 3 times { - delete[] mpCurrentScan; - delete[] mpPreviousScan; + mpCurrentScan.reset(); + mpPreviousScan.reset(); } - delete[] mpDeflateInBuf; + mpDeflateInBuf.reset(); sal_uInt32 nIDATSize = aOStm.Tell(); sal_uInt32 nBytes, nBytesToWrite = nIDATSize; @@ -481,9 +481,9 @@ sal_uLong PNGWriterImpl::ImplGetFilter (sal_uLong nY, sal_uLong nXStart, sal_uLo sal_uInt8* pDest; if (mnFilterType) - pDest = mpCurrentScan; + pDest = mpCurrentScan.get(); else - pDest = mpDeflateInBuf; + pDest = mpDeflateInBuf.get(); if (nXStart < mnWidth) { @@ -596,20 +596,20 @@ sal_uLong PNGWriterImpl::ImplGetFilter (sal_uLong nY, sal_uLong nXStart, sal_uLo // filter type4 ( PAETH ) will be used only for 24bit graphics if (mnFilterType) { - mnDeflateInSize = pDest - mpCurrentScan; - pDest = mpDeflateInBuf; + mnDeflateInSize = pDest - mpCurrentScan.get(); + pDest = mpDeflateInBuf.get(); *pDest++ = 4; // filter type - sal_uInt8* p1 = mpCurrentScan + 1; // Current Pixel + sal_uInt8* p1 = mpCurrentScan.get() + 1; // Current Pixel sal_uInt8* p2 = p1 - mnBBP; // left pixel - sal_uInt8* p3 = mpPreviousScan; // upper pixel + sal_uInt8* p3 = mpPreviousScan.get(); // upper pixel sal_uInt8* p4 = p3 - mnBBP; // upperleft Pixel; - while (pDest < mpDeflateInBuf + mnDeflateInSize) + while (pDest < mpDeflateInBuf.get() + mnDeflateInSize) { sal_uLong nb = *p3++; sal_uLong na, nc; - if (p2 >= mpCurrentScan + 1) + if (p2 >= mpCurrentScan.get() + 1) { na = *p2; nc = *p4; @@ -648,7 +648,7 @@ sal_uLong PNGWriterImpl::ImplGetFilter (sal_uLong nY, sal_uLong nXStart, sal_uLo } else { - mnDeflateInSize = pDest - mpDeflateInBuf; + mnDeflateInSize = pDest - mpDeflateInBuf.get(); } return mnDeflateInSize; } @@ -656,7 +656,7 @@ sal_uLong PNGWriterImpl::ImplGetFilter (sal_uLong nY, sal_uLong nXStart, sal_uLo void PNGWriterImpl::ImplClearFirstScanline() { if (mnFilterType) - memset(mpPreviousScan, 0, mnDeflateInSize); + memset(mpPreviousScan.get(), 0, mnDeflateInSize); } void PNGWriterImpl::ImplOpenChunk (sal_uLong nChunkType) commit c2f5a026ca643b104bf88cfb0429de1ea81d38dc Author: Noel Grandin <[email protected]> Date: Mon Apr 23 13:27:54 2018 +0200 loplugin:useuniqueptr in TabControl Change-Id: I4d6ce243c92de740fbb5b6934aaf14dbe28eb18e Reviewed-on: https://gerrit.libreoffice.org/53351 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index 6286ecea7ef7..6fd7cd3841f5 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -50,7 +50,7 @@ class ListBox; class VCL_DLLPUBLIC TabControl : public Control { protected: - ImplTabCtrlData* mpTabCtrlData; + std::unique_ptr<ImplTabCtrlData> mpTabCtrlData; long mnLastWidth; long mnLastHeight; long mnMaxPageWidth; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 13f08e464724..36393f20906c 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -98,7 +98,7 @@ void TabControl::ImplInit( vcl::Window* pParent, WinBits nStyle ) mbFormat = true; mbRestoreHelpId = false; mbSmallInvalidate = false; - mpTabCtrlData = new ImplTabCtrlData; + mpTabCtrlData.reset(new ImplTabCtrlData); mpTabCtrlData->mpListBox = nullptr; ImplInitSettings( true ); @@ -198,8 +198,7 @@ void TabControl::dispose() // delete TabCtrl data if (mpTabCtrlData) mpTabCtrlData->mpListBox.disposeAndClear(); - delete mpTabCtrlData; - mpTabCtrlData = nullptr; + mpTabCtrlData.reset(); Control::dispose(); } commit ffe251f62aec250118598041d3528cee54c65538 Author: Noel Grandin <[email protected]> Date: Mon Apr 23 12:00:52 2018 +0200 loplugin:useuniqueptr in ImplListBoxWindow Change-Id: I9966baf9fd490fec4fb808f7e70470eb690dbc9e Reviewed-on: https://gerrit.libreoffice.org/53350 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx index 313ff8cbd047..1130ad9ef805 100644 --- a/vcl/inc/listbox.hxx +++ b/vcl/inc/listbox.hxx @@ -165,7 +165,7 @@ public: class ImplListBoxWindow : public Control, public vcl::ISearchableStringList { private: - ImplEntryList* mpEntryList; ///< EntryList + std::unique_ptr<ImplEntryList> mpEntryList; ///< EntryList tools::Rectangle maFocusRect; Size maUserItemSize; @@ -255,7 +255,7 @@ public: virtual ~ImplListBoxWindow() override; virtual void dispose() override; - ImplEntryList* GetEntryList() const { return mpEntryList; } + ImplEntryList* GetEntryList() const { return mpEntryList.get(); } sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry ); void RemoveEntry( sal_Int32 nPos ); diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 7dbabad9934a..f4100e13089d 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -461,7 +461,7 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle ) Control( pParent, 0 ), maQuickSelectionEngine( *this ) { - mpEntryList = new ImplEntryList( this ); + mpEntryList.reset(new ImplEntryList( this )); mnTop = 0; mnLeft = 0; @@ -508,7 +508,7 @@ ImplListBoxWindow::~ImplListBoxWindow() void ImplListBoxWindow::dispose() { - delete mpEntryList; + mpEntryList.reset(); Control::dispose(); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
