jidesoft / jidefx-oss

JideFX Common Layer
Other
106 stars 41 forks source link

TooltipEx causes stackoverflow #22

Open osoriri2004 opened 10 years ago

osoriri2004 commented 10 years ago

I am trying to run the examples.

TooltipEx tooltip = new TooltipEx(...); in method addDecoratorForMaskTextField(Label label, MaskTextField field) of class TextFieldsDemo causes the following problem.

Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157) at com.sun.javafx.application.LauncherImpl$$Lambda$1/2084435065.run(Unknown Source) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.StackOverflowError at javafx.beans.property.StringPropertyBase.get(StringPropertyBase.java:49) at javafx.beans.binding.StringExpression.getValue(StringExpression.java:51) at javafx.beans.binding.StringExpression.getValue(StringExpression.java:47) at javafx.beans.property.StringPropertyBase.get(StringPropertyBase.java:130)

jidesoft commented 10 years ago

I couldn't reproduce it in TextFieldsDemo. Are you on the latest JDK8? What are the steps to reproduce it if you need to click somewhere on the demo after running?

salgadobreno commented 9 years ago

I'm able to reproduce, trying to initialize a TooltipEx gives me StackOverflowError, with the same pattern(StringpropertyBase.get, StringExpression.getValue, StringExpression.getValue, StringPropertyBase.get...)

I also get this error trying to use validations with messages, that is:

@Override
    public ValidationEvent call(ValidationObject param) {
        if (param.getNewValue() != null && !param.getNewValue().toString().isEmpty()) {
            return new ValidationEvent(ValidationEvent.VALIDATION_OK, 9999, "teste"); //StackOverflowError
        }
    }

But:

@Override
    public ValidationEvent call(ValidationObject param) {
        if (param.getNewValue() != null && !param.getNewValue().toString().isEmpty()) {
            return new ValidationEvent(ValidationEvent.VALIDATION_OK); //No error
        }
    }

I've tried to follow the steps in debug but wasn't able to pinpoint anything...

JDK 1.8.0 u45 jidefx 0.9.1

ferchop1089 commented 8 years ago

Hello, me the same error happens but I've located the problem: The problem arises in the private method "initialize" in the "TooltipEx" class

private void initialize() {

        // undo PopupControl's bridge and replace it with Tooltip's
        if (bridge != null) {
            getContent().clear();
            bridge.idProperty().unbind();
            bridge.styleProperty().unbind();

            // Bind up these two properties. Note that the third, styleClass, is
            // handled in the onChange listener for that list.
            bridge.idProperty().bind(idProperty()); // StackOverflowError here
            bridge.styleProperty().bind(styleProperty()); // And here
        }

        getContent().add(bridge);

        getStyleClass().setAll("tooltip");
    }

This is called during instantiation:

public TooltipEx(String text) {
        bridge = new CSSBridge();
        setText(text);
        initialize(); //here
    }

It turns out that the variable 'bridge' is inherited from the 'PopupControl' class and wanting to bind the properties, which are actually doing is linked to itself as the call to 'idProperty ()' actually does is:

public final StringProperty idProperty () {return bridge.idProperty (); }  // In the 'PopupControl' class.

Both bridge.idProperty() and idProperty() in bridge.idProperty().bind (idProperty()); refer to the same variable 'idProperty'.

JDK 1.8.0_66-b17 jidefx 0.9.1-b128 SO Debian 64bit

PD: Sorry for my writing, I do not handle very well English.

emirdeliz commented 8 years ago

I get the same error when validate the form with fields.

if (txt.isEmpty()) { /* Field is empty */
    return new ValidationEvent(ValidationEvent.VALIDATION_ERROR, 0, errorMsg); /* Error stackoverwflow */
}

Some solution for this?