javafxports / openjdk-jfx

The openjfx repo has moved to:
https://github.com/openjdk/jfx
GNU General Public License v2.0
1.01k stars 145 forks source link

NPE in MenuButtonSkinBase due to null scene #637

Closed hlf0319 closed 4 years ago

hlf0319 commented 4 years ago

I think this is happening after this change https://github.com/javafxports/openjdk-jfx/pull/544 (https://github.com/javafxports/openjdk-jfx/issues/465)

I implemented my customized ListCell (label and menuButton inside anchorPane) I am getting NPE when I remove the last item from the list (it only happens when I remove the last item, removing from any other positions are fine)

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at java.base/java.util.Objects.requireNonNull(Objects.java:221)
    at javafx.controls/javafx.scene.control.skin.MenuButtonSkinBase.lambda$new$7(MenuButtonSkinBase.java:198)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

Sample implementation of my updateItem:

    @Override
    protected void updateItem(String name, boolean empty) {
        super.updateItem(name, empty);

        if (empty || name == null) {
            setText(null);

            setContentDisplay(ContentDisplay.TEXT_ONLY);
        } else {
            profileLabel.setText(name);
            deleteMenuItem.setOnAction(actionEvent -> {
                ...
            });
            setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
        }
    }
hlf0319 commented 4 years ago

Hi, @vlaaad , sorry for the distraction. I just ran into the above issue, would you be able to take a quick peek?

kleopatra commented 4 years ago

this repo is inactive - if you think you found a bug, please report it through the usual channels (https://bugreport.java.com/bugreport/ or directly at jbs if you have write access) - and don't forget to add a reproducible example demonstrating the issue :)

hlf0319 commented 4 years ago

Thanks @kleopatra , will report in https://bugreport.java.com/bugreport/

hlf0319 commented 4 years ago

Filed a bug with review ID 9066631 Also uploaded a small project with repro - https://github.com/hlf0319/repro-openjdk-jfx-637 I feel the problem is caused due to my onAction inside my customized ListCell.

kristofdho commented 3 years ago

Hi, is there any update on this? I am also running into the same NPE due to a null Scene, but I can't seem to find the bugreport ID you mentioned.

kevinrushforth commented 3 years ago

Filed as: https://bugs.openjdk.java.net/browse/JDK-8252630 which is closed as a duplicate of https://bugs.openjdk.java.net/browse/JDK-8244234