From 45d4bcc5f7067feea4328f784524d5956f14ef84 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 3 Mar 2011 20:25:16 +0000 Subject: [PATCH] Try to fix AV on tab closing, this time by avoiding calls to TControl.ClientToScreen respectively ScreenToClient, which I both suspect to be buggy. Fixes issue #1935. --- source/main.pas | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/main.pas b/source/main.pas index 01eabd73..a0af8068 100644 --- a/source/main.pas +++ b/source/main.pas @@ -8955,7 +8955,7 @@ end; procedure TMainForm.CloseButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var - aPoint: TPoint; + i: Integer; begin // Click on "Close" button of Query tab if Button <> mbLeft then @@ -8964,8 +8964,12 @@ begin // here, we must check if also the MouseDown event was fired on this particular button. See issue #1469. if (Sender <> FLastMouseDownCloseButton) then Exit; - aPoint := PageControlMain.ScreenToClient((Sender as TSpeedButton).ClientToScreen(Point(X,Y))); - CloseQueryTab(GetMainTabAt(aPoint.X, aPoint.Y)); + for i:=0 to QueryTabs.Count-1 do begin + if QueryTabs[i].CloseButton = Sender then begin + CloseQueryTab(QueryTabs[i].TabSheet.PageIndex); + break; + end; + end; end;