From 3d90ce24d1d39354692da609dbe70b77dab45ecb Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 27 Mar 2022 14:40:07 +0200 Subject: [PATCH] Silence two crashes in QuotedDatabase and IsSameAs. See https://www.heidisql.com/forum.php?t=39040 --- source/dbconnection.pas | 20 +++++++++++++------- source/main.pas | 16 +++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 0d9757a9..54d43077 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -9895,13 +9895,19 @@ begin if (not Assigned(CompareTo)) or (CompareTo = nil) then begin Result := False; end else begin - Result := FConnection.IdentifierEquals(Name, CompareTo.Name) - and (NodeType = CompareTo.NodeType) - and (Database = CompareTo.Database) - and (Schema = CompareTo.Schema) - and (Column = CompareTo.Column) - and (ArgTypes = CompareTo.ArgTypes) - and (Connection = CompareTo.Connection); + try + Result := FConnection.IdentifierEquals(Name, CompareTo.Name) + and (NodeType = CompareTo.NodeType) + and (Database = CompareTo.Database) + and (Schema = CompareTo.Schema) + and (Column = CompareTo.Column) + and (ArgTypes = CompareTo.ArgTypes) + and (Connection = CompareTo.Connection); + except + // No reproduction recipe yet, but numerous crashes from above were reported + on E:EAccessViolation do + Result := False; + end; end; end; diff --git a/source/main.pas b/source/main.pas index b213e06b..3e81316a 100644 --- a/source/main.pas +++ b/source/main.pas @@ -10697,11 +10697,17 @@ begin and (DataGridTable <> nil) and Assigned(DataGridTable) then begin - KeyName := DataGridTable.QuotedDatabase+'.'+DataGridTable.QuotedName; - FocusedCol := ''; - if DataGrid.FocusedColumn > NoColumn then - FocusedCol := DataGrid.Header.Columns[DataGrid.FocusedColumn].Text; - DataGridFocusedCell.Values[KeyName] := IntToStr(DataGrid.FocusedNode.Index) + DELIM + FocusedCol; + try + KeyName := DataGridTable.QuotedDatabase+'.'+DataGridTable.QuotedName; + FocusedCol := ''; + if DataGrid.FocusedColumn > NoColumn then + FocusedCol := DataGrid.Header.Columns[DataGrid.FocusedColumn].Text; + DataGridFocusedCell.Values[KeyName] := IntToStr(DataGrid.FocusedNode.Index) + DELIM + FocusedCol; + except + on E:EAccessViolation do begin + LogSQL('HandleDataGridAttributes: '+E.Message, lcError); + end; + end; end; DataGridFocusedNodeIndex := 0; DataGridFocusedColumnName := '';