diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-23 10:27:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-24 14:50:21 +0200 |
commit | baa91c67d6fb7f84f94795e6e3727cd0b5b23061 (patch) | |
tree | a28cc45ce17bbbc579a672b47ac38b931324b0f7 /vcl | |
parent | 528a2e51bc5e9d3fd10a03603f4c07b271f0749b (diff) |
loplugin:useuniqueptr in OutputDevice
Change-Id: I6f933b54c11a4939870c3a788a4928f2d6f12850
Reviewed-on: https://gerrit.libreoffice.org/53349
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/PhysicalFontCollection.hxx | 4 | ||||
-rw-r--r-- | vcl/source/font/PhysicalFontCollection.cxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/print.cxx | 49 | ||||
-rw-r--r-- | vcl/source/gdi/virdev.cxx | 12 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 18 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 18 | ||||
-rw-r--r-- | vcl/source/outdev/outdevstate.cxx | 13 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 4 |
8 files changed, 29 insertions, 97 deletions
diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx index 2c32408ce158..1d5dbb908039 100644 --- a/vcl/inc/PhysicalFontCollection.hxx +++ b/vcl/inc/PhysicalFontCollection.hxx @@ -63,8 +63,8 @@ public: // misc utilities PhysicalFontCollection* Clone() const; - ImplDeviceFontList* GetDeviceFontList() const; - ImplDeviceFontSizeList* GetDeviceFontSizeList( const OUString& rFontName ) const; + std::unique_ptr<ImplDeviceFontList> GetDeviceFontList() const; + std::unique_ptr<ImplDeviceFontSizeList> GetDeviceFontSizeList( const OUString& rFontName ) const; private: mutable bool mbMatchData; // true if matching attributes are initialized diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 6f19f8c437b1..848fbdf06122 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -894,9 +894,9 @@ PhysicalFontCollection* PhysicalFontCollection::Clone() const return pClonedCollection; } -ImplDeviceFontList* PhysicalFontCollection::GetDeviceFontList() const +std::unique_ptr<ImplDeviceFontList> PhysicalFontCollection::GetDeviceFontList() const { - ImplDeviceFontList* pDeviceFontList = new ImplDeviceFontList; + std::unique_ptr<ImplDeviceFontList> pDeviceFontList(new ImplDeviceFontList); for (auto const& family : maPhysicalFontFamilies) { @@ -907,9 +907,9 @@ ImplDeviceFontList* PhysicalFontCollection::GetDeviceFontList() const return pDeviceFontList; } -ImplDeviceFontSizeList* PhysicalFontCollection::GetDeviceFontSizeList( const OUString& rFontName ) const +std::unique_ptr<ImplDeviceFontSizeList> PhysicalFontCollection::GetDeviceFontSizeList( const OUString& rFontName ) const { - ImplDeviceFontSizeList* pDeviceFontSizeList = new ImplDeviceFontSizeList; + std::unique_ptr<ImplDeviceFontSizeList> pDeviceFontSizeList(new ImplDeviceFontSizeList); PhysicalFontFamily* pFontFamily = FindFontFamily( rFontName ); if( pFontFamily != nullptr ) diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index fa43dedea7a4..f5780ea2680f 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -586,17 +586,8 @@ void Printer::ImplReleaseFonts() mpFontInstance = nullptr; } - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); } void Printer::ReleaseGraphics( bool bRelease ) @@ -960,16 +951,8 @@ void Printer::dispose() mpFontInstance->Release(); mpFontInstance = nullptr; } - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); delete mpFontCache; mpFontCache = nullptr; // font list deleted by OutputDevice dtor @@ -1109,16 +1092,8 @@ bool Printer::SetPrinterProps( const Printer* pPrinter ) mpFontInstance->Release(); mpFontInstance = nullptr; } - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); // clean up font list delete mpFontCache; delete mpFontCollection; @@ -1152,16 +1127,8 @@ bool Printer::SetPrinterProps( const Printer* pPrinter ) mpFontInstance->Release(); mpFontInstance = nullptr; } - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); delete mpFontCache; delete mpFontCollection; mpFontCache = nullptr; diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index bcd5541dcd7e..9ab205f983c9 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -498,16 +498,8 @@ void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32 mpFontInstance->Release(); mpFontInstance = nullptr; } - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); // preserve global font lists ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index bd112469404d..94308054b03c 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -75,9 +75,7 @@ int OutputDevice::GetDevFontCount() const if (!mpDeviceFontList->Count()) { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - + mpDeviceFontList.reset(); return 0; } } @@ -92,7 +90,7 @@ bool OutputDevice::IsFontAvailable( const OUString& rFontName ) const int OutputDevice::GetDevFontSizeCount( const vcl::Font& rFont ) const { - delete mpDeviceFontSizeList; + mpDeviceFontSizeList.reset(); ImplInitFontList(); mpDeviceFontSizeList = mpFontCollection->GetDeviceFontSizeList( rFont.GetFamilyName() ); @@ -488,16 +486,8 @@ void OutputDevice::ImplClearFontData( const bool bNewFontLists ) if ( bNewFontLists ) { - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); // release all physically selected fonts on this device if( AcquireGraphics() ) diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index b44eedda0818..82833c72d819 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -62,7 +62,7 @@ OutputDevice::OutputDevice() : mpFontCollection = nullptr; mpDeviceFontList = nullptr; mpDeviceFontSizeList = nullptr; - mpOutDevStateStack = new OutDevStateStack; + mpOutDevStateStack.reset(new OutDevStateStack); mpPDFWriter = nullptr; mpAlphaVDev = nullptr; mpExtOutDevData = nullptr; @@ -128,7 +128,7 @@ OutputDevice::OutputDevice() : maThresRes.mnThresPixToLogY = 0; // struct ImplOutDevData- see #i82615# - mpOutDevData = new ImplOutDevData; + mpOutDevData.reset(new ImplOutDevData); mpOutDevData->mpRotateDev = nullptr; mpOutDevData->mpRecordLayout = nullptr; @@ -158,8 +158,7 @@ void OutputDevice::dispose() // #i75163# ImplInvalidateViewTransform(); - delete mpOutDevData; - mpOutDevData = nullptr; + mpOutDevData.reset(); // for some reason, we haven't removed state from the stack properly if ( !mpOutDevStateStack->empty() ) @@ -170,20 +169,15 @@ void OutputDevice::dispose() mpOutDevStateStack->pop_back(); } } - delete mpOutDevStateStack; - mpOutDevStateStack = nullptr; + mpOutDevStateStack.reset(); // release the active font instance if( mpFontInstance ) mpFontInstance->Release(); // remove cached results of GetDevFontList/GetDevSizeList - // TODO: use smart pointers for them - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); // release ImplFontCache specific to this OutputDevice // TODO: refcount ImplFontCache diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index d2226add6f1b..6713f6481369 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -621,17 +621,8 @@ void OutputDevice::ImplReleaseFonts() mpFontInstance = nullptr; } - if ( mpDeviceFontList ) - { - delete mpDeviceFontList; - mpDeviceFontList = nullptr; - } - - if ( mpDeviceFontSizeList ) - { - delete mpDeviceFontSizeList; - mpDeviceFontSizeList = nullptr; - } + mpDeviceFontList.reset(); + mpDeviceFontSizeList.reset(); } diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index f6deaaf6b1e8..6fe84173c710 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -314,7 +314,7 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFon } // last level fallback, check each font type face one by one - ImplDeviceFontList* pTestFontList = pFontCollection->GetDeviceFontList(); + std::unique_ptr<ImplDeviceFontList> pTestFontList = pFontCollection->GetDeviceFontList(); // limit the count of fonts to be checked to prevent hangs static const int MAX_GFBFONT_COUNT = 600; int nTestFontCount = pTestFontList->Count(); @@ -332,8 +332,6 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFon break; } - delete pTestFontList; - return bFound; } |