SynEdit: Fix crash in highlighting code under QT (Bug #12951)

git-svn-id: trunk@18411 -
This commit is contained in:
martin 2009-01-24 15:12:04 +00:00
parent 17299353b0
commit a9764b3457
2 changed files with 30 additions and 23 deletions

View File

@ -3296,8 +3296,14 @@ var
' Range=', PtrInt(FFoldedLinesView.Ranges[CurLine]) ' Range=', PtrInt(FFoldedLinesView.Ranges[CurLine])
]); ]);
DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine)); DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine));
end else begin end
{$ELSE}
if (FFoldedLinesView.Ranges[CurLine] = nil) then begin
DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine));
end
{$ENDIF} {$ENDIF}
else
begin
fHighlighter.SetRange(FFoldedLinesView.Ranges[CurLine]); //mh 2000-10-10 fHighlighter.SetRange(FFoldedLinesView.Ranges[CurLine]); //mh 2000-10-10
fHighlighter.SetLine(sLine, FFoldedLinesView.TextIndex[CurLine]); fHighlighter.SetLine(sLine, FFoldedLinesView.TextIndex[CurLine]);
// Try to concatenate as many tokens as possible to minimize the count // Try to concatenate as many tokens as possible to minimize the count
@ -3315,9 +3321,7 @@ var
// Let the highlighter scan the next token. // Let the highlighter scan the next token.
fHighlighter.Next; fHighlighter.Next;
end; end;
{$IFDEF DEBUGSYNRANGE}
end; end;
{$ENDIF}
end; end;
// Draw anything that's left in the TokenAccu record. Fill to the end // Draw anything that's left in the TokenAccu record. Fill to the end
// of the invalid area with the correct colors. // of the invalid area with the correct colors.

View File

@ -1642,7 +1642,8 @@ end;
(* Lines *) (* Lines *)
function TSynEditFoldedView.GetLines(index : Integer) : String; function TSynEditFoldedView.GetLines(index : Integer) : String;
begin begin
if (index < 0) or (index > fLinesInWindow) then exit(''); if (index < 0) or (index > fLinesInWindow) then
exit(fLines[ScreenLineToTextIndex(Index)]);
Result := fLines[fTextIndexList[index]]; Result := fLines[fTextIndexList[index]];
end; end;
@ -1655,13 +1656,15 @@ end;
function TSynEditFoldedView.GetRange(Index : integer) : TSynEditRange; function TSynEditFoldedView.GetRange(Index : integer) : TSynEditRange;
begin begin
if (index < 0) or (index > fLinesInWindow) then exit(nil); if (index < 0) or (index > fLinesInWindow) then
exit(fLines.Ranges[ScreenLineToTextIndex(Index)]);
Result := fLines.Ranges[fTextIndexList[index]]; Result := fLines.Ranges[fTextIndexList[index]];
end; end;
function TSynEditFoldedView.GetTextIndex(index : Integer) : Integer; function TSynEditFoldedView.GetTextIndex(index : Integer) : Integer;
begin begin
if (index < 0) or (index > fLinesInWindow) then exit(-1); if (index < 0) or (index > fLinesInWindow) then
exit(ScreenLineToTextIndex(Index));
Result := fTextIndexList[index]; Result := fTextIndexList[index];
end; end;