-
Notifications
You must be signed in to change notification settings - Fork 541
8281953: NullPointer in InputMethod components in JFXPanel #735
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
8281953: NullPointer in InputMethod components in JFXPanel #735
Conversation
|
👋 Welcome back eduardsdv! A progress list of the required criteria for merging this PR into |
Webrevs
|
| Window window = scene != null ? scene.getWindow() : null; | ||
| if (window == null) { | ||
| return new Point2D(0, 0); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as each scene needs to be located in a window, the following will simplify the code:
| Window window = scene != null ? scene.getWindow() : null; | |
| if (window == null) { | |
| return new Point2D(0, 0); | |
| } | |
| if (scene == null) { | |
| return new Point2D(0, 0); | |
| } | |
| Window window = scene.getWindow(); |
Is it possible to have a scene without an assigned window?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the NullPointer occurs here because the synchronization between JavaFx and AWT threads is not really possible in this case, we cannot ensure that this method is only called when the scene is assigned to a window.
I would check here for null both the scene and the window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a pity. Then ignore this comment.
aghaisas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good.
I thought about returning null if either the scene or the window is null. As we need to fix this corner case, whether returning null or the default point (as proposed in this PR) does not matter. Both approaches will work.
- Have you verified the sample program attached to the JBS runs successfully with your fix?
- I have a very minor formatting comment on the test.
| // Check that no NullPointerException is thrown if the TextField is not in scene | ||
| // and that the default point is returned. | ||
| Point2D point = textField.getInputMethodRequests().getTextLocation(0); | ||
| assertEquals(new Point2D(0,0), point); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor : Please add a space between 0,0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the space and checked the fix again with the sample program.
The fix works, the NullPointer does not occur anymore.
|
@eduardsdv 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: 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 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@aghaisas) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
@eduardsdv |
|
/sponsor |
|
Going to push as commit a0bb545.
Your commit was automatically rebased without conflicts. |
|
@aghaisas @eduardsdv Pushed as commit a0bb545. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
If the InputMethod's node is not in the scene, the default text location point is returned.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/735/head:pull/735$ git checkout pull/735Update a local copy of the PR:
$ git checkout pull/735$ git pull https://git.openjdk.java.net/jfx pull/735/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 735View PR using the GUI difftool:
$ git pr show -t 735Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/735.diff