[Libreoffice-commits] core.git: include/vcl vcl/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Wed May 20 20:52:35 UTC 2020
include/vcl/outdev.hxx | 2 +-
include/vcl/window.hxx | 2 +-
vcl/source/outdev/outdev.cxx | 26 ++++++++++++--------------
vcl/source/window/window.cxx | 40 +++++++++-------------------------------
4 files changed, 23 insertions(+), 47 deletions(-)
New commits:
commit 1110726b24de47f598edf6e6d4578cd7d7a15f78
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed May 20 17:12:43 2020 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed May 20 22:52:01 2020 +0200
Restructure DrawOutDevDirectCheck to avoid using uninitialized pointer
The check for source device's mpGraphics is moved into drawOutDevDirect,
since failing it must result in immediate return from the function.
Check for this->mpGraphics also moved into drawOutDevDirect, since it's
dereferenced in DrawOutDevDirectProcess, unclear why was it skipped in
some cases previously.
Removed unreachable warning.
Change-Id: I4ad882f8f60d6543786aef2ec1651e499d47874d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94463
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index f2e19567150e..e7c014ee3561 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -561,7 +561,7 @@ protected:
virtual tools::Rectangle SetBackgroundComponentBounds();
- virtual void DrawOutDevDirectCheck( const OutputDevice* pSrcDev, SalGraphics*& pSrcGraphics );
+ virtual const OutputDevice* DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const;
virtual void DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics );
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 2214c0a3b1ed..4b484eacba1c 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -753,7 +753,7 @@ protected:
virtual void ImplAdjustNWFSizes();
virtual void CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate) override;
- virtual void DrawOutDevDirectCheck(const OutputDevice* pSrcDev, SalGraphics*& pSrcGraphics) override;
+ virtual const OutputDevice* DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const override;
virtual void DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) override;
virtual void ClipToPaintRegion( tools::Rectangle& rDstRect ) override;
virtual bool UsePolyPolygonForComplexGradient() override;
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index fe06032d7ca0..e53f1cd81f3b 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -517,9 +517,17 @@ void OutputDevice::CopyDeviceArea( SalTwoRect& aPosAry, bool /*bWindowInvalidate
void OutputDevice::drawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& rPosAry )
{
SalGraphics* pSrcGraphics;
- SalGraphics*& pSrcGraphicsRef = pSrcGraphics;
+ if (const OutputDevice* pCheckedSrc = DrawOutDevDirectCheck(pSrcDev))
+ {
+ if (!pCheckedSrc->mpGraphics && !pCheckedSrc->AcquireGraphics())
+ return;
+ pSrcGraphics = pCheckedSrc->mpGraphics;
+ }
+ else
+ pSrcGraphics = nullptr;
- DrawOutDevDirectCheck(pSrcDev, pSrcGraphicsRef);
+ if (!mpGraphics && !AcquireGraphics())
+ return;
// #102532# Offset only has to be pseudo window offset
const tools::Rectangle aSrcOutRect( Point( pSrcDev->mnOutOffX, pSrcDev->mnOutOffY ),
@@ -537,19 +545,9 @@ void OutputDevice::drawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& rP
}
}
-void OutputDevice::DrawOutDevDirectCheck( const OutputDevice* pSrcDev, SalGraphics*& pSrcGraphics )
+const OutputDevice* OutputDevice::DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const
{
- if ( this == pSrcDev )
- pSrcGraphics = nullptr;
- else
- {
- if ( !pSrcDev->mpGraphics )
- {
- if ( !pSrcDev->AcquireGraphics() )
- return;
- }
- pSrcGraphics = pSrcDev->mpGraphics;
- }
+ return this == pSrcDev ? nullptr : pSrcDev;
}
void OutputDevice::DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index ebba8bfb7f33..648dbcf52519 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1247,41 +1247,19 @@ void Window::CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate )
OutputDevice::CopyDeviceArea(aPosAry, bWindowInvalidate);
}
-void Window::DrawOutDevDirectCheck(const OutputDevice* pSrcDev, SalGraphics*& pSrcGraphics)
+const OutputDevice* Window::DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const
{
+ const OutputDevice* pSrcDevChecked;
if ( this == pSrcDev )
- pSrcGraphics = nullptr;
+ pSrcDevChecked = nullptr;
+ else if (GetOutDevType() != pSrcDev->GetOutDevType())
+ pSrcDevChecked = pSrcDev;
+ else if (this->mpWindowImpl->mpFrameWindow == static_cast<const vcl::Window*>(pSrcDev)->mpWindowImpl->mpFrameWindow)
+ pSrcDevChecked = nullptr;
else
- {
- if ( GetOutDevType() != pSrcDev->GetOutDevType() )
- {
- if ( !pSrcDev->mpGraphics )
- {
- if ( !pSrcDev->AcquireGraphics() )
- return;
- }
- pSrcGraphics = pSrcDev->mpGraphics;
- }
- else
- {
- if ( this->mpWindowImpl->mpFrameWindow == static_cast<const vcl::Window*>(pSrcDev)->mpWindowImpl->mpFrameWindow )
- pSrcGraphics = nullptr;
- else
- {
- if ( !pSrcDev->mpGraphics )
- {
- if ( !pSrcDev->AcquireGraphics() )
- return;
- }
- pSrcGraphics = pSrcDev->mpGraphics;
+ pSrcDevChecked = pSrcDev;
- if ( !mpGraphics && !AcquireGraphics() )
- return;
- SAL_WARN_IF( !mpGraphics || !pSrcDev->mpGraphics, "vcl.gdi",
- "OutputDevice::DrawOutDev(): We need more than one Graphics" );
- }
- }
- }
+ return pSrcDevChecked;
}
void Window::DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
More information about the Libreoffice-commits
mailing list