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

JDK-8323615: PopupControl.skin.setSkin(Skin) fails to call dispose() on discarded Skin #1331

Closed
wants to merge 1 commit into from

Conversation

Maran23
Copy link
Member

@Maran23 Maran23 commented Jan 11, 2024

For some reason the skinProperty did not allow to set a new skin when it is the same class as the previous one.
This leads to multiple issues:

  1. When creating a new skin (same class as previous), the skin will likely install listener but is then rejected when setting it due to the skinProperty class constraint
    -> PopupControl is in a weird state as the current skin was not disposed since it is still set, although we already created and 'set' a new skin
  2. A skin of the same class can behave differently, so it is not really valid to reject a skin just because it is the same class as the previous
    -> Just imagine we have the following skin class
class MyCustomSkin<C extends PopupControl> extends Skin<C> {
    public MyCustomSkin(C skinnable, boolean someFlag) { ... }
}

Now if we would change the skin of the PopupControl two times like this:

popup.setSkin(new MyCustomSkin(popup, true));
popup.setSkin(new MyCustomSkin(popup, false));

The second time the skin will be rejected as it is the same class, although I may changed the skin behaviour, in this case demonstrated by a boolean flag for showing purposes.

This is the same issue and fix as done for Control in JDK-8276056 (PR: #806)


Progress

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

Issue

  • JDK-8323615: PopupControl.skin.setSkin(Skin) fails to call dispose() on discarded Skin (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1331

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1331.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 11, 2024

👋 Welcome back mhanl! 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 openjdk bot added the rfr Ready for review label Jan 11, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 11, 2024

Webrevs

@@ -213,18 +213,6 @@ public PopupControl() {
// a reference to the old value.
private Skin<?> oldValue;

@Override
Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle Jan 11, 2024

Choose a reason for hiding this comment

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

This logic was introduce to deal with skins set from the css JDK-8096194

Are you sure it will still work? Do we need to test this scenario explicitly?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the skin/skinProperty logic was there before, just moved.
It was added in https://bugs.openjdk.org/browse/JDK-8127070,
with the comment from David Grieve: The code for handling the skin property in PopupControl needs to look like the code in Control.

So they basically synchronized the whole skin/skin name API to PopupControl.

@andy-goryachev-oracle
Copy link
Contributor

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@andy-goryachev-oracle
Copy link
Contributor

I think the proposed fix is correct. I've tried to re-load skin via CSS (see https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/PopupControl_SetSkin_8323615.java ) and it does seem to reload correctly, as far as I can tell.

Loading fails without the fix, as expected.

Still, i would like a second pair of eyes to look at this, if possible.


assertNotEquals("New skin was not set", oldSkin, newSkin);
}

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle Jan 12, 2024

Choose a reason for hiding this comment

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

minor: please remove extra newline, I'll reapprove if you choose to make the change

@kevinrushforth
Copy link
Member

@arapte Can you be the second reviewer?

Copy link
Collaborator

@mstr2 mstr2 left a comment

Choose a reason for hiding this comment

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

Looks good, and works as I expect it.

@openjdk
Copy link

openjdk bot commented Jan 30, 2024

@Maran23 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:

8323615: PopupControl.skin.setSkin(Skin) fails to call dispose() on discarded Skin

Reviewed-by: angorya, mstrauss

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 23 new commits pushed to the master branch:

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 Ready to be integrated label Jan 30, 2024
@arapte
Copy link
Member

arapte commented Feb 1, 2024

@Maran23
This is ready for integration. If you were waiting for me. Thanks, It looks good, I don't have any comments.

@Maran23
Copy link
Member Author

Maran23 commented Feb 1, 2024

@Maran23 This is ready for integration. If you were waiting for me. Thanks, It looks good, I don't have any comments.

Thank you for checking as well!

/integrate

@openjdk
Copy link

openjdk bot commented Feb 1, 2024

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

  • af7e057: 8324879: Platform-specific preferences keys are incorrect for Windows toolkit
  • 40809a3: 8322703: Intermittent crash in WebView in a JFXPanel from IME calls on macOS
  • c5ab220: 8324658: Allow animation play/start/stop/pause methods to be called on any thread
  • 52840a1: 8324337: Cherry-pick WebKit 617.1 stabilization fixes
  • d653a31: 8260013: Snapshot does not work for nodes in a subscene
  • 876d535: 8324239: JFXPanelHiDPITest fails on Windows 11
  • 767b027: 8324797: Code example in JavaDoc of ObservableValue#when doesn't compile
  • 359ffb9: 8308955: MediaPlayer/AudioClip skip data on seek/loop
  • 9e7e8e1: 8324270: Update boot JDK to 21.0.2
  • 1170658: 8322784: JFXPanel calls InputMethodRequests on wrong thread
  • ... and 18 more: https://git.openjdk.org/jfx/compare/caba6788e2b62b3c1af102d1ff311ac2eaeab8c5...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 1, 2024

@Maran23 Pushed as commit aac2df1.

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

@Maran23 Maran23 deleted the 8323615-popup-control-skin branch July 29, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants