[Libreoffice-commits] core.git: vcl/inc vcl/win
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Sat Sep 25 17:45:34 UTC 2021
vcl/inc/win/salgdi.h | 3 ++-
vcl/win/gdi/salgdi.cxx | 17 +++++++++++++----
vcl/win/window/salframe.cxx | 27 +++++++++++----------------
3 files changed, 26 insertions(+), 21 deletions(-)
New commits:
commit 7e571e59559dcf80ee0c195533cb0895da175a07
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 15 19:45:58 2021 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat Sep 25 19:45:01 2021 +0200
WIN call RealizePalette from setPalette
I have no idea, how to handle a RealizePalette error or when it
can occur. The previous code has ignored it all together, or
handled it as successful. This now doesn't act on GDI_ERROR.
FWIW GDI_ERROR is defined a ~0 in wine, as it's an UINT.
Change-Id: Ib0aaabcaa8c2d7d7ca93678b6b82db864beb8ce3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122370
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 0f5b700cff26..ec7f4fe13fff 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -177,7 +177,8 @@ public:
void setHDC(HDC aNew);
HPALETTE getDefPal() const;
- void setPalette(HPALETTE, BOOL bForceBkgd = TRUE);
+ // returns the result from RealizePalette, otherwise 0 on success or GDI_ERROR
+ UINT setPalette(HPALETTE, BOOL bForceBkgd = TRUE);
HRGN getRegion() const;
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 6bd510b6effa..ee231f1ac7aa 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -705,28 +705,37 @@ HPALETTE WinSalGraphics::getDefPal() const
return mhDefPal;
}
-void WinSalGraphics::setPalette(HPALETTE hNewPal, BOOL bForceBkgd)
+UINT WinSalGraphics::setPalette(HPALETTE hNewPal, BOOL bForceBkgd)
{
+ UINT res = GDI_ERROR;
+
if (!getHDC())
{
assert(!mhDefPal);
- return;
+ return res;
}
if (hNewPal)
{
HPALETTE hOldPal = SelectPalette(getHDC(), hNewPal, bForceBkgd);
- if (!mhDefPal)
- mhDefPal = hOldPal;
+ if (hOldPal)
+ {
+ if (!mhDefPal)
+ mhDefPal = hOldPal;
+ res = RealizePalette(getHDC());
+ }
}
else
{
+ res = 0;
if (mhDefPal)
{
SelectPalette(getHDC(), mhDefPal, bForceBkgd);
mhDefPal = nullptr;
}
}
+
+ return res;
}
HRGN WinSalGraphics::getRegion() const
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index e995cae356d4..ec97012fad43 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -992,10 +992,7 @@ bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, HWND
return false;
if ( pSalData->mhDitherPal )
- {
pGraphics->setPalette(pSalData->mhDitherPal);
- RealizePalette( hDC );
- }
if ( pGraphics == mpThreadGraphics )
pSalData->mnCacheDCInUse++;
@@ -4153,8 +4150,7 @@ static void ImplHandleForcePalette( HWND hWnd )
WinSalGraphics* pGraphics = pFrame->mpLocalGraphics;
if (pGraphics->getDefPal())
{
- pGraphics->setPalette(hPal, FALSE);
- if ( RealizePalette( pGraphics->getHDC() ) )
+ if (pGraphics->setPalette(hPal, FALSE) != GDI_ERROR)
{
InvalidateRect( hWnd, nullptr, FALSE );
UpdateWindow( hWnd );
@@ -4209,7 +4205,7 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
WinSalGraphics* pGraphics;
HDC hDC;
HPALETTE hOldPal = nullptr;
- UINT nCols;
+ UINT nCols = GDI_ERROR;
bool bUpdate;
pSalData->mbInPalChange = true;
@@ -4241,15 +4237,16 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
{
hDC = GetDC(hWnd);
hOldPal = SelectPalette(hDC, hPal, TRUE);
+ if (hOldPal)
+ nCols = RealizePalette(hDC);
}
else
{
hDC = pFrame->mpLocalGraphics->getHDC();
- pFrame->mpLocalGraphics->setPalette(hPal);
+ nCols = pFrame->mpLocalGraphics->setPalette(hPal);
}
- nCols = RealizePalette( hDC );
- bUpdate = nCols != 0;
+ bUpdate = nCols != 0 && nCols != GDI_ERROR;
if ( !bStdDC )
{
@@ -4264,22 +4261,20 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
{
pGraphics = pTempVD->getGraphics();
if ( pGraphics->getDefPal() )
- {
pGraphics->setPalette(hPal);
- RealizePalette( pGraphics->getHDC() );
- }
pTempVD = pTempVD->getNext();
}
+
pTempFrame = pSalData->mpFirstFrame;
while ( pTempFrame )
{
if ( pTempFrame != pFrame )
{
pGraphics = pTempFrame->mpLocalGraphics;
- if ( pGraphics && pGraphics->getHDC() && pGraphics->getDefPal() )
+ if (pGraphics && pGraphics->getDefPal())
{
- pGraphics->setPalette(hPal);
- if ( RealizePalette( pGraphics->getHDC() ) )
+ UINT nRes = pGraphics->setPalette(hPal);
+ if (nRes != 0 && nRes != GDI_ERROR)
bUpdate = true;
}
}
@@ -4293,7 +4288,7 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
while ( pTempFrame )
{
pGraphics = pTempFrame->mpLocalGraphics;
- if ( pGraphics && pGraphics->getHDC() && pGraphics->getDefPal() )
+ if (pGraphics && pGraphics->getDefPal())
{
InvalidateRect( pTempFrame->mhWnd, nullptr, FALSE );
UpdateWindow( pTempFrame->mhWnd );
More information about the Libreoffice-commits
mailing list