8346887: DrawFocusRect() may cause an assertion failure

Reviewed-by: phh, serb
Backport-of: 8eddf67c82a2af4d704c4063ad802640770b3c26
This commit is contained in:
Satyen Subramaniam 2025-03-12 23:08:32 +00:00 committed by Paul Hohensee
parent 84576a9729
commit 7210b97106
3 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2025, 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
@ -242,7 +242,8 @@ AwtButton::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
RECT focusRect;
VERIFY(::CopyRect(&focusRect, &rect));
VERIFY(::InflateRect(&focusRect,-inf,-inf));
VERIFY(::DrawFocusRect(hDC, &focusRect));
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
VERIFY(::GetLastError() == 0);
}
/* Notify any subclasses */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2025, 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
@ -290,12 +290,14 @@ AwtCheckbox::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
if ((drawInfo.itemState & ODS_FOCUS) &&
((drawInfo.itemAction & ODA_FOCUS)||
(drawInfo.itemAction &ODA_DRAWENTIRE))) {
VERIFY(::DrawFocusRect(hDC, &focusRect));
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
VERIFY(::GetLastError() == 0);
}
/* erase focus rect */
else if (!(drawInfo.itemState & ODS_FOCUS) &&
(drawInfo.itemAction & ODA_FOCUS)) {
VERIFY(::DrawFocusRect(hDC, &focusRect));
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
VERIFY(::GetLastError() == 0);
}
/* Notify any subclasses */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2025, 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
@ -4446,7 +4446,8 @@ void AwtComponent::DrawListItem(JNIEnv *env, DRAWITEMSTRUCT &drawInfo)
if ((drawInfo.itemState & ODS_FOCUS) &&
(drawInfo.itemAction & (ODA_FOCUS | ODA_DRAWENTIRE))) {
if (!unfocusableChoice){
VERIFY(::DrawFocusRect(hDC, &rect));
if (!::IsRectEmpty(&rect) && (::DrawFocusRect(hDC, &rect) == 0))
VERIFY(::GetLastError() == 0);
}
}
env->DeleteLocalRef(target);