* Avoid LCL warning message: use QueueAsyncCall instead of PostMessage to release the edit component

* Fix memory leak when closing an app with an editlink active

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1486 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2011-02-06 11:49:10 +00:00
parent e087c31ada
commit 9d6cd2caad

View File

@ -3164,12 +3164,14 @@ type
// Edit support classes. // Edit support classes.
TStringEditLink = class; TStringEditLink = class;
{ TVTEdit }
TVTEdit = class(TCustomEdit) TVTEdit = class(TCustomEdit)
private private
procedure CMAutoAdjust(var Message: TLMessage); message CM_AUTOADJUST; procedure CMAutoAdjust(var Message: TLMessage); message CM_AUTOADJUST;
procedure CMExit(var Message: TLMessage); message CM_EXIT; procedure CMExit(var Message: TLMessage); message CM_EXIT;
procedure CMRelease(var Message: TLMessage); message CM_RELEASE;
procedure CNCommand(var Message: TLMCommand); message CN_COMMAND; procedure CNCommand(var Message: TLMCommand); message CN_COMMAND;
procedure DoRelease(Data: PtrInt);
procedure WMChar(var Message: TLMChar); message LM_CHAR; procedure WMChar(var Message: TLMChar); message LM_CHAR;
procedure WMDestroy(var Message: TLMDestroy); message LM_DESTROY; procedure WMDestroy(var Message: TLMDestroy); message LM_DESTROY;
procedure WMGetDlgCode(var Message: TLMNoParams); message LM_GETDLGCODE; procedure WMGetDlgCode(var Message: TLMNoParams); message LM_GETDLGCODE;
@ -3182,7 +3184,7 @@ type
public public
constructor Create(Link: TStringEditLink); reintroduce; constructor Create(Link: TStringEditLink); reintroduce;
procedure Release; virtual; procedure Release;
property AutoSelect; property AutoSelect;
property AutoSize; property AutoSize;
@ -11326,7 +11328,6 @@ begin
StopWheelPanning; StopWheelPanning;
//lcl //lcl
FPanningWindow.Free; FPanningWindow.Free;
CancelEditNode;
// Just in case it didn't happen already release the edit link. // Just in case it didn't happen already release the edit link.
FEditLink := nil; FEditLink := nil;
@ -17496,6 +17497,7 @@ begin
DeleteObject(FDottedBrush); DeleteObject(FDottedBrush);
FDottedBrush := 0; FDottedBrush := 0;
CancelEditNode;
inherited; inherited;
{$ifdef DEBUG_VTV}Logger.ExitMethod([lcMessages],'DestroyHandle');{$endif} {$ifdef DEBUG_VTV}Logger.ExitMethod([lcMessages],'DestroyHandle');{$endif}
end; end;
@ -18074,7 +18076,6 @@ begin
DoStateChange([], [tsEditing]); DoStateChange([], [tsEditing]);
if Assigned(FOnEditCancelled) then if Assigned(FOnEditCancelled) then
FOnEditCancelled(Self, FEditColumn); FOnEditCancelled(Self, FEditColumn);
if not (csDestroying in ComponentState) then
FEditLink := nil; FEditLink := nil;
end; end;
end; end;
@ -30443,14 +30444,6 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TVTEdit.CMRelease(var Message: TLMessage);
begin
Free;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TVTEdit.CNCommand(var Message: TLMCommand); procedure TVTEdit.CNCommand(var Message: TLMCommand);
begin begin
@ -30467,6 +30460,13 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TVTEdit.DoRelease(Data: PtrInt);
begin
Free;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TVTEdit.WMChar(var Message: TLMChar); procedure TVTEdit.WMChar(var Message: TLMChar);
begin begin
@ -30633,7 +30633,7 @@ procedure TVTEdit.Release;
begin begin
if HandleAllocated then if HandleAllocated then
PostMessage(Handle, CM_RELEASE, 0, 0); Application.QueueAsyncCall(DoRelease, 0);
end; end;
//----------------- TStringEditLink ------------------------------------------------------------------------------------ //----------------- TStringEditLink ------------------------------------------------------------------------------------