Skip to content

Commit

Permalink
8346887: DrawFocusRect() may cause an assertion failure
Browse files Browse the repository at this point in the history
Backport-of: 8eddf67
  • Loading branch information
Satyen Subramaniam authored and Paul Hohensee committed Jan 16, 2025
1 parent 4068754 commit 97119a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/java.desktop/windows/native/libawt/windows/awt_Button.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, 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
Expand Down Expand Up @@ -242,7 +242,7 @@ AwtButton::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
RECT focusRect;
VERIFY(::CopyRect(&focusRect, &rect));
VERIFY(::InflateRect(&focusRect,-inf,-inf));
if(::DrawFocusRect(hDC, &focusRect) == 0)
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
VERIFY(::GetLastError() == 0);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, 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
Expand Down Expand Up @@ -290,13 +290,13 @@ AwtCheckbox::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
if ((drawInfo.itemState & ODS_FOCUS) &&
((drawInfo.itemAction & ODA_FOCUS)||
(drawInfo.itemAction &ODA_DRAWENTIRE))) {
if(::DrawFocusRect(hDC, &focusRect) == 0)
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
VERIFY(::GetLastError() == 0);
}
/* erase focus rect */
else if (!(drawInfo.itemState & ODS_FOCUS) &&
(drawInfo.itemAction & ODA_FOCUS)) {
if(::DrawFocusRect(hDC, &focusRect) == 0)
if (!::IsRectEmpty(&focusRect) && (::DrawFocusRect(hDC, &focusRect) == 0))
VERIFY(::GetLastError() == 0);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, 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
Expand Down Expand Up @@ -4499,7 +4499,7 @@ void AwtComponent::DrawListItem(JNIEnv *env, DRAWITEMSTRUCT &drawInfo)
if ((drawInfo.itemState & ODS_FOCUS) &&
(drawInfo.itemAction & (ODA_FOCUS | ODA_DRAWENTIRE))) {
if (!unfocusableChoice){
if(::DrawFocusRect(hDC, &rect) == 0)
if (!::IsRectEmpty(&rect) && (::DrawFocusRect(hDC, &rect) == 0))
VERIFY(::GetLastError() == 0);
}
}
Expand Down

0 comments on commit 97119a9

Please sign in to comment.