RFR: JDK-8311113: Remove invalid pointer cast and clean up setLabel() in awt_MenuItem.cpp
Phil Race
prr at openjdk.org
Wed Aug 30 18:45:30 UTC 2023
On Wed, 16 Aug 2023 03:57:29 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>> In awt_MenuItem.cpp (712,22): ` mii.dwTypeData = (LPTSTR)(*sb)` produces invalid pointer cast warning when complied on clang and moreover this is a no-op.
>>
>> `mii.dwTypeData` is used only when **MIIM_STRING** flag is set in the fMask (as per [Docs](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-menuiteminfoa)), which is not the case in JDK [Ln#705](https://github.com/openjdk/jdk/blob/e56d3bc2dab3d32453b6eda66e8434953c436084/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp#L706). Hence the assignment ` mii.dwTypeData = (LPTSTR)(*sb)` is not required and so is the label parameter. Additionally necessary cleanup is done at the following places -
>>
>> - WMenuItemPeer.java - to the native function call
>> - awt_MenuItem.cpp - `WMenuItemPeer__1setLabel() ,_SetLabel(), SetLabel()`
>> - awt_MenuItem.h
>>
>> Added a test which checks setLabel() functionality on Menu, MenuItem and PopupMenu.
>
> Please double-check how the external tools like jaws/narrator will work after this change, will they be able to read the correct content of the menu item?
> @mrserb
>
> > Please double-check how the external tools like jaws/narrator will work after this change, will they be able to read the correct content of the menu item?
>
> The updating of the label works correctly since the application handles the drawing/updating of the string as specified by the `mii.fType = MFT_OWNERDRAW` without requiring to set `dwTypeData`. To double-check ran JAWS and it works as expected & reads out the new label name when updated.
Hmm, so where does JAWS get that info if we no longer set it ? It isn't scraping pixels and doing OCR.
Seems like a lot of changes here to silence a warning we don't even get.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15276#issuecomment-1699666466
More information about the client-libs-dev
mailing list