Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8346887: DrawFocusRect() may cause an assertion failure #521

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions jdk/src/windows/native/sun/windows/awt_Button.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down
8 changes: 5 additions & 3 deletions jdk/src/windows/native/sun/windows/awt_Checkbox.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions jdk/src/windows/native/sun/windows/awt_Component.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down
Loading