11/*
2- * Copyright (c) 1996,2019 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1996,2020 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -1374,7 +1374,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
13741374 {
13751375 HDC hDC;
13761376// First, release the DCs scheduled for deletion
1377- ReleaseDCList (GetHWnd (), passiveDCList);
1377+ ReleaseDCList (passiveDCList);
13781378
13791379 GetDCReturnStruct *returnStruct =new GetDCReturnStruct;
13801380 returnStruct->gdiLimitReached =FALSE ;
@@ -1402,7 +1402,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
14021402 {
14031403 HDC hDC = (HDC)wParam;
14041404MoveDCToPassiveList (hDC,GetHWnd ());
1405- ReleaseDCList (GetHWnd (), passiveDCList);
1405+ ReleaseDCList (passiveDCList);
14061406 mr = mrConsume;
14071407break ;
14081408 }
@@ -1411,7 +1411,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
14111411// Called during Component destruction. Gets current list of
14121412// DC's associated with Component and releases each DC.
14131413ReleaseDCList (GetHWnd (), activeDCList);
1414- ReleaseDCList (GetHWnd (), passiveDCList);
1414+ ReleaseDCList (passiveDCList);
14151415 mr = mrConsume;
14161416break ;
14171417 }
@@ -7436,6 +7436,19 @@ DCItem *DCList::RemoveAllDCs(HWND hWnd)
74367436return newListPtr;
74377437}
74387438
7439+ /* *
7440+ * Remove all DCs from the DC list. Return the list of those
7441+ * DC's to the caller (which will then probably want to
7442+ * call ReleaseDC() for the returned DCs).
7443+ */
7444+ DCItem *DCList::RemoveAllDCs ()
7445+ {
7446+ listLock.Enter ();
7447+ DCItem *newListPtr = head;
7448+ head =NULL ;
7449+ listLock.Leave ();
7450+ return newListPtr;
7451+ }
74397452
74407453/* *
74417454 * Realize palettes of all existing HDC objects
@@ -7458,8 +7471,7 @@ void MoveDCToPassiveList(HDC hDC, HWND hWnd) {
74587471 }
74597472}
74607473
7461- void ReleaseDCList (HWND hwnd, DCList &list) {
7462- DCItem *removedDCs = list.RemoveAllDCs (hwnd);
7474+ static void ReleaseDCList (DCItem *removedDCs) {
74637475while (removedDCs) {
74647476 DCItem *tmpDCList = removedDCs;
74657477DASSERT (::GetObjectType (tmpDCList->hDC ) == OBJ_DC);
@@ -7473,3 +7485,11 @@ void ReleaseDCList(HWND hwnd, DCList &list) {
74737485delete tmpDCList;
74747486 }
74757487}
7488+
7489+ void ReleaseDCList (HWND hwnd, DCList &list) {
7490+ ReleaseDCList (list.RemoveAllDCs (hwnd));
7491+ }
7492+
7493+ void ReleaseDCList (DCList &list) {
7494+ ReleaseDCList (list.RemoveAllDCs ());
7495+ }