FXMisc / Flowless

Efficient VirtualFlow for JavaFX
BSD 2-Clause "Simplified" License
185 stars 38 forks source link

StackOverflowError #1

Closed DennisdeW closed 9 years ago

DennisdeW commented 9 years ago

I am using RichTextFX in my project, but I am having an issue which seems to be contained to Flowless:

I use the following code to append a certain message in bold font:

private InlineCssTextArea text;

//....
    //In constructor
    text = new InlineCssTextArea();
    text.setWrapText(true);
//....

public void appendBold(String msg) {
    Platform.runLater(() -> {
        int curPos = text.getText().length(); //The index of the first new character
        int endPos = msg.length() + curPos - 1; //The index of the last new character
        text.appendText(msg);
        text.setStyle(curPos, endPos, "-fx-font-weight: bold;");            
   });
}

(I have two other, similar methods for italic and normal fonts) This usually works, but sometimes it fails with a StackOverflowError, where the following section of stacktrace repeats continuously:

at org.fxmisc.flowless.VirtualFlow$$Lambda$238/562912964.invalidated(Unknown Source)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.binding.DoubleBinding.invalidate(DoubleBinding.java:222)
    at com.sun.javafx.binding.BindingHelperObserver.invalidated(BindingHelperObserver.java:51)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.binding.DoubleBinding.invalidate(DoubleBinding.java:222)
    at org.fxmisc.flowless.VirtualFlowContent.setLengthOffset(VirtualFlow.java:1426)
    at org.fxmisc.flowless.VirtualFlowContent.setLengthPosition(VirtualFlow.java:608)
    at org.fxmisc.flowless.VerticalFlowMetrics.setVerticalPosition(VirtualFlow.java:1848)
    at org.fxmisc.flowless.VirtualFlow.lambda$new$3(VirtualFlow.java:217)
    at org.fxmisc.flowless.VirtualFlow$$Lambda$240/1469374270.changed(Unknown Source)
    at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.property.DoublePropertyBase.fireValueChangedEvent(DoublePropertyBase.java:106)
    at javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113)
    at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:146)
    at javafx.scene.control.ScrollBar.setValue(ScrollBar.java:151)
    at org.fxmisc.flowless.VirtualFlow.lambda$new$1(VirtualFlow.java:211)

I can not find any common factor between the instances where this error occurs, so I'm not sure if you can help me with this, but I would very much appreciate it if you could have a look.

TomasMikula commented 9 years ago

Are you able to provide a self-contained example, or test with the current version (0.6) of RichTextFX?

TomasMikula commented 9 years ago

Closing as I cannot reproduce this in the current version.