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