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

8258979: The image didn't show correctly with GTK LAF #17294

Closed
wants to merge 7 commits into from

Conversation

kumarabhi006
Copy link
Contributor

@kumarabhi006 kumarabhi006 commented Jan 8, 2024

The collapsed icon for JTree is not painted using Icon.paintIcon(Component c, Graphics g, int x, int y) in GTK LAF. The collapsed icon is returned from BasicTreeUI class which doesn't contain any icon image whereas the expanded icon is returned from SynthTreeUI class and expanded icon is rendered correctly.
The proposed fix is to return collapsed icon as an object of collapsed icon wrapper which implements synthIcon and is similar to the expanded icon implementation.

Test mentioned in JBS is an applet based which is converted to main based now and extended for all installed LAFs on the system.

No regression caused with the fix, link is attached in JBS .


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8258979: The image didn't show correctly with GTK LAF (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17294/head:pull/17294
$ git checkout pull/17294

Update a local copy of the PR:
$ git checkout pull/17294
$ git pull https://git.openjdk.org/jdk.git pull/17294/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17294

View PR using the GUI difftool:
$ git pr show -t 17294

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17294.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 8, 2024

👋 Welcome back abhiscxk! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 8, 2024

@kumarabhi006 The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Jan 8, 2024
@mrserb
Copy link
Member

mrserb commented Jan 8, 2024

⚠️ Failed to retrieve information on issue 8258979.

Looks like the bug is confidential/not public.

@kumarabhi006
Copy link
Contributor Author

⚠️ Failed to retrieve information on issue 8258979.

Looks like the bug is confidential/not public.

Already updated the bug but it is still not reflected.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 8, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 8, 2024

@prsadhuk
Copy link
Contributor

prsadhuk commented Jan 8, 2024

JBS image suggests that no image is rendered either for collapsed or expanded icon for Ubuntu20.10-x64 but it seems you are seeing expanded icon but not collapsed icon, is that correct? WHich ubuntu you tested against? Did you check on ubuntu 20.10 in case

@kumarabhi006
Copy link
Contributor Author

JBS image suggests that no image is rendered either for collapsed or expanded icon for Ubuntu20.10-x64 but it seems you are seeing expanded icon but not collapsed icon, is that correct?

Yes, only collapsed icon is not rendered.

Which ubuntu you tested against?

22.04

Did you check on ubuntu 20.10 in case

Didn't have 201.0 machine, so couldn't check.

@prsadhuk
Copy link
Contributor

prsadhuk commented Jan 8, 2024

How about latest 23.10? Probably you should install and check there as well if you dont have that.....There is a need to check in latest OracleLinux too as there is a difference in observations across ubuntu versions..
Also, if one icon is rendered and other is not, there is a potential to create automated test to render the icons into bufferedimage and compare, the collapsed one should be all white BI in failed case...and you can use that automated test to test in ubuntu20.10 machine which we seem to have few in mach5...

@kumarabhi006
Copy link
Contributor Author

How about latest 23.10? Probably you should install and check there as well if you dont have that.....There is a need to check in latest OracleLinux too as there is a difference in observations across ubuntu versions.. Also, if one icon is rendered and other is not, there is a potential to create automated test to render the icons into bufferedimage and compare, the collapsed one should be all white BI in failed case...and you can use that automated test to test in ubuntu20.10 machine which we seem to have few in mach5...

Ok, will check and update.

@openjdk openjdk bot removed the rfr Pull request is ready for review label Jan 10, 2024
@kumarabhi006
Copy link
Contributor Author

kumarabhi006 commented Jan 10, 2024

Also, if one icon is rendered and other is not, there is a potential to create automated test to render the icons into bufferedimage and compare, the collapsed one should be all white BI in failed case...and you can use that automated test to test in ubuntu20.10 machine which we seem to have few in mach5...

Modified the manual test to automated and tested in mach5 machines. Test passed on all platforms. Test passed on specific ubuntu 20.10 machine multiple times.

How about latest 23.10? Probably you should install and check there as well if you dont have that.....There is a need to check in latest OracleLinux too as there is a difference in observations across ubuntu versions..

Installed 23.10 machine in my local and verified the automated test. Ran the test on oracle linux as well and it passed.

CI link is attached in JBS for automated test.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 10, 2024
SynthGraphicsUtils.paintIcon(collapsedIcon, context, g, x, y, w, h);
}
else {
SynthGraphicsUtils.paintIcon(collapsedIcon, context, g, x, y, w, h);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess it's a copy of ExpandedIconWrapper class, so CollapsedIconWrapper and ExpandedIconWrapper can be optimised to use common method passing in the "icon" argument..

Copy link
Contributor Author

@kumarabhi006 kumarabhi006 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I merge the two classes into one class like instead of separate ExpandedIconWrapper and CollapsedIconWrapper, only one IconWrapper class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess you could since they are all private..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged ExpandedIconWrapper and CollapsedIconWrapper class to IconWrapper class.


private Icon expandedIconWrapper = new IconWrapper(IconType.EXPANDED);

private Icon collapsedIconWrapper = new IconWrapper(IconType.COLLAPSED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can pass in collapsedIcon or expandedIcon to IconWrapper class which can save it in icon field and
Then IconWrapper class can just call SynthGraphicsUtils.paintIcon(icon, context, g, x, y, w, h);

Copy link
Contributor Author

@kumarabhi006 kumarabhi006 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with this approach first but images didn't render at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess those might be null at class initialisation stage so it didn't render..you can try

expandedIconWrapper = new IconWrapper(expandedIcon);
collapsedIconWrappr - new IconWrapper(collapsedICon);

in updateStyle() where it sets

setExpandedIcon(style.getIcon(context, "Tree.expandedIcon"));
setCollapsedIcon(style.getIcon(context, "Tree.collapsedIcon"));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -150,6 +157,9 @@ private void updateStyle(JTree tree) {
LookAndFeel.installProperty(
tree, JTree.SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles);

expandedIconWrapper = new IconWrapper(expandedIcon);
collapsedIconWrapper = new IconWrapper(collapsedIcon);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems updateStyle is called for all propertyChange event so it can cause memory leak by doing the class instantiation every time it is called..
Probably better place to instantiate this objects is in installDefaults after calling updateStyle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

}
else {
SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
SynthGraphicsUtils.paintIcon(iconType, context, g, x, y, w, h);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess it can be further optimized in all these methods

if (context == null) {
context = getContext(tree);
}
SynthGraphicsUtils.paintIcon(iconType, context, g, x, y, w, h);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -782,40 +791,34 @@ public String getName() {
// To get the correct context we return an instance of this that fetches
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add collapsedIcon in the comment too now..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@kumarabhi006 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8258979: The image didn't show correctly with GTK LAF

Reviewed-by: psadhukhan, tr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1065 new commits pushed to the master branch:

  • 0ff2dea: 8320673: PageFormat/CustomPaper.java has no Pass/Fail buttons; multiple instructions
  • 8e12053: 8322799: Test JPKG003-013: ServiceTest fails because the user cannot uninstall the "servicetest" package on OEL 9.2 x64 and OEL 9.2 64-bit Arm (aarch64)
  • e4389d8: 8323571: Regression in source resolution process
  • 49e6121: 8310813: Simplify and modernize equals, hashCode, and compareTo for BigInteger
  • 4ea7b36: 8322235: Split up and improve LocaleProvidersRun
  • 93bedd7: 8323213: Fix some javadoc broken links in ObjectReference, and other misc javadoc cleanups
  • b78896b: 8319571: Update jni/nullCaller/NullCallerTest.java to accept flags or mark as flagless
  • e10d140: 8321712: C2: "failed: Multiple uses of register" in C2_MacroAssembler::vminmax_fp
  • c2e77e2: 8319128: sun/security/pkcs11 tests fail on OL 7.9 aarch64
  • 9fd855e: 8322971: KEM.getInstance() should check if a 3rd-party security provider is signed
  • ... and 1055 more: https://git.openjdk.org/jdk/compare/4ea1b99c1a6efe144af381ea538f93718e9baf74...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 12, 2024
* @run main bug8038113
*/

public class bug8038113 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be better to change the file & class name to something meaningful instead of bug id since now two bugs refer to same test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so. Since I am converting the test from applet based it should be ok to just mention the new bug id in jtreg tags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, else it look good to me.

@kumarabhi006
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

Going to push as commit 82a63a0.
Since your change was applied there have been 1066 commits pushed to the master branch:

  • 8d9814a: 8322757: Enable -Wparentheses warnings
  • 0ff2dea: 8320673: PageFormat/CustomPaper.java has no Pass/Fail buttons; multiple instructions
  • 8e12053: 8322799: Test JPKG003-013: ServiceTest fails because the user cannot uninstall the "servicetest" package on OEL 9.2 x64 and OEL 9.2 64-bit Arm (aarch64)
  • e4389d8: 8323571: Regression in source resolution process
  • 49e6121: 8310813: Simplify and modernize equals, hashCode, and compareTo for BigInteger
  • 4ea7b36: 8322235: Split up and improve LocaleProvidersRun
  • 93bedd7: 8323213: Fix some javadoc broken links in ObjectReference, and other misc javadoc cleanups
  • b78896b: 8319571: Update jni/nullCaller/NullCallerTest.java to accept flags or mark as flagless
  • e10d140: 8321712: C2: "failed: Multiple uses of register" in C2_MacroAssembler::vminmax_fp
  • c2e77e2: 8319128: sun/security/pkcs11 tests fail on OL 7.9 aarch64
  • ... and 1056 more: https://git.openjdk.org/jdk/compare/4ea1b99c1a6efe144af381ea538f93718e9baf74...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 12, 2024
@openjdk openjdk bot closed this Jan 12, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 12, 2024
@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@kumarabhi006 Pushed as commit 82a63a0.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants