summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorXisco Faulí <xiscofauli@libreoffice.org>2019-01-22 14:04:22 +0100
committerXisco Faulí <xiscofauli@libreoffice.org>2019-01-22 17:09:46 +0100
commit81ab8e736fafbe826008939568e2d446204ae080 (patch)
tree95edc4ce60016fdac09398b3dafc6a258f3a51d5 /vcl/win
parent03e28b32ee1fe527da14af39eae429057abc25f2 (diff)
Revert "tdf#107792 vcl/win: do not afraid to delete stock objects"
This reverts commit b940eb5903f583089e99042d60ceae635ae2af83. So far tdf#122877, tdf#122867 and tdf#122851 have been found Change-Id: Id69db9e705001aa8b561642b4bb9e70a2fc3fcbd Reviewed-on: https://gerrit.libreoffice.org/66737 Reviewed-by: Dmitriy Shilin <dshil@fastmail.com> Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/gdiimpl.cxx46
-rw-r--r--vcl/win/gdi/gdiimpl.hxx2
2 files changed, 42 insertions, 6 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index b3f5b0735bb0..a9406729fa21 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -210,7 +210,9 @@ WinSalGraphicsImpl::WinSalGraphicsImpl(WinSalGraphics& rParent):
mbXORMode(false),
mbPen(false),
mhPen(nullptr),
+ mbStockPen(false),
mbBrush(false),
+ mbStockBrush(false),
mhBrush(nullptr)
{
}
@@ -218,10 +220,16 @@ WinSalGraphicsImpl::WinSalGraphicsImpl(WinSalGraphics& rParent):
WinSalGraphicsImpl::~WinSalGraphicsImpl()
{
if ( mhPen )
- DeletePen( mhPen );
+ {
+ if ( !mbStockPen )
+ DeletePen( mhPen );
+ }
if ( mhBrush )
- DeleteBrush( mhBrush );
+ {
+ if ( !mbStockBrush )
+ DeleteBrush( mhBrush );
+ }
}
void WinSalGraphicsImpl::Init()
@@ -1278,6 +1286,7 @@ void WinSalGraphicsImpl::SetLineColor()
// set new data
mbPen = FALSE;
+ mbStockPen = TRUE;
}
void WinSalGraphicsImpl::SetLineColor(Color nColor)
@@ -1285,8 +1294,12 @@ void WinSalGraphicsImpl::SetLineColor(Color nColor)
COLORREF nPenColor = PALETTERGB(nColor.GetRed(),
nColor.GetGreen(),
nColor.GetBlue());
+ bool bStockPen = false;
+
HPEN hNewPen = SearchStockPen(nPenColor);
- if (!hNewPen)
+ if (hNewPen)
+ bStockPen = true;
+ else
hNewPen = MakePen(nColor);
ResetPen(hNewPen);
@@ -1295,6 +1308,7 @@ void WinSalGraphicsImpl::SetLineColor(Color nColor)
mnPenColor = nPenColor;
maLineColor = nColor;
mbPen = TRUE;
+ mbStockPen = bStockPen;
}
HPEN WinSalGraphicsImpl::SearchStockPen(COLORREF nPenColor)
@@ -1336,9 +1350,16 @@ void WinSalGraphicsImpl::ResetPen(HPEN hNewPen)
HPEN hOldPen = SelectPen(mrParent.getHDC(), hNewPen);
if (mhPen)
- DeletePen(mhPen);
+ {
+ if (!mbStockPen)
+ {
+ DeletePen(mhPen);
+ }
+ }
else
+ {
mrParent.mhDefPen = hOldPen;
+ }
mhPen = hNewPen;
}
@@ -1349,6 +1370,7 @@ void WinSalGraphicsImpl::SetFillColor()
// set new data
mbBrush = FALSE;
+ mbStockBrush = TRUE;
}
void WinSalGraphicsImpl::SetFillColor(Color nColor)
@@ -1356,8 +1378,12 @@ void WinSalGraphicsImpl::SetFillColor(Color nColor)
COLORREF nBrushColor = PALETTERGB(nColor.GetRed(),
nColor.GetGreen(),
nColor.GetBlue());
+ bool bStockBrush = false;
+
HBRUSH hNewBrush = SearchStockBrush(nBrushColor);
- if (!hNewBrush)
+ if (hNewBrush)
+ bStockBrush = true;
+ else
hNewBrush = MakeBrush(nColor);
ResetBrush(hNewBrush);
@@ -1366,6 +1392,7 @@ void WinSalGraphicsImpl::SetFillColor(Color nColor)
mnBrushColor = nBrushColor;
maFillColor = nColor;
mbBrush = TRUE;
+ mbStockBrush = bStockBrush;
}
HBRUSH WinSalGraphicsImpl::SearchStockBrush(COLORREF nBrushColor)
@@ -1498,9 +1525,16 @@ void WinSalGraphicsImpl::ResetBrush(HBRUSH hNewBrush)
HBRUSH hOldBrush = SelectBrush(mrParent.getHDC(), hNewBrush);
if (mhBrush)
- DeleteBrush(mhBrush);
+ {
+ if (!mbStockBrush)
+ {
+ DeleteBrush(mhBrush);
+ }
+ }
else
+ {
mrParent.mhDefBrush = hOldBrush;
+ }
mhBrush = hNewBrush;
}
diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx
index e96b226457f7..f1cd729daf1b 100644
--- a/vcl/win/gdi/gdiimpl.hxx
+++ b/vcl/win/gdi/gdiimpl.hxx
@@ -38,7 +38,9 @@ private:
bool mbXORMode : 1; // _every_ output with RasterOp XOR
bool mbPen : 1; // is Pen (FALSE == NULL_PEN)
HPEN mhPen; // Pen
+ bool mbStockPen : 1; // is Pen a stockpen
bool mbBrush : 1; // is Brush (FALSE == NULL_BRUSH)
+ bool mbStockBrush : 1; // is Brush a stockbrush
HBRUSH mhBrush; // Brush
COLORREF mnPenColor; // PenColor
COLORREF mnBrushColor; // BrushColor