--- old/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp 2019-12-01 13:40:13.729031600 +0000 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp 2019-12-01 13:40:11.348422900 +0000 @@ -1374,7 +1374,7 @@ { HDC hDC; // First, release the DCs scheduled for deletion - ReleaseDCList(GetHWnd(), passiveDCList); + ReleaseDCList(passiveDCList); GetDCReturnStruct *returnStruct = new GetDCReturnStruct; returnStruct->gdiLimitReached = FALSE; @@ -1402,7 +1402,7 @@ { HDC hDC = (HDC)wParam; MoveDCToPassiveList(hDC, GetHWnd()); - ReleaseDCList(GetHWnd(), passiveDCList); + ReleaseDCList(passiveDCList); mr = mrConsume; break; } @@ -1411,7 +1411,7 @@ // Called during Component destruction. Gets current list of // DC's associated with Component and releases each DC. ReleaseDCList(GetHWnd(), activeDCList); - ReleaseDCList(GetHWnd(), passiveDCList); + ReleaseDCList(passiveDCList); mr = mrConsume; break; } @@ -7436,6 +7436,19 @@ return newListPtr; } +/** + * Remove all DCs from the DC list. Return the list of those + * DC's to the caller (which will then probably want to + * call ReleaseDC() for the returned DCs). + */ +DCItem *DCList::RemoveAllDCs() +{ + listLock.Enter(); + DCItem *newListPtr = head; + head = NULL; + listLock.Leave(); + return newListPtr; +} /** * Realize palettes of all existing HDC objects @@ -7458,8 +7471,7 @@ } } -void ReleaseDCList(HWND hwnd, DCList &list) { - DCItem *removedDCs = list.RemoveAllDCs(hwnd); +static void ReleaseDCList(DCItem *removedDCs) { while (removedDCs) { DCItem *tmpDCList = removedDCs; DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC); @@ -7473,3 +7485,11 @@ delete tmpDCList; } } + +void ReleaseDCList(HWND hwnd, DCList &list) { + ReleaseDCList(list.RemoveAllDCs(hwnd)); +} + +void ReleaseDCList(DCList &list) { + ReleaseDCList(list.RemoveAllDCs()); +} --- old/src/java.desktop/windows/native/libawt/windows/awt_Component.h 2019-12-01 13:40:37.233912600 +0000 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Component.h 2019-12-01 13:40:35.182558900 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -923,10 +923,12 @@ void AddDCItem(DCItem *newItem); DCItem *RemoveDC(HDC hDC, HWND hWnd); DCItem *RemoveAllDCs(HWND hWnd); + DCItem *RemoveAllDCs(); void RealizePalettes(int screen); }; void ReleaseDCList(HWND hwnd, DCList &list); +void ReleaseDCList(DCList &list); void MoveDCToPassiveList(HDC hDC, HWND hWnd); #include "ObjectList.h"