From 7999de397db335b5a0cda09cfbb7f644eabf00e6 Mon Sep 17 00:00:00 2001 From: dmitry Date: Tue, 16 Feb 2010 14:39:39 +0000 Subject: [PATCH] carbon: fix for emulated caret and releasing widgetset git-svn-id: trunk@23719 - --- lcl/interfaces/carbon/carboncaret.pas | 19 +++++++++++++++---- lcl/interfaces/carbon/carbonobject.inc | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/carbon/carboncaret.pas b/lcl/interfaces/carbon/carboncaret.pas index cc72cced78..074024f543 100644 --- a/lcl/interfaces/carbon/carboncaret.pas +++ b/lcl/interfaces/carbon/carboncaret.pas @@ -37,7 +37,7 @@ uses // Free Pascal Classes, SysUtils, Types, // Widgetset - CarbonDef, CarbonGDIObjects, + CarbonDef, CarbonGDIObjects, CarbonInt, // LCL LCLType, LCLIntf, LCLProc, Graphics, ExtCtrls, Forms; @@ -57,6 +57,7 @@ type FVisibleState: Boolean; FRespondToFocus: Boolean; FCaretCS: System.PRTLCriticalSection; + FWidgetSetReleased: Boolean; procedure SetPos(const Value: TPoint); procedure UpdateCall(Data: PtrInt); protected @@ -94,6 +95,8 @@ procedure SetCarbonCaretRespondToFocus(Value: Boolean); function DestroyCaret: Boolean; procedure DrawCaret; procedure DestroyGlobalCaret; +//todo: make a better solution for the Widgetset released before GlobalCaret +procedure CaretWidgetSetReleased; implementation @@ -298,7 +301,7 @@ end; function TEmulatedCaret.DestroyCaret: Boolean; begin - FTimer.Enabled := False; + if FTimer<>nil then FTimer.Enabled := False; FVisible := False; FVisibleRealized := False; FVisibleState := False; @@ -420,7 +423,7 @@ procedure TEmulatedCaret.UpdateCaret; var R: TRect; begin - if (FWidget = nil) then Exit; + if (FWidget = nil) or FWidgetSetReleased then Exit; if FWidget.Painting then Exit; if not IsValid then Exit; @@ -442,8 +445,16 @@ begin UpdateCaret; end; -finalization +procedure CaretWidgetSetReleased; +begin + if Assigned(GlobalCaret) then begin + GlobalCaret.fTimer.Free; + GlobalCaret.fTimer:=nil; + GlobalCaret.FWidgetSetReleased:=True; + end; +end; +finalization DestroyGlobalCaret; diff --git a/lcl/interfaces/carbon/carbonobject.inc b/lcl/interfaces/carbon/carbonobject.inc index ba1994ed65..9bf43a86fa 100644 --- a/lcl/interfaces/carbon/carbonobject.inc +++ b/lcl/interfaces/carbon/carbonobject.inc @@ -579,6 +579,8 @@ end; ------------------------------------------------------------------------------} destructor TCarbonWidgetSet.Destroy; begin + CaretWidgetSetReleased; + FreeAndNil(FTimerMap); DisposeAEEventHandlerUPP(FOpenEventHandlerUPP); DisposeAEEventHandlerUPP(FQuitEventHandlerUPP);