Skip to content

Commit 33561bf

Browse files
Satyen SubramaniamVictor Rudometov
authored andcommitted
8346887: DrawFocusRect() may cause an assertion failure
Backport-of: 8eddf67c82a2af4d704c4063ad802640770b3c26
1 parent 0243349 commit 33561bf

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/java.desktop/windows/native/libawt/windows/awt_Button.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, 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
@@ -242,7 +242,7 @@ AwtButton::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
242242
RECT focusRect;
243243
VERIFY(::CopyRect(&focusRect, &rect));
244244
VERIFY(::InflateRect(&focusRect,-inf,-inf));
245-
if(::DrawFocusRect(hDC, &focusRect) == 0)
245+
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
246246
VERIFY(::GetLastError() == 0);
247247
}
248248

src/java.desktop/windows/native/libawt/windows/awt_Checkbox.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, 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
@@ -290,13 +290,13 @@ AwtCheckbox::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
290290
if ((drawInfo.itemState & ODS_FOCUS) &&
291291
((drawInfo.itemAction & ODA_FOCUS)||
292292
(drawInfo.itemAction &ODA_DRAWENTIRE))) {
293-
if(::DrawFocusRect(hDC, &focusRect) == 0)
293+
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
294294
VERIFY(::GetLastError() == 0);
295295
}
296296
/* erase focus rect */
297297
else if (!(drawInfo.itemState & ODS_FOCUS) &&
298298
(drawInfo.itemAction & ODA_FOCUS)) {
299-
if(::DrawFocusRect(hDC, &focusRect) == 0)
299+
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
300300
VERIFY(::GetLastError() == 0);
301301
}
302302

src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, 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
@@ -4465,7 +4465,7 @@ void AwtComponent::DrawListItem(JNIEnv *env, DRAWITEMSTRUCT &drawInfo)
44654465
if ((drawInfo.itemState & ODS_FOCUS) &&
44664466
(drawInfo.itemAction & (ODA_FOCUS | ODA_DRAWENTIRE))) {
44674467
if (!unfocusableChoice){
4468-
if(::DrawFocusRect(hDC, &rect) == 0)
4468+
if (!::IsRectEmpty(&rect) && (::DrawFocusRect(hDC, &rect) == 0))
44694469
VERIFY(::GetLastError() == 0);
44704470
}
44714471
}

0 commit comments

Comments
 (0)