8235147: Release HDC from passiveDCList sooner
Reviewed-by: serb, jdv
This commit is contained in:
parent
f916df3b0e
commit
fa7f53ee93
src/java.desktop/windows/native/libawt/windows
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2020, 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
|
||||
@ -1374,7 +1374,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
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 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hDC = (HDC)wParam;
|
||||
MoveDCToPassiveList(hDC, GetHWnd());
|
||||
ReleaseDCList(GetHWnd(), passiveDCList);
|
||||
ReleaseDCList(passiveDCList);
|
||||
mr = mrConsume;
|
||||
break;
|
||||
}
|
||||
@ -1411,7 +1411,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
// 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 @@ DCItem *DCList::RemoveAllDCs(HWND hWnd)
|
||||
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 MoveDCToPassiveList(HDC hDC, HWND hWnd) {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ void ReleaseDCList(HWND hwnd, DCList &list) {
|
||||
delete tmpDCList;
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseDCList(HWND hwnd, DCList &list) {
|
||||
ReleaseDCList(list.RemoveAllDCs(hwnd));
|
||||
}
|
||||
|
||||
void ReleaseDCList(DCList &list) {
|
||||
ReleaseDCList(list.RemoveAllDCs());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2020, 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 @@ public:
|
||||
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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user