Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8260361

Cannot read field "dragboard" because "this.this$0.dndGesture" is null

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      ADDITIONAL SYSTEM INFORMATION :
      ArchLinux, AdoptOpenJDK 15.0.1 OpenJFX 15.0.1, using Kotlin, but the source code below is in Java so it may be easier for you to reproduce.

      A DESCRIPTION OF THE PROBLEM :
      When dropping a directory or a file from the GNOME File manager, the drop works properly, but then the following gets displayed in the log:
      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "dragboard" because "this.this$0.dndGesture" is null
      at javafx.graphics/javafx.scene.Scene$DropTargetListener.drop(Scene.java:2965)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.lambda$handleDragDrop$2(GlassSceneDnDEventHandler.java:108)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragDrop(GlassSceneDnDEventHandler.java:104)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleDragDrop$11(GlassViewEventHandler.java:766)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragDrop(GlassViewEventHandler.java:765)
      at javafx.graphics/com.sun.glass.ui.View.handleDragDrop(View.java:713)
      at javafx.graphics/com.sun.glass.ui.View.notifyDragDrop(View.java:1042)
      at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
      at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
      at java.base/java.lang.Thread.run(Thread.java:832)


      The event is properly consumed and isDropCompleted is set to true.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Drag a file or a directory from Gnome File manager onto a label that has onDragOver (selects only COPY/LINK orMOVE) , onDragDropped (that if it has files, set isDropCompleted to true and then consume the event, and a onDragExited that consume the event.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No message displayed in the log
      ACTUAL -
      Message displayed in the log:

      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "dragboard" because "this.this$0.dndGesture" is null
      at javafx.graphics/javafx.scene.Scene$DropTargetListener.drop(Scene.java:2965)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.lambda$handleDragDrop$2(GlassSceneDnDEventHandler.java:108)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragDrop(GlassSceneDnDEventHandler.java:104)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleDragDrop$11(GlassViewEventHandler.java:766)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragDrop(GlassViewEventHandler.java:765)
      at javafx.graphics/com.sun.glass.ui.View.handleDragDrop(View.java:713)
      at javafx.graphics/com.sun.glass.ui.View.notifyDragDrop(View.java:1042)
      at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
      at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
      at java.base/java.lang.Thread.run(Thread.java:832)


      ---------- BEGIN SOURCE ----------
      package sample;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.input.*;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      public class Main extends Application {

          @Override public void start(Stage stage) {
              VBox root = new VBox();
              Scene scene = new Scene(root, 400, 100);

              final Text target = new Text("DROP HERE");
              target.setFont(Font.font(64.0));

              target.setOnDragOver(event -> {
                  System.out.println("onDragOver");
                  if (event.getGestureSource() != target &&
                          event.getDragboard().hasFiles()) {
                      event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                  }
                  event.consume();
              });

              target.setOnDragEntered(event -> {
                  System.out.println("onDragEntered");
                  if (event.getGestureSource() != target &&
                          event.getDragboard().hasFiles()) {
                      target.setFill(Color.GREEN);
                  }
                  event.consume();
              });

              target.setOnDragExited(event -> {
                  target.setFill(Color.BLACK);
                  event.consume();
              });

              target.setOnDragDropped(event -> {
                  System.out.println("onDragDropped");
                  Dragboard db = event.getDragboard();
                  boolean success = false;
                  if (db.hasFiles()) {
                      target.setText(String.valueOf(db.getFiles().size()));
                      success = true;
                  }
                  event.setDropCompleted(success);
                  event.consume();
              });

              root.getChildren().add(target);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: