fix AV if second DragStop being called. (Second DragStop freed performer and returned execution to first DragStop which was inside that freed performer)

git-svn-id: trunk@13577 -
This commit is contained in:
paul 2008-01-02 09:17:52 +00:00
parent 28f8ce52b5
commit 2db37e8ee3

View File

@ -80,6 +80,7 @@ type
FStartPosition: TPoint;//mouse position at start of drag or dock FStartPosition: TPoint;//mouse position at start of drag or dock
FThresholdValue: Integer;//treshold before the drag becomes activated FThresholdValue: Integer;//treshold before the drag becomes activated
FWaitForTreshold: boolean;//are we waiting on the treshold activation FWaitForTreshold: boolean;//are we waiting on the treshold activation
FInDragStop: Boolean; // semaphore to prevent second execution of dragStop
protected protected
//Support input capture //Support input capture
procedure KeyUp(var Key: Word; Shift : TShiftState); override; procedure KeyUp(var Key: Word; Shift : TShiftState); override;
@ -89,6 +90,7 @@ type
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override; procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override; procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
public public
constructor Create; override;
destructor Destroy; override; destructor Destroy; override;
//Support methods //Support methods
@ -579,11 +581,15 @@ end;
procedure TDragManagerDefault.DragStop(ADropped : Boolean); procedure TDragManagerDefault.DragStop(ADropped : Boolean);
//End the drag operation //End the drag operation
begin begin
if FPerformer <> nil then try if (FPerformer <> nil) and not FInDragStop then
FPerformer.DragStop(ADropped); begin
finally FInDragStop := True;
FPerformer.Free; try
FPerformer:=nil; FPerformer.DragStop(ADropped);
finally
FreeAndNil(FPerformer);
FInDragStop := False;
end;
end; end;
end; end;
@ -620,6 +626,12 @@ begin
//DragStop(true); //DragStop(true);
end; end;
constructor TDragManagerDefault.Create;
begin
inherited Create;
FInDragStop := False;
end;
procedure TDragManagerDefault.MouseMove(Shift: TShiftState; X, Y: Integer); procedure TDragManagerDefault.MouseMove(Shift: TShiftState; X, Y: Integer);
var P: TPoint; var P: TPoint;
begin begin