Undocked project windows not closed/error after project is closed (#424)
Under typical circumstances, windows which are tied to a project (e.g. diagrams or the Element Browser) open as tabbed windows in the main application window. When the project is closed, these windows close as well. However, when these windows are undocked into floating windows (very nice feature for multi-monitor setups), they stay open after a project is closed. Worse, if you try to interact with these windows in a meaningful way (e.g. add or delete elements), a NullReferenceException exception will occur.
Steps to reproduce:
- Create a new project
- Create a new class diagram
- Create a new class in the diagram
- Drag the diagram window out of the main window tab set so that it floats on its own
- Close and save the project
- Notice the diagram window stays open
- Select the class you created and delete
A similar error occurs if you view and undock the Element Browser. The steps above result in this error:
System.NullReferenceException: Object reference not set to an instance of an object.
at SoftwareIdeasModeler.MainForm.CloseUnreferencedWindows()
at SoftwareIdeasModeler.Core.Projecting.Project.Execute(Command cmd)
at SoftwareIdeasModeler.SimDiagramControl.DeleteSelectedElements()
at SoftwareIdeasModeler.SimDiagramControl.canvas_KeyDown(Object sender, KeyEventArgs e)
at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
at SoftwareIdeasModeler.Controls.StyledPanel.SelectablePanel.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
OF=SoftwareIdeasModeler.MainForm
NoPrj
OF=DockablePanel.Controls.DockablePanel.FloatingForm
OF=DockablePanel.Controls.DockablePanel.FloatingForm
OF=SoftwareIdeasModeler.Forms.StartForm
OF=SoftwareIdeasModeler.Forms.EditorForm
Dusan Rodina - softwareideas.net 24 March 2015 23:12:24
Thank you for your notices, Chris. These bugs will be fixed soon.
Chris Simmons 24 March 2015 18:56:47
To clarify, when I say, "if you try to interact with these windows", I mean after the project is closed. The windows behave normally as long as the project is open.
To me, the appropriate behavior here is to simply close any windows related to a project when it closes. The app knows to close the windows which are in the main app window. It just seems like the application "loses track" of the windows after they are removed from the main app window.