diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-02-09 11:06:05 +1100 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-02-09 11:06:05 +1100 |
| commit | e529ca0ed34e81f40a1dbe3be4114a4e0ec267d6 (patch) | |
| tree | 1572e79501d09eddf20b62b298bf5358d9e6c372 | |
| parent | e79fadf10d92ade023c86d20891829c3dd02d5ee (diff) | |
| download | scintilla-mirror-e529ca0ed34e81f40a1dbe3be4114a4e0ec267d6.tar.gz | |
Backport: Use uniform initialization for resetting GDI handles to avoid NULL/0 warnings.
Changed HDC, HPEN, HBRUSH, HFONT, HRGN, and HBITMAP.
Backport of changeset 7980:587c0b6a5317.
| -rw-r--r-- | win32/PlatWin.cxx | 40 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 10 |
2 files changed, 25 insertions, 25 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 0ffa9323d..0102fbb01 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -221,12 +221,12 @@ HFONT FormatAndMetrics::HFont() { #if defined(USE_D2D) if (technology == SCWIN_TECH_GDI) { if (0 == ::GetObjectW(hfont, sizeof(lf), &lf)) { - return 0; + return {}; } } else { const HRESULT hr = pTextFormat->GetFontFamilyName(lf.lfFaceName, LF_FACESIZE); if (!SUCCEEDED(hr)) { - return 0; + return {}; } lf.lfWeight = pTextFormat->GetFontWeight(); lf.lfItalic = pTextFormat->GetFontStyle() == DWRITE_FONT_STYLE_ITALIC; @@ -234,7 +234,7 @@ HFONT FormatAndMetrics::HFont() { } #else if (0 == ::GetObjectW(hfont, sizeof(lf), &lf)) { - return 0; + return {}; } #endif return ::CreateFontIndirectW(&lf); @@ -510,29 +510,29 @@ void SurfaceGDI::Clear() noexcept { if (penOld) { ::SelectObject(hdc, penOld); ::DeleteObject(pen); - penOld = 0; + penOld = {}; } - pen = 0; + pen = {}; if (brushOld) { ::SelectObject(hdc, brushOld); ::DeleteObject(brush); - brushOld = 0; + brushOld = {}; } - brush = 0; + brush = {}; if (fontOld) { // Fonts are not deleted as they are owned by a Font object ::SelectObject(hdc, fontOld); - fontOld = 0; + fontOld = {}; } if (bitmapOld) { ::SelectObject(hdc, bitmapOld); ::DeleteObject(bitmap); - bitmapOld = 0; + bitmapOld = {}; } - bitmap = 0; + bitmap = {}; if (hdcOwned) { ::DeleteDC(hdc); - hdc = 0; + hdc = {}; hdcOwned = false; } } @@ -547,7 +547,7 @@ bool SurfaceGDI::Initialised() { void SurfaceGDI::Init(WindowID) { Release(); - hdc = ::CreateCompatibleDC(NULL); + hdc = ::CreateCompatibleDC({}); hdcOwned = true; ::SetTextAlign(hdc, TA_BASELINE); } @@ -574,8 +574,8 @@ void SurfaceGDI::PenColour(ColourDesired fore) { if (pen) { ::SelectObject(hdc, penOld); ::DeleteObject(pen); - pen = 0; - penOld = 0; + pen = {}; + penOld = {}; } pen = ::CreatePen(0,1,fore.AsInteger()); penOld = SelectPen(hdc, pen); @@ -585,8 +585,8 @@ void SurfaceGDI::BrushColour(ColourDesired back) noexcept { if (brush) { ::SelectObject(hdc, brushOld); ::DeleteObject(brush); - brush = 0; - brushOld = 0; + brush = {}; + brushOld = {}; } // Only ever want pure, non-dithered brushes const ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsInteger())); @@ -957,8 +957,8 @@ void SurfaceGDI::SetClip(PRectangle rc) { } void SurfaceGDI::FlushCachedState() { - pen = 0; - brush = 0; + pen = {}; + brush = {}; } void SurfaceGDI::SetUnicodeMode(bool unicodeMode_) { @@ -1103,7 +1103,7 @@ void SurfaceD2D::Release() { } void SurfaceD2D::SetScale() { - HDC hdcMeasure = ::CreateCompatibleDC(NULL); + HDC hdcMeasure = ::CreateCompatibleDC({}); logPixelsY = ::GetDeviceCaps(hdcMeasure, LOGPIXELSY); dpiScaleX = ::GetDeviceCaps(hdcMeasure, LOGPIXELSX) / 96.0f; dpiScaleY = logPixelsY / 96.0f; @@ -1820,7 +1820,7 @@ void Window::SetFont(Font &font) { namespace { void FlipBitmap(HBITMAP bitmap, int width, int height) noexcept { - HDC hdc = ::CreateCompatibleDC(NULL); + HDC hdc = ::CreateCompatibleDC({}); if (hdc) { HBITMAP prevBmp = SelectBitmap(hdc, bitmap); ::StretchBlt(hdc, width - 1, 0, -width, height, hdc, 0, 0, width, height, SRCCOPY); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 5b42a85bc..d543ca940 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -482,7 +482,7 @@ ScintillaWin::ScintillaWin(HWND hwnd) { linesPerScroll = 0; wheelDelta = 0; // Wheel delta from roll - hRgnUpdate = 0; + hRgnUpdate = {}; hasOKText = false; @@ -506,7 +506,7 @@ ScintillaWin::ScintillaWin(HWND hwnd) { ds.sci = this; dt.sci = this; - sysCaretBitmap = 0; + sysCaretBitmap = {}; sysCaretWidth = 0; sysCaretHeight = 0; @@ -908,7 +908,7 @@ sptr_t ScintillaWin::WndPaint() { } if (hRgnUpdate) { ::DeleteRgn(hRgnUpdate); - hRgnUpdate = 0; + hRgnUpdate = {}; } ::EndPaint(MainHWND(), &ps); @@ -3071,7 +3071,7 @@ void ScintillaWin::FullPaint() { FullPaintDC(hdc); ::ReleaseDC(MainHWND(), hdc); } else { - FullPaintDC(0); + FullPaintDC({}); } } @@ -3400,7 +3400,7 @@ BOOL ScintillaWin::DestroySystemCaret() noexcept { const BOOL retval = ::DestroyCaret(); if (sysCaretBitmap) { ::DeleteObject(sysCaretBitmap); - sysCaretBitmap = 0; + sysCaretBitmap = {}; } return retval; } |
