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

[Text] NPE at javafx.scene.text.Text.getSpanBounds(Text.java:292)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:

      Description

      I'm getting a NPE with this stack trace (simplified):

      javafx.scene.text.Text.getSpanBounds(Text.java:291)
        javafx.scene.text.Text.getRuns(Text.java:321)
          javafx.scene.Parent.layout(Parent.java:1076)
            javafx.scene.text.TextFlow.layoutChildren(TextFlow.java:300)
              ...
                javafx.scene.text.Text.getSpanBounds(Text.java:292)

      The problem I'm seeing here is that Text.getRuns() assumes that calling getParent().layout() results in TextFlow.layoutChildren(), which in the end results in Text.textRuns being non-null. The flaw is that getParent().layout() does not call layoutChildren() if already performing layout (higher up the call stack). Thus Text.getRuns() returns null and it blows on the next line in Text.getSpanBounds().

      I consider it a bug to assume that layout() results in layoutChildren(). Please, correct me if I'm wrong.

      I have a simple project to demonstrate the issue, though it depends on JFXtras. Here is the source code and the build file that takes care of downloading JFXtras:
      https://gist.github.com/TomasMikula/13ebd2c1e1dfcb7d4a8a

      I'm using JDK 8 b129.

        Attachments

          Activity

            People

            Assignee:
            fheidric Felipe Heidrich (Inactive)
            Reporter:
            tmikula Tomas Mikula
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: