I have this strange behavior in my application, where it seems children aren't added under their expected parents. I can verify this by using the debug console. The issue is that when I call the destroy on these parents, my children/member objects aren't destroyed and thus leading to various subsequent issues - not counting the excessive use of memory.
I have created a test case code that can reproduce the issue and I want your opinion if this a bug or just me not doing the stuff as expected. The code that seams to work is the following:
And the debug console shows a correct canvas objects tree as can be seen in the tree_correct.png image attached. Check how all the isc_Label objects are below the tabSet object in the tree. Thus when I push the destroy button they are destroyed as expected.
Now check the below snippet:
The resulted canvases tree is the one shown in the tree_erroneous.png image attached. The problem is with the isc_Label_2 object, which is now not under the tabSet object, and if I press the destroy button this object will remain intact ... clearly not what one would expect. The only difference is of course the order of the addMember calls inside the code, and there is not notification to the programmer that this can lead to errors, making it harder if impossible to foresee such cases.
I have tested this with latest stable and current trunk releases of SmartGwt (r1621). Tested it on latest Chrome dev release (10.0.648.18), FF (3.6.15) and IE8. First two under Linux Ubuntu 10.10 and the last under Win7.
The issue is that although the above case is a simple example and can be easily "corrected", this can not be said for a more complex application. With many lines creating objects and adding them under parents to build an objects hierarchy, one can easily get into situations that trigger the problem that exists in the erroneous snippet of code. This leading to objects not be destroyed when their expected parent is destroyed. Any thoughts or comments on the above would be much appreciated.
I have created a test case code that can reproduce the issue and I want your opinion if this a bug or just me not doing the stuff as expected. The code that seams to work is the following:
Code:
//Create a tabSet with some panes VLayout hLayout = new VLayout(); tabSet = new TabSet(); tabSet.setWidth(500); tabSet.setHeight(500); //Create some labels. Label label1 = new Label("Tab1"); Label label2 = new Label("Tab2"); Label label3 = new Label("Tab3"); //Create some tabs. Tab tab1 = new Tab("Tab1"); Tab tab2 = new Tab("Tab2"); Tab tab3 = new Tab("Tab3"); //Add the labels as part of the tabs. tab1.setPane(label1); tab2.setPane(label2); tab2.setDisabled(true); tab3.setPane(label3); tab3.setDisabled(true); IButton button = new IButton("Destroy!"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { destroyTabSet(); } }); //Add tabs as part of tabSet tabSet.addTab(tab1); tabSet.addTab(tab2); tabSet.addTab(tab3); hLayout.addMember(tabSet); hLayout.addMember(button); hLayout.show();
Now check the below snippet:
Code:
//Create a tabSet with some panes VLayout hLayout = new VLayout(); tabSet = new TabSet(); tabSet.setWidth(500); tabSet.setHeight(500); //Create some labels. Label label1 = new Label("Tab1"); Label label2 = new Label("Tab2"); Label label3 = new Label("Tab3"); //Create some tabs. Tab tab1 = new Tab("Tab1"); Tab tab2 = new Tab("Tab2"); Tab tab3 = new Tab("Tab3"); //Add tabs as part of tabSet tabSet.addTab(tab1); tabSet.addTab(tab2); tabSet.addTab(tab3); //Add the labels as part of the tabs. tab1.setPane(label1); tab2.setPane(label2); tab2.setDisabled(true); tab3.setPane(label3); tab3.setDisabled(true); IButton button = new IButton("Destroy!"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { destroyTabSet(); } }); hLayout.addMember(tabSet); hLayout.addMember(button); hLayout.show();
I have tested this with latest stable and current trunk releases of SmartGwt (r1621). Tested it on latest Chrome dev release (10.0.648.18), FF (3.6.15) and IE8. First two under Linux Ubuntu 10.10 and the last under Win7.
The issue is that although the above case is a simple example and can be easily "corrected", this can not be said for a more complex application. With many lines creating objects and adding them under parents to build an objects hierarchy, one can easily get into situations that trigger the problem that exists in the erroneous snippet of code. This leading to objects not be destroyed when their expected parent is destroyed. Any thoughts or comments on the above would be much appreciated.
Comment