From 9708b0ddebfcb21b9daf6a5ecdf3c412a45d41df Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 8 Nov 2022 08:54:41 +0100 Subject: [PATCH] ClipboardWatcher: Fix null ref when client is not initialized in Environment --- GUIs.ClipboardWatcher/ProfileSearches.vb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/GUIs.ClipboardWatcher/ProfileSearches.vb b/GUIs.ClipboardWatcher/ProfileSearches.vb index 8a700a60..18798caa 100644 --- a/GUIs.ClipboardWatcher/ProfileSearches.vb +++ b/GUIs.ClipboardWatcher/ProfileSearches.vb @@ -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)