Skip to content

Commit da13d50

Browse files
committed
Better handling of log file controls
- Don't attempt to open the log file if the object does not exist (shouldn't be able to reach this point anyways) - Only enable view and delete controls if log file is present.
1 parent 43ac206 commit da13d50

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

WinNUT_V2/WinNUT-Client/Pref_Gui.vb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ Public Class Pref_Gui
338338

339339
Private Sub Btn_ViewLog_Click(sender As Object, e As EventArgs) Handles Btn_ViewLog.Click
340340
LogFile.LogTracing("Show LogFile", LogLvl.LOG_DEBUG, Me)
341-
If File.Exists(LogFile.LogFilePath) Then
341+
If LogFile IsNot Nothing AndAlso File.Exists(LogFile.LogFilePath) Then
342342
Process.Start(LogFile.LogFilePath)
343343
Else
344-
LogFile.LogTracing("LogFile does not exists", LogLvl.LOG_WARNING, Me)
344+
LogFile.LogTracing("LogFile does not exists", LogLvl.LOG_ERROR, Me)
345345
Btn_ViewLog.Enabled = False
346346
Btn_DeleteLog.Enabled = False
347347
End If
@@ -368,14 +368,14 @@ Public Class Pref_Gui
368368
''' Enable or disable controls to view and delete log data if it's available.
369369
''' </summary>
370370
Private Sub SetLogControlsStatus()
371-
If My.Settings.LG_LogToFile Then ' Directory.Exists(Logger.LogFolder)
371+
LogFile.LogTracing("Setting LogControl statuses.", LogLvl.LOG_DEBUG, Me)
372+
373+
If LogFile.IsWritingToFile Then
372374
Btn_ViewLog.Enabled = True
373375
Btn_DeleteLog.Enabled = True
374376
Else
375377
Btn_ViewLog.Enabled = False
376378
Btn_DeleteLog.Enabled = False
377379
End If
378-
379-
LogFile.LogTracing("Setting LogControl statuses.", LogLvl.LOG_DEBUG, Me)
380380
End Sub
381381
End Class

0 commit comments

Comments
 (0)