From ad0305c5747bae64697bb9036fe690f7f753f939 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 22 Oct 2023 11:13:46 +0200 Subject: [PATCH] Fix EAccessViolation in TDBObject.GetImageIndex:6 --- source/dbconnection.pas | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 6d9aaea2..70e88c5a 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -10055,13 +10055,16 @@ end; function TDBObject.GetImageIndex: Integer; begin // Detect key icon index for specified db object (table, trigger, ...) + Result := -1; case NodeType of lntNone: begin - // Prevent AV with no connection - if FConnection <> nil then + // Prevent AV with no connection. Parameters may not have been initialized as well + if FConnection <> nil then try Result := FConnection.Parameters.ImageIndex - else - Result := -1; + except + on E:EAccessViolation do + Result := -1; + end; end; lntDb: Result := ICONINDEX_DB; @@ -10086,8 +10089,6 @@ begin lntEvent: Result := ICONINDEX_EVENT; lntColumn: Result := ICONINDEX_FIELD; - - else Result := -1; end; end;