Datei IdComponent.pas
Delphi-Quellcode:
destructor TIdComponent.Destroy;
begin
inherited Destroy;
// After inherited - do at last possible moment
+
if Assigned(GStackCriticalSection)
then
GStackCriticalSection.Acquire;
try
Dec(GInstanceCount);
if GInstanceCount = 0
then begin
// This CS will guarantee that during the FreeAndNil nobody will try to use
// or construct GStack
FreeAndNil(GStack);
end;
finally
+
if Assigned(GStackCriticalSection)
then
GStackCriticalSection.Release;
end;
end;
...
initialization
GStackCriticalSection := TCriticalSection.Create;
finalization
-
// Dont Free. If shutdown is from another Init section, it can cause GPF when stack
-
// tries to access it. App will kill it off anyways, so just let it leak
-
// FreeAndNil(GStackCriticalSection);
+ FreeAndNil(GStackCriticalSection);
end.
Das die beim schreiben des Kommentars nicht gleich darauf gekommen sind
Aber der
Indy-Code ist sowieso etwas undurchsichtig (von der Formatierung mal abgesehen)