Skip to content
Permalink
Browse files
8235147: Release HDC from passiveDCList sooner
Reviewed-by: serb, jdv
  • Loading branch information
Alexey Ivanov committed Feb 25, 2020
1 parent f916df3 commit fa7f53ee93f3dd6ee28c34fd4ac29f69247e88bd
Showing with 29 additions and 7 deletions.
  1. +26 −6 src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
  2. +3 −1 src/java.desktop/windows/native/libawt/windows/awt_Component.h
@@ -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 @@ class DCList {
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"

0 comments on commit fa7f53e

Please sign in to comment.