From cb9be0e492d047648185ae80553220fd9b538746 Mon Sep 17 00:00:00 2001 From: Tamas Bunth Date: Wed, 7 Jun 2017 04:38:27 +0200 Subject: Replace vcl::SalLayout Release with destructor Replace SalLayout::Release() with normal destructor mechanism. Release() uses reference counting for the layout. But in practice, the reference counting variable is initialized in ctor and is not incremented elsewhere. So I removed the Release() method and replaced all the Release() calls with 'delete'. It will make easier the use of smart pointers and decrease the chance of memory leaks. Change-Id: Ia2e142dea10b87e232d5757d84778e62d87cf081 Reviewed-on: https://gerrit.libreoffice.org/38488 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- vcl/source/outdev/font.cxx | 4 ++-- vcl/source/outdev/text.cxx | 32 ++++++++++++++++---------------- vcl/source/outdev/textline.cxx | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'vcl/source/outdev') diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 5bad32a22e44..f588853feb3c 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1334,7 +1334,7 @@ SalLayout* OutputDevice::getFallbackFont( if (!pFallback->LayoutText(rLayoutArgs)) { // there is no need for a font that couldn't resolve anything - pFallback->Release(); + delete pFallback; return nullptr; } @@ -1457,7 +1457,7 @@ sal_Int32 OutputDevice::ValidateKashidas ( const OUString& rTxt, ++nDropped; } } - pSalLayout->Release(); + delete pSalLayout; return nDropped; } diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index f99cf54a9cb3..15eaeb434433 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -878,7 +878,7 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr, if( pSalLayout ) { ImplDrawText( *pSalLayout ); - pSalLayout->Release(); + delete pSalLayout; } if( mpAlphaVDev ) @@ -943,7 +943,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr, if( pSalLayout ) { ImplDrawText( *pSalLayout ); - pSalLayout->Release(); + delete pSalLayout; } if( mpAlphaVDev ) @@ -986,7 +986,7 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry, } DeviceCoordinate nWidth = pSalLayout->FillDXArray( pDXPixelArray.get() ); int nWidthFactor = pSalLayout->GetUnitsPerPixel(); - pSalLayout->Release(); + delete pSalLayout; // convert virtual char widths to virtual absolute positions if( pDXPixelArray ) @@ -1031,7 +1031,7 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry, long nWidth = pSalLayout->FillDXArray( pDXAry ); int nWidthFactor = pSalLayout->GetUnitsPerPixel(); - pSalLayout->Release(); + delete pSalLayout; // convert virtual char widths to virtual absolute positions if( pDXAry ) @@ -1075,7 +1075,7 @@ bool OutputDevice::GetCaretPositions( const OUString& rStr, long* pCaretXArray, int nWidthFactor = pSalLayout->GetUnitsPerPixel(); pSalLayout->GetCaretPositions( 2*nLen, pCaretXArray ); long nWidth = pSalLayout->GetTextWidth(); - pSalLayout->Release(); + delete pSalLayout; // fixup unknown caret positions int i; @@ -1135,7 +1135,7 @@ void OutputDevice::DrawStretchText( const Point& rStartPt, sal_uLong nWidth, if( pSalLayout ) { ImplDrawText( *pSalLayout ); - pSalLayout->Release(); + delete pSalLayout; } if( mpAlphaVDev ) @@ -1313,7 +1313,7 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, // layout text if( pSalLayout && !pSalLayout->LayoutText( aLayoutArgs ) ) { - pSalLayout->Release(); + delete pSalLayout; pSalLayout = nullptr; } @@ -1358,7 +1358,7 @@ std::shared_ptr OutputDevice::CreateTextLayoutCache( return nullptr; std::shared_ptr const ret( pSalLayout->CreateTextLayoutCache(copyBecausePrepareModifiesIt)); - pSalLayout->Release(); + delete pSalLayout; return ret; } @@ -1399,7 +1399,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, } nRetVal = pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor ); - pSalLayout->Release(); + delete pSalLayout; } return nRetVal; @@ -1445,7 +1445,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, { // calculate subpixel width of hyphenation character long nHyphenPixelWidth = pHyphenLayout->GetTextWidth() * nSubPixelFactor; - pHyphenLayout->Release(); + delete pHyphenLayout; // calculate hyphenated break position nTextPixelWidth -= nHyphenPixelWidth; @@ -1458,7 +1458,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, rHyphenPos = nRetVal; } - pSalLayout->Release(); + delete pSalLayout; } return nRetVal; @@ -2326,7 +2326,7 @@ SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, c // Get font data aSysLayoutData.orientation = pLayout->GetOrientation(); - pLayout->Release(); + delete pLayout; return aSysLayoutData; } @@ -2352,7 +2352,7 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect, { nXOffset = pSalLayout->GetTextWidth(); nXOffset /= pSalLayout->GetUnitsPerPixel(); - pSalLayout->Release(); + delete pSalLayout; // TODO: fix offset calculation for Bidi case if( nBase < nIndex) nXOffset = -nXOffset; @@ -2390,7 +2390,7 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect, rRect += Point( maMapRes.mnMapOfsX, maMapRes.mnMapOfsY ); } - pSalLayout->Release(); + delete pSalLayout; } return bRet; @@ -2438,7 +2438,7 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector, if( pSalLayout ) { nXOffset = pSalLayout->GetTextWidth(); - pSalLayout->Release(); + delete pSalLayout; // TODO: fix offset calculation for Bidi case if( nBase > nIndex) nXOffset = -nXOffset; @@ -2476,7 +2476,7 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector, } } - pSalLayout->Release(); + delete pSalLayout; } if( bOldMap ) diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 69e473810f74..427a8d95e595 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -604,7 +604,7 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, if( pLayout ) { nStrikeoutWidth = pLayout->GetTextWidth() / (nTestStrLen * pLayout->GetUnitsPerPixel()); - pLayout->Release(); + delete pLayout; } if( nStrikeoutWidth <= 0 ) // sanity check return; @@ -664,7 +664,7 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, pLayout->DrawText( *mpGraphics ); - pLayout->Release(); + delete pLayout; Pop(); SetTextColor( aOldColor ); -- cgit