From 5f845aa8ffcddead21098e10dbfabf45b1286c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Thu, 21 Dec 2023 13:31:07 +0100 Subject: [PATCH] * Fix AV in some cases. reported by Pascal Riekenberg --- packages/fcl-db/src/base/database.inc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/fcl-db/src/base/database.inc b/packages/fcl-db/src/base/database.inc index 0a7dfc168f..6f7106ed15 100644 --- a/packages/fcl-db/src/base/database.inc +++ b/packages/fcl-db/src/base/database.inc @@ -454,15 +454,14 @@ end; procedure TDBTransaction.SetDatabase(Value: TDatabase); begin - If Value<>FDatabase then - begin - CheckInactive; - If Assigned(FDatabase) then - FDatabase.UnregisterTransaction(Self); - If Value<>Nil Then - Value.RegisterTransaction(Self); - FDatabase:=Value; - end; + If Value=FDatabase then + exit; + CheckInactive; + If Assigned(FDatabase) then + FDatabase.UnregisterTransaction(Self); + If Value<>Nil Then + Value.RegisterTransaction(Self); + FDatabase:=Value; end; constructor TDBTransaction.Create(AOwner: TComponent); @@ -523,9 +522,9 @@ end; destructor TDBTransaction.Destroy; begin - Database:=Nil; CloseDataSets; RemoveDatasets; + Database:=Nil; FDatasets.Free; Inherited; end;