From 9a3211466a9bebe03cb336ae913aaddbb6349ae7 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 26 Oct 2010 18:47:59 +0000 Subject: [PATCH] Fix detection of focused db object for usage in copy table dialog. Could happen that a trigger with the same name of the wanted table was taken, instead of the table. --- source/copytable.pas | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/source/copytable.pas b/source/copytable.pas index 2e1718c6..b176c511 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -87,28 +87,20 @@ end; procedure TCopyTableForm.FormShow(Sender: TObject); var - Table, Filter: String; + Filter: String; Dummy: String; - DBObjects: TDBObjectList; - Obj: TDBObject; + Obj: PDBObject; Values: TStringList; i, j: Integer; Item: TMenuItem; + Tree: TVirtualStringTree; begin if Mainform.DBtree.Focused then - Table := Mainform.ActiveDbObj.Name + Tree := Mainform.DBtree else - Table := Mainform.ListTables.Text[Mainform.ListTables.FocusedNode, 0]; - DBObjects := MainForm.ActiveConnection.GetDBObjects(Mainform.ActiveDatabase); - FDBObj := nil; - for Obj in DBObjects do begin - if Obj.Name = Table then begin - FDBObj := Obj; - break; - end; - end; - if FDBObj = nil then - Exception.Create('Database object "'+Table+'" not found.'); + Tree := Mainform.ListTables; + Obj := Tree.GetNodeData(Tree.FocusedNode); + FDBObj := Obj^; editNewTablename.Text := FDBObj.Name + '_copy'; editNewTablename.SetFocus; lblNewTablename.Caption := 'Copy ''' + FDBObj.Name + ''' to new db.table:';