Skip to content

Commit

Permalink
Fix program exiting immediately and possible NullReferenceException i…
Browse files Browse the repository at this point in the history
…n frmMain_FormClosing.
  • Loading branch information
rmcardle committed Feb 18, 2013
1 parent 30c3b01 commit d09727a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions mRemoteV1/Forms/frmMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Public Class frmMain

' Load GUI Configuration
SettingsLoad.Load()
If Not IsConnectionsFileLoaded Then Close()

Debug.Print("---------------------------" & vbNewLine & "[START] - " & Now)

Expand All @@ -64,6 +63,10 @@ Public Class frmMain

'LoadCredentials()
LoadConnections()
If Not IsConnectionsFileLoaded Then
Application.Exit()
Return
End If

If My.Settings.StartupComponentsCheck Then
Windows.Show(UI.Window.Type.ComponentsCheck)
Expand Down Expand Up @@ -163,24 +166,28 @@ Public Class frmMain
End Sub

Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If My.Settings.ConfirmExit And WindowList.Count > 0 Then
Dim Result As DialogResult = cTaskDialog.MessageBox(Me, My.Application.Info.ProductName, My.Language.strConfirmExitMainInstruction, "", "", "", My.Language.strCheckboxDoNotShowThisMessageAgain, eTaskDialogButtons.YesNo, eSysIcons.Question, Nothing)
If cTaskDialog.VerificationChecked Then
My.Settings.ConfirmExit = False
End If
If Result = DialogResult.No Then
e.Cancel = True
Exit Sub
If WindowList IsNot Nothing Then
If My.Settings.ConfirmExit And WindowList.Count > 0 Then
Dim result As DialogResult = cTaskDialog.MessageBox(Me, My.Application.Info.ProductName, My.Language.strConfirmExitMainInstruction, "", "", "", My.Language.strCheckboxDoNotShowThisMessageAgain, eTaskDialogButtons.YesNo, eSysIcons.Question, Nothing)
If cTaskDialog.VerificationChecked Then
My.Settings.ConfirmExit = False
End If
If result = DialogResult.No Then
e.Cancel = True
Exit Sub
End If
End If
End If

Shutdown.BeforeQuit()

_IsClosing = True

For Each Window As UI.Window.Base In WindowList
Window.Close()
Next
If WindowList IsNot Nothing Then
For Each window As UI.Window.Base In WindowList
window.Close()
Next
End If

Debug.Print("[END] - " & Now)
End Sub
Expand Down

0 comments on commit d09727a

Please sign in to comment.