Bugfix: regression introduced in revision 1104 - Abort()ing in popupTreeView causes various misbehaviours.

Also added three debug statements so the rest of you can test and see that things happen in the right order now; feel free to remove these.
This commit is contained in:
rosenfield
2007-11-08 12:10:37 +00:00
parent c8d8712a89
commit a706163966
3 changed files with 14 additions and 9 deletions

View File

@ -57,7 +57,6 @@ object MDIChild: TMDIChild
HotTrack = True
Images = MainForm.ImageList1
Indent = 19
PopupMenu = popupTreeView
ReadOnly = True
RightClickSelect = True
RowSelect = True
@ -65,6 +64,7 @@ object MDIChild: TMDIChild
TabOrder = 0
OnChange = DBtreeChange
OnChanging = DBtreeChanging
OnContextPopup = DBtreeContextPopup
OnExpanding = DBtreeExpanding
end
object TableShow: TPanel

View File

@ -308,6 +308,8 @@ type
N25: TMenuItem;
menuLogToFile: TMenuItem;
menuOpenLogFolder: TMenuItem;
procedure DBtreeContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
procedure DBtreeChanging(Sender: TObject; Node: TTreeNode;
var AllowChange: Boolean);
procedure menuRenameColumnClick(Sender: TObject);
@ -1494,6 +1496,15 @@ begin
end;
procedure TMDIChild.DBtreeContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
begin
debug('context menu; storing right click item so it won''t get lost');
DBRightClickSelectedItem := DBtree.Selected;
popupTreeView.Popup(MousePos.X, MousePos.Y);
PostMessage(MainForm.Handle, WM_CLEAR_RIGHTCLICK_POINTER, 0, 0);
end;
{***
A database-node is about to be expanded:
Drop the dummy-node and add all tables
@ -4513,7 +4524,6 @@ end;
procedure TMDIChild.popupTreeViewPopup(Sender: TObject);
begin
if DBRightClickSelectedItem <> nil then Exit;
// toggle drop-items and remember right-clicked item
PopupMenuDropDatabase.Enabled := DBtree.Selected.Level = 1;
PopupMenuCreateTable.Enabled := DBtree.Selected.Level in [1,2];
@ -4524,13 +4534,6 @@ begin
menuAlterDatabase.Hint := 'Rename and/or modify character set of database';
menuTreeAlterTable.Enabled := DBtree.Selected.Level = 2;
MainForm.DropTable.Enabled := DBtree.Selected.Level = 2;
DBRightClickSelectedItem := DBtree.Selected;
try
popupTreeView.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
Abort;
finally
PostMessage(MainForm.Handle, WM_CLEAR_RIGHTCLICK_POINTER, 0, 0);
end;
end;

View File

@ -285,6 +285,7 @@ end;
procedure TMainForm.HandleWMClearRightClickPointer(var msg: TMessage);
begin
debug('clearing stored right click item');
ChildWin.DBRightClickSelectedItem := nil;
end;
@ -955,6 +956,7 @@ var
t : TStringList;
db, msg, sql, activeDB : String;
begin
debug('drop table activated');
t := TStringlist.Create;
// Set default database name to to ActiveDatabase.
// Can be overwritten when someone selects a table in dbtree from different database