With UltraWinTabbedMdi 12.1.20121.2135, I'm getting a hard-to-reproduce NullReferenceException when changing an MDI tab's title by setting Form.Text. The stack trace starts off like this:
at Infragistics.Win.UltraWinTabbedMdi.MdiTabGroup.DirtyTabItem(MdiTab tab, Boolean invalidate, Boolean textChanged, Boolean imageChanged) at Infragistics.Win.UltraWinTabbedMdi.MdiTab.OnMdiChildTextChanged(Object sender, EventArgs e) at System.Windows.Forms.Control.OnTextChanged(EventArgs e) at System.Windows.Forms.Form.OnTextChanged(EventArgs e) at System.Windows.Forms.Control.set_Text(String value)
I'm guessing that I may be disposing something prematurely, since I've made changes to that regard recently. However, I haven't been able to track it down. In addition, neither MdiTab.OnMdiChildTextChanged nor MdiTabGroup.DirtyTabItem seem to appear in the documentation.
The new value for Form.Text is not null, and the tab is supposed to be visible.
Hello,
Have you tried this with the latest service release of Infragistics 12.1. I’ve checked the source code of UltraTabbedMdiManger and I did not found anything suspicious in OnMdiChildTextChanged and DirtyTabItem methods, the only possible issue that might occur there with NullRefferenceExeption is if the form for that MdiTab was disposed during the changing of the text. If you are able to isolate this in a simple sample, I’ll be glad to investigate this further for you.
I am waiting for your feedback.
Hi,
thanks for getting back to me.
Yes, this is with 2135, which appears to be the latest SR. In addition, I have a branch with Infragistics 14.1 (SR 2035), and have been able to reproduce it there as well. The stacktrace is the same:
at Infragistics.Win.UltraWinTabbedMdi.MdiTabGroup.DirtyTabItem(MdiTab tab, Boolean invalidate, Boolean textChanged, Boolean imageChanged) at Infragistics.Win.UltraWinTabbedMdi.MdiTab.OnMdiChildTextChanged(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Control.OnTextChanged(EventArgs e) at System.Windows.Forms.Form.OnTextChanged(EventArgs e) at System.Windows.Forms.Control.set_Text(String value) at System.Windows.Forms.Form.set_Text(String value) at [ code of ours that sets the Text property on an MDI child Form ]
I've checked and neither the MdiTab, nor MdiTabGroup, nor Manager have Disposed set to true. Nor is either the child or parent Form disposed.
Oddly, this occurs even with the Manager's Enabled property set to false, i.e. non-tabbed MDI. I've also been able to track down that it doesn't matter what I set the property to; the issue occurs even with simply setting Me.Text (Me being the Form) to Guid.NewGuid().ToString() each time.
However, I have yet to figure out how to isolate this to a simpler sample.
Regards
there we go — I have a simple sample now.
Launch the attached Windows Forms app in a debugger. Click the "Reopen" button, then "Set Title". This will throw the aforementioned exception.
To work around it, simply comment out these lines in FormUtils.cs:
if (tab != null)
tab.MoveToGroup(group);
The Reopen() method's idea is to close a form, then open another form with similar content. We need this in our LOB application to "restart a workflow", if you will.
The main portion of Reopen() is in the middle part, calling .Close() and then .Show(). However, as a convenience, it first finds the existing MdiTab, then its group; then, once the new MdiTab has been opened, it moves that to the same MdiTabGroup the old one was in.
This call to MoveToGroup appears to retain a reference to the old tab, or something like that.
Hope that helps & regards
Please let me know If you need my further assistance on this issue?
Thank you for using Infragistics Components.
Hello ,
Could you please explain me why implementation of Reset Form() method is not an option for you, I've implemented such method in your sample and it works so good. So you could just copy and paste my ResetForm() method in your solution and to test it.
Hi Hristo,
for architectural reasons, reinitializing the existing form isn't currently a feasible option. You're right, of course, that this would be a lot cleaner.
Is there an easy way to retain the MdiTabGroup's settings (e.g. "split horizontally; on the right side"), then recreate a tab group with those settings if there is no more tab in the group?
I am just checking about the progress of this issue. Let me know If you need my further assistance on this matter ?
Thank you for the provided sample. I’ve investigate it and it seems that you are getting this NullRefference exception only if there only one MDIChild Form. What exactly happen there:
When you click Reopen button, your current form is closed, which dispose your form, this affect the corresponding UltraTab which also must be disposed, and if there were only one tab in corresponding TabGroup (like in your case), this tab group is excluded from ToolbarManager collections and it is ready for dispose. And since you have instants to it, GC doesn’t collect it (if you set breakpoint on line 32 for your FormUtils class and check the TabManager you will see that it is null). When you change the Text of your form, corresponding Tab is subscribed for the text change event of Form and it trays to change its caption, which affects corresponding TabGroup (this tabGroup tha has null for TabbedMadiManager) which cause this NullRefference expiation. This explain also why if you comment
this works. If you comment this lines you do not reposition your tab to a TabGroup which doesn’t have MDITabbedMamanger. I believe that you are doing this in order to reload your form in the same TabGroup, so what you could do in your case is instead to close and recreate your form just to create a method which will reload what you need (or might call InitializeComponent() method and then to call LoadEvent of your form). Another options is to check if the corresponding TabGroup has only one tab, if so you shouldn’t call MoveToGroup() method for this group.
Please let me know if you have any further questions.