This is a migrated thread and some comments may be shown as answers.

Possible bug with ExpressionEditor and INotifyPropertyChanged Item

3 Answers 87 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 01 Nov 2011, 11:00 PM
Hi Guys!

I am fairly new into Telerik business, so please apologize if this isnt the way to report a possible bug.

My recent project is a simulation software for thermal power plants. In a canvas the user can drag&drop
various powergrid objects and connect them to each other.

The user can enter math formulas using public properties of any object on the canvas. And here comes
radExpressionEditor into the game. In this project I am using ILGenerator to dynamicaly add Properties
at runtime. Unfortunately radExpressionEditor doesnt support multiple Item objects.

So much for a little background info. Now for the bug.....

I have a object with the following signature:

    public class DynamicFields : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;

        private int _Test;
        public int Test
        {
            get { return _Test; }
            set { _Test = value; PropertyChangedHandler("Test"); }
        }

        public DynamicFields() { }

        public void PropertyChangedHandler(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        // BUG: RadExpressionEditor sets a Handle on this.PropertyChanged, but doesnt have any Targetdelegate.
        // Lets remove it here as a workaround!
        public void RemoveLastPropertyChangedHandler()
        {
            Delegate RemoveDelegate = this.PropertyChanged.GetInvocationList().Last();
            if (RemoveDelegate != null)
            {
                this.PropertyChanged -= (RemoveDelegate as PropertyChangedEventHandler);
            }
        }


Some other place in my code I do something like this:

            //Window with ExpressionEditor that will be shown as a dialog
            Window_ExpressionEditor ee = new Window_ExpressionEditor();

            //FormelEditor is an instance of ExpressionEditor
            ee.FormelEditor.Item = Device.dynamicFields;

            //As soon the Item Property is set to my Dynamicobject, radExpressionEditor will subscribe to
            //the PropertyChanged event but without any target method to call.
            //So then ever I change the Value of a property the PropertyChangedHandler raises an exception.

            //Workaround is to delete last entry of the GetInvocationList()
            DynamicFields df = this.Device.dynamicFields;
            df.RemoveLastPropertyChangedHandler();


This behaviour also occurs if I use a "normal" class without expanding the properties at runtime.
Right now my workaround runs fine, but would be nice to get this bug verified.

Oh and please implement radExpressionEditor.Items for multiple objects use ;-)

Thank you and my best regards, Martin

3 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 04 Nov 2011, 04:58 PM
Hello Martin,

I have just tried to replicate your problem locally on my machine but I was not able to. Would it be possible for you to send us a small sample application that illustrates your exact scenario using the latest version of the controls?

Regarding the feature you are requesting it is in our long backlog so we will have it implemented at some point.

Greetings,
Stefan Dobrev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Martin
Top achievements
Rank 1
answered on 11 Dec 2011, 10:22 PM
Hi Stefan!

Sorry about the long delay... But on the 4th of november my first born child (a son) was born.
So I took the liberty of getting of for some time. Well now I am back on business.

I have created a testprojekt to verify the bug.
http://download.olsens.at/EE_PropertyChangedBug.zip

What does this project do?

 - Generate a dynamic class of various sources (in this szenario it is from two classes, in reality I use a database)
 - Changing/setting value of a dynamic field
 - Attach this dynamic class as itemsourse of the ExpressionEditor
 - Retry the changing/setting value of a dynamic field ==> Bugs.
 - I have also included my simple workaround.

Basically I do all this because I need the ExpressionEditor to build complex Formulas with more than one itemsource.
So I build a dynamic class and add that as a source.

Another bug, which was VERY annoying, was the ExpressionParser. But I just realized that it is fixed in the latest Hotfix
of release Q3.2011 Hotfix 1205.

It crashes if you type something like this "10 * (" in the PART_ExpressionNodeEditor. The crash occurs always if you
type a openbracket after the multiplicationsymbol. But only if no additional formula is after the bracket:

10 * (  ==> Crashes
But 10 * -1 and typing the brackets as last action 10 * (-1 ==> does not crash.

I am writing about this bug also, because all your demos are affected. And it is a poor marketing if people try your demos
but crashes ;-)

Regards, Martin

0
Stefan Dobrev
Telerik team
answered on 14 Dec 2011, 07:34 AM
Hello Martin,

First of all congratulations for your first child. Our whole team wishes all the best for your family and happy holidays.

Now back to business. I was able to reproduce the issue using the sample you have provided. The good news is that I was able to trace down the root cause for this and we will do our best to provide a fix in one of our next latest internal builds.

Thanks for pointing out this bug. I have update your Telerik points accordingly.

Regards,
Stefan Dobrev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ExpressionEditor
Asked by
Martin
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Martin
Top achievements
Rank 1
Share this question
or