From 725f9d055403204c864bd3269969fd88450a405a Mon Sep 17 00:00:00 2001 From: Jurgen Date: Tue, 31 Dec 2019 18:02:06 +0200 Subject: [PATCH] Fixed incorrect use of getManagedChildren (#887) --- .../src/main/java9/org/fxmisc/richtext/TextFlowExt.java | 2 +- .../src/main/java9/org/fxmisc/richtext/TextFlowLayout.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowExt.java b/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowExt.java index 7b0b0b41a..376e11470 100644 --- a/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowExt.java +++ b/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowExt.java @@ -26,7 +26,7 @@ class TextFlowExt extends TextFlow { private TextFlowLayout textLayout() { if ( layout == null ) { - layout = new TextFlowLayout( this, getManagedChildren() ); + layout = new TextFlowLayout( this ); } return layout; } diff --git a/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowLayout.java b/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowLayout.java index 6ae507a1b..35e5a6499 100644 --- a/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowLayout.java +++ b/richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowLayout.java @@ -21,14 +21,12 @@ class TextFlowLayout { private TextFlow flow; - private List children; private List lineMetrics = new ArrayList<>(); private int lineCount = -1; - TextFlowLayout( TextFlow tf, List managedChildren ) { + TextFlowLayout( TextFlow tf ) { tf.getChildren().addListener( (Observable ob) -> lineCount = -1 ); tf.widthProperty().addListener( (Observable ob) -> lineCount = -1 ); - children = managedChildren; flow = tf; } @@ -73,7 +71,7 @@ int getLineCount() { double totLines = 0.0, prevMinY = 1.0, prevMaxY = -1.0; int totCharSoFar = 0; - for ( Node n : children ) { + for ( Node n : flow.getChildren() ) if ( n.isManaged() ) { Bounds nodeBounds = n.getBoundsInParent(); int length = (n instanceof Text) ? ((Text) n).getText().length() : 1;