MG: fixed synedit crash on exit

git-svn-id: trunk@1476 -
This commit is contained in:
lazarus 2002-03-04 10:01:01 +00:00
parent 2e084658ef
commit 8e4ae5f28d
4 changed files with 26 additions and 16 deletions

View File

@ -1371,7 +1371,7 @@ function TCodeToolManager.OnGetCodeToolForBuffer(Sender: TObject;
begin
{$IFDEF CTDEBUG}
writeln('[TCodeToolManager.OnGetCodeToolForBuffer]'
,' Sender=',TCustomCodeTool(Sender).Scanner.MainSource.Filename
,' Sender=',TCustomCodeTool(Sender).MainFilename
,' Code=',Code.Filename);
{$ENDIF}
Result:=TFindDeclarationTool(GetCodeToolForSource(Code,true));

View File

@ -108,7 +108,7 @@ function UpperCaseStr(const s: string): string;
var i, l: integer;
begin
l:=length(s);
Setlength(Result,l);
SetLength(Result,l);
for i:=1 to l do
Result[i]:=UpChars[s[i]];
end;

View File

@ -477,6 +477,7 @@ var
c1, c2: char;
begin
// Skip all spaces and comments
//writeln(' TLinkScanner.ReadNextToken SrcPos=',SrcPos,' SrcLen=',SrcLen,' "',copy(Src,SrcPos,5),'" "',copy(UpperSrc,SrcPos,5),'"');
if (SrcPos>SrcLen) then ReturnFromIncludeFile;
while SrcPos<=SrcLen do begin
if IsCommentStartChar[Src[SrcPos]] then begin
@ -625,10 +626,11 @@ writeln('TLinkScanner.Scan C ',SrcLen);
LastTokenIsEqual:=false;
LastTokenIsEnd:=false;
{$IFDEF CTDEBUG}
writeln('TLinkScanner.Scan A ',SrcLen);
writeln('TLinkScanner.Scan D ',SrcLen);
{$ENDIF}
repeat
ReadNextToken;
//writeln('TLinkScanner.Scan E "',copy(Src,TokenStart,SrcPos-TokenStart),'"');
UpdateCleanedSource(SrcPos-1);
if (SrcPos<=SrcLen+1) then begin
if (not LastTokenIsEqual) and

View File

@ -432,9 +432,17 @@ procedure TheFontsInfoManager.UnlockFontsInfo(
begin
with pFontsInfo^ do
begin
{$IFDEF SYN_LAZARUS}
if LockCount>0 then begin
Dec(LockCount);
if 0 = LockCount then
DestroyFontHandles(pFontsInfo);
end;
{$ELSE}
Dec(LockCount);
if 0 = LockCount then
DestroyFontHandles(pFontsInfo);
{$ENDIF}
end;
end;
@ -531,6 +539,12 @@ begin
{$ENDIF}
end;
end;
{$IFDEF SYN_LAZARUS}
if SynTextDrawerFinalization and (FFontsInfo.Count=0) then
// the program is in the finalization phase
// and this object is not used anymore -> destroy it
Free;
{$ENDIF}
end;
procedure TheFontsInfoManager.RetrieveLogFontForComparison(ABaseFont: TFont;
@ -639,7 +653,6 @@ end;
constructor TheFontStock.Create(InitialFont: TFont);
begin
writeln(' AAA TheFontStock.Create Self=',HexStr(Cardinal(Self),8));
inherited Create;
SetBaseFont(InitialFont);
@ -647,8 +660,6 @@ end;
destructor TheFontStock.Destroy;
begin
writeln(' AAA TheFontStock.Destroy Self=',HexStr(Cardinal(Self),8));
ReleaseFontsInfo;
ASSERT(FDCRefCount = 0);
@ -745,8 +756,6 @@ end;
procedure TheFontStock.ReleaseFontsInfo;
begin
writeln(' AAA TheFontStock.ReleaseFontsInfo Self=',HexStr(Cardinal(Self),8));
if Assigned(FpInfo) then
with GetFontsInfoManager do
begin
@ -853,14 +862,10 @@ begin
SetBaseFont(ABaseFont);
FColor := clWindowText;
FBkColor := clWindow;
writeln(' AAA TheTextDrawer.Create Self=',HexStr(Cardinal(Self),8));
end;
destructor TheTextDrawer.Destroy;
begin
writeln(' AAA TheTextDrawer.Destroy Self=',HexStr(Cardinal(Self),8));
FFontStock.Free;
ReleaseETODist;
@ -1283,7 +1288,6 @@ end;
{$ENDIF} // HE_LEADBYTES
initialization
{$IFDEF SYN_LAZARUS}
SynTextDrawerFinalization:=false;
{$ENDIF}
@ -1293,11 +1297,15 @@ initialization
finalization
{$IFDEF SYN_LAZARUS}
// MG: We can't free the gFontsInfoManager here, because the synedit
// components need it and will be destroyed with the Application object in
// the lcl after this finalization section.
// So, the flag SynTextDrawerFinalization is set and the gFontsInfoManager
// will destroy itself, as soon, as it is not used anymore.
SynTextDrawerFinalization:=true;
{$ELSE}
FreeAndNil(gFontsInfoManager);
{$ENDIF}
gFontsInfoManager.Free;
gFontsInfoManager:=nil;
end.