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,28 +3296,32 @@ var
' Range=', PtrInt(FFoldedLinesView.Ranges[CurLine])
]);
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}
fHighlighter.SetRange(FFoldedLinesView.Ranges[CurLine]); //mh 2000-10-10
fHighlighter.SetLine(sLine, FFoldedLinesView.TextIndex[CurLine]);
// Try to concatenate as many tokens as possible to minimize the count
// of ExtTextOut calls necessary. This depends on the selection state
// or the line having special colors. For spaces the foreground color
// is ignored as well.
//debugln('>>>> PaintLines Line=',dbgs(CurLine),' rect=',dbgs(rcToken));
while not fHighlighter.GetEol do begin
fHighlighter.GetTokenEx(sToken,nTokenLen);
attr := fHighlighter.GetTokenAttribute;
// Add Markup to the token and append it to the TokenAccu
// record. This will paint any chars already stored if there is
// a (visible) change in the attributes.
DrawHiLightMarkupToken(attr,sToken,nTokenLen);
// Let the highlighter scan the next token.
fHighlighter.Next;
else
begin
fHighlighter.SetRange(FFoldedLinesView.Ranges[CurLine]); //mh 2000-10-10
fHighlighter.SetLine(sLine, FFoldedLinesView.TextIndex[CurLine]);
// Try to concatenate as many tokens as possible to minimize the count
// of ExtTextOut calls necessary. This depends on the selection state
// or the line having special colors. For spaces the foreground color
// is ignored as well.
//debugln('>>>> PaintLines Line=',dbgs(CurLine),' rect=',dbgs(rcToken));
while not fHighlighter.GetEol do begin
fHighlighter.GetTokenEx(sToken,nTokenLen);
attr := fHighlighter.GetTokenAttribute;
// Add Markup to the token and append it to the TokenAccu
// record. This will paint any chars already stored if there is
// a (visible) change in the attributes.
DrawHiLightMarkupToken(attr,sToken,nTokenLen);
// Let the highlighter scan the next token.
fHighlighter.Next;
end;
end;
{$IFDEF DEBUGSYNRANGE}
end;
{$ENDIF}
end;
// Draw anything that's left in the TokenAccu record. Fill to the end
// of the invalid area with the correct colors.

View File

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