ClipboardWatcher: Fix null ref when client is not initialized in Environment

This commit is contained in:
Jonathan Jenne 2022-11-08 08:54:41 +01:00
parent 456a729f46
commit 9708b0ddeb

View File

@ -12,10 +12,9 @@ Imports DigitalData.Modules.ZooFlow.Params
Public Class ProfileSearches
Inherits BaseClass
Private _Environment As Environment
Private _Client As Client
Private _ClipboardContents As String
Private ReadOnly _Environment As Environment
Private ReadOnly _Client As Client
Private ReadOnly _ClipboardContents As String
Public Class Search
Public Guid As Integer
@ -32,7 +31,7 @@ Public Class ProfileSearches
_Environment = pEnvironment
_ClipboardContents = pClipboardContents
Try
If _Environment.Service.Client.IsOnline = True Then
If _Environment.Service.Client IsNot Nothing AndAlso _Environment.Service.Client.IsOnline = True Then
Try
Dim oSplit() As String = _Environment.Service.Address.Split(":")
Dim oAppServerAddress As String = oSplit(0)
@ -50,6 +49,8 @@ Public Class ProfileSearches
Logger.Warn($"Could not initialize the AppServer: {ex.Message}")
Logger.Error(ex)
End Try
Else
Logger.Debug("No client found in Env.")
End If
Catch ex As Exception
Logger.Error(ex)
@ -82,9 +83,7 @@ Public Class ProfileSearches
End Function
Public Async Function LoadDocumentSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
Return Await Task.Run(Function()
Return DoLoadDocumentSearches(ProfileId)
End Function)
Return Await Task.Run(Function() DoLoadDocumentSearches(ProfileId))
End Function
Private Function DoLoadDocumentSearches(ProfileId As Integer) As List(Of Search)
@ -146,9 +145,7 @@ Public Class ProfileSearches
End Function
Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
Return Await Task.Run(Function()
Return DoLoadDataSearches(ProfileId)
End Function)
Return Await Task.Run(Function() DoLoadDataSearches(ProfileId))
End Function
Private Function DoLoadDataSearches(ProfileId As Integer) As List(Of Search)