Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

JDK-8221987: javafx.graphics/javafx.stage.Window$TKBoundsConfigurator.apply (#408) #431

Merged

Conversation

christianheilmann
Copy link
Contributor

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use org.controlsfx.samples.HelloNotifications from https://github.com/controlsfx/controlsfx/blob/master/controlsfx-samples/src/main/java/org/controlsfx/samples/HelloNotifications.java and press very frequent on "Top-right notification" then the NPE will occur. It is independent of the os. We tested it on windows and mac.

@christianheilmann
Copy link
Contributor Author

christianheilmann commented Apr 5, 2019

Issue: #408

@kevinrushforth kevinrushforth added the bug Something isn't working label Apr 5, 2019
@kevinrushforth
Copy link
Collaborator

This looks like a safe and obvious fix to me. I have tagged @arapte to do the formal review.

@kevinrushforth
Copy link
Collaborator

newWW, newWH, newCW, newCH,
newXG, newYG,
newRX, newRY);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The set of local variables will not be needed when peer is null.
Please consider change as below,

public void apply() {
if (dirty) {
if (peer != null) {
// Snapshot values and then reset() before we call down
// as we may end up with recursive calls back up with
// new values that must be recorded as dirty.
boolean xSet = !Double.isNaN(x);
float newX = xSet ? (float) x : 0f;
boolean ySet = !Double.isNaN(y);
float newY = ySet ? (float) y : 0f;
float newWW = (float) windowWidth;
float newWH = (float) windowHeight;
float newCW = (float) clientWidth;
float newCH = (float) clientHeight;
float newXG = xGravity;
float newYG = yGravity;
float newRX = (float) renderScaleX;
float newRY = (float) renderScaleY;
reset();
peer.setBounds(newX, newY, xSet, ySet,
newWW, newWH, newCW, newCH,
newXG, newYG,
newRX, newRY);
} else {
reset();
}
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

A second alternative would be to return early from the method if peer is null, leaving the rest of the method unchanged.

    public void apply() {
        if (dirty) {
            if (peer == null) {
                reset();
                return;
            }
            ...
        }

I don't have a strong opinion. Any of the three choices (the original fix, Ambarish's proposed change, or my variation on that) are fine with me.

Copy link
Contributor

Choose a reason for hiding this comment

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

A second alternative would be to return early from the method if peer is null, leaving the rest of the method unchanged.

    public void apply() {
        if (dirty) {
            if (peer == null) {
                reset();
                return;
            }
            ...
        }

I don't have a strong opinion. Any of the three choices (the original fix, Ambarish's proposed change, or my variation on that) are fine with me.

I find the proposal from @kevinrushforth clearer.

@arapte
Copy link
Contributor

arapte commented Apr 9, 2019

I could observe the issue with, ControlsFX 8.40.14 & ControlsFX 9.0.0, downloaded from here https://github.com/controlsfx/controlsfx
But there is no controlsFX build for JDK 9 onwards. However the issue looks easily reproducible.

@Ciruman
Copy link
Contributor

Ciruman commented Apr 10, 2019

I could observe the issue with, ControlsFX 8.40.14 & ControlsFX 9.0.0, downloaded from here https://github.com/controlsfx/controlsfx
But there is no controlsFX build for JDK 9 onwards. However the issue looks easily reproducible.

@arapte There are RC. You can find them here:
https://search.maven.org/artifact/org.controlsfx/controlsfx/11.0.0-RC2/jar

@christianheilmann
Copy link
Contributor Author

@kevinrushforth thanks for your code review. I integrated your suggestion.

Copy link
Collaborator

@kevinrushforth kevinrushforth 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.

Copy link
Contributor

@arapte arapte 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 to me too.

@arapte arapte merged commit 8e22393 into javafxports:develop Apr 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants