From 3768bc9818a10f416920ef5c3de03a0ceb52c2ed Mon Sep 17 00:00:00 2001 From: Anh-Kiet Ngo Date: Sat, 19 May 2012 01:00:27 -0700 Subject: [PATCH] Fix bugs on initial create and null exception. For the null exception, it's when the last tab gets closed and the code tries to focus on ActiveDocument. Since it no longer exists, a null pointer exception is thrown. The second bug is on the creation of the first tab. It needs to be focused after it is created. --- SuperPutty/frmSuperPutty.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SuperPutty/frmSuperPutty.cs b/SuperPutty/frmSuperPutty.cs index 14f43de..866c44f 100755 --- a/SuperPutty/frmSuperPutty.cs +++ b/SuperPutty/frmSuperPutty.cs @@ -277,9 +277,16 @@ public bool IsActiveDocument(ctlPuttyPanel panel) /// private void dockPanel1_ActiveDocumentChanged(object sender, EventArgs e) { - FocusCurrentTab(); - dockPanel1.ActiveDocument.TabTextColor = null; - dockPanel1.ActiveDocument.DockHandler.RefreshPaneChanges(); + if (dockPanel1.ActiveDocument != null) + { + FocusCurrentTab(); + dockPanel1.ActiveDocument.TabTextColor = null; + dockPanel1.ActiveDocument.DockHandler.RefreshPaneChanges(); + } + else + { + this.Focus(); + } } private void frmSuperPutty_Activated(object sender, EventArgs e) @@ -447,7 +454,7 @@ public void CreatePuttyPanel(SessionData sessionData, bool isPutty) this.BeginInvoke((MethodInvoker)delegate() { sessionPanel.Close(); - }); + }); } else { @@ -458,6 +465,7 @@ public void CreatePuttyPanel(SessionData sessionData, bool isPutty) sessionPanel = new ctlPuttyPanel(this, sessionData, callback, isPutty); sessionPanel.Show(dockPanel1, sessionData.LastDockstate); + FocusCurrentTab(); } private void newMintty_Click(object sender, EventArgs e)