RFR: 8336879: Always true condition 'img != null' in GTKPainter.paintPopupMenuBackground
Prasanta Sadhukhan
psadhukhan at openjdk.org
Wed Jul 24 07:08:37 UTC 2024
On Wed, 24 Jul 2024 06:34:15 GMT, Abhishek Kumar <abhiscxk at openjdk.org> wrote:
>> src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java line 617:
>>
>>> 615: if (border == img.getRGB(w / 2, h / 2)) {
>>> 616: // fix no menu borders in Adwaita theme
>>> 617: Graphics g2 = img.getGraphics();
>>
>> I guess we can do `if (!isHw && img!=null)`
>> Also the comment that it is done for Adwaita theme, shouldn't then this code block be done in native after checking what theme is effective now, as this may affect Yaru or other theme potentially, no?
>
>> I guess we can do if (!isHw && img!=null)
>
> Thought of but "is it possible that img can be null when it is returned from GTKEngine.finishPainting() method as the BufferedImage instance is created there and returned? ".
GTKEngine is not final so it is possible for it to be extended and provided implementation to finishPainting so it better to safeguard...also to be noted why only in this method, finishPainting returned image is being used, other several places, it does not check the returned image at all..
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20308#discussion_r1689253992
More information about the client-libs-dev
mailing list