From db705286b0f31634e3ad1507d67bffb71ff234fd Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Tue, 10 Jul 2012 14:59:04 +1000 Subject: Avoid warnings from Visual Studio Code Analysis for unchecked values and a loop with unclear termination. --- win32/PlatWin.cxx | 107 +++++++++++++++++++++++++------------------------ win32/ScintillaWin.cxx | 3 +- 2 files changed, 57 insertions(+), 53 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index aa98918b8..d791ff45b 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -772,44 +772,46 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil HBITMAP hbmMem = CreateDIBSection(reinterpret_cast(hMemDC), &bpih, DIB_RGB_COLORS, &image, NULL, 0); - HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); - - DWORD valEmpty = dwordFromBGRA(0,0,0,0); - DWORD valFill = dwordFromBGRA( - static_cast(GetBValue(fill.AsLong()) * alphaFill / 255), - static_cast(GetGValue(fill.AsLong()) * alphaFill / 255), - static_cast(GetRValue(fill.AsLong()) * alphaFill / 255), - static_cast(alphaFill)); - DWORD valOutline = dwordFromBGRA( - static_cast(GetBValue(outline.AsLong()) * alphaOutline / 255), - static_cast(GetGValue(outline.AsLong()) * alphaOutline / 255), - static_cast(GetRValue(outline.AsLong()) * alphaOutline / 255), - static_cast(alphaOutline)); - DWORD *pixels = reinterpret_cast(image); - for (int y=0; y(GetBValue(fill.AsLong()) * alphaFill / 255), + static_cast(GetGValue(fill.AsLong()) * alphaFill / 255), + static_cast(GetRValue(fill.AsLong()) * alphaFill / 255), + static_cast(alphaFill)); + DWORD valOutline = dwordFromBGRA( + static_cast(GetBValue(outline.AsLong()) * alphaOutline / 255), + static_cast(GetGValue(outline.AsLong()) * alphaOutline / 255), + static_cast(GetRValue(outline.AsLong()) * alphaOutline / 255), + static_cast(alphaOutline)); + DWORD *pixels = reinterpret_cast(image); + for (int y=0; y(hdc), rc.left, rc.top, width, height, hMemDC, 0, 0, width, height, merge); + AlphaBlendFn(reinterpret_cast(hdc), rc.left, rc.top, width, height, hMemDC, 0, 0, width, height, merge); - SelectBitmap(hMemDC, hbmOld); - ::DeleteObject(hbmMem); + SelectBitmap(hMemDC, hbmOld); + ::DeleteObject(hbmMem); + } ::DeleteDC(hMemDC); } else { BrushColor(outline); @@ -832,26 +834,28 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig unsigned char *image = 0; HBITMAP hbmMem = CreateDIBSection(reinterpret_cast(hMemDC), &bpih, DIB_RGB_COLORS, reinterpret_cast(&image), NULL, 0); - HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); + if (hbmMem) { + HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); - for (int y=height-1; y>=0; y--) { - for (int x=0; x=0; y--) { + for (int x=0; x(hdc), rc.left, rc.top, rc.Width(), rc.Height(), hMemDC, 0, 0, width, height, merge); + AlphaBlendFn(reinterpret_cast(hdc), rc.left, rc.top, rc.Width(), rc.Height(), hMemDC, 0, 0, width, height, merge); - SelectBitmap(hMemDC, hbmOld); - ::DeleteObject(hbmMem); + SelectBitmap(hMemDC, hbmOld); + ::DeleteObject(hbmMem); + } ::DeleteDC(hMemDC); } @@ -2491,14 +2495,13 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) { // the listbox is not visible. SetRedraw(false); Clear(); - size_t size = strlen(list) + 1; - char *words = new char[size]; + size_t size = strlen(list); + char *words = new char[size+1]; lti.SetWords(words); - memcpy(words, list, size); + memcpy(words, list, size+1); char *startword = words; char *numword = NULL; - int i = 0; - for (; words[i]; i++) { + for (size_t i=0; i < size; i++) { if (words[i] == separator) { words[i] = '\0'; if (numword) diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index c2727607b..80abc69d9 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -385,7 +385,8 @@ void ScintillaWin::Initialise() { // Find TrackMouseEvent which is available on Windows > 95 HMODULE user32 = ::GetModuleHandle(TEXT("user32.dll")); - TrackMouseEventFn = (TrackMouseEventSig)::GetProcAddress(user32, "TrackMouseEvent"); + if (user32) + TrackMouseEventFn = (TrackMouseEventSig)::GetProcAddress(user32, "TrackMouseEvent"); if (TrackMouseEventFn == NULL) { // Windows 95 has an emulation in comctl32.dll:_TrackMouseEvent HMODULE commctrl32 = ::LoadLibrary(TEXT("comctl32.dll")); -- cgit v1.2.3