fix possible AV source when updating page caption

This commit is contained in:
Basile Burg 2016-04-16 14:18:38 +02:00
parent d88cc5c4f6
commit 87905802d1
1 changed files with 16 additions and 14 deletions

View File

@ -201,10 +201,11 @@ end;
procedure TCEEditorWidget.docFocused(aDoc: TCESynMemo); procedure TCEEditorWidget.docFocused(aDoc: TCESynMemo);
begin begin
if pageControl.currentPage.Caption = '<new document>' then
updatePageCaption;
if aDoc = fDoc then exit; if aDoc = fDoc then exit;
fDoc := aDoc; fDoc := aDoc;
if fDoc.isNotNil and pageControl.currentPage.isNotNil and
(pageControl.currentPage.Caption = '<new document>') then
updatePageCaption;
focusedEditorChanged; focusedEditorChanged;
updateImperative; updateImperative;
end; end;
@ -510,20 +511,21 @@ end;
procedure TCEEditorWidget.updatePageCaption; procedure TCEEditorWidget.updatePageCaption;
var var
md: string = ''; md: string = '<new document>';
begin begin
if fDoc.isDSource then if fDoc.isNotNil then
begin begin
lex(fDoc.Lines.Text, fTokList, @lexFindToken); if fDoc.isDSource then
md := getModuleName(fTokList); begin
fTokList.Clear; lex(fDoc.Lines.Text, fTokList, @lexFindToken);
if md.isEmpty then md := getModuleName(fTokList);
md := fDoc.fileName.extractFileName; fTokList.Clear;
end if md.isEmpty then
else if fDoc.fileName.fileExists then md := fDoc.fileName.extractFileName;
md := fDoc.fileName.extractFileName end
else else if fDoc.fileName.fileExists then
md := '<new document>'; md := fDoc.fileName.extractFileName
end;
pageControl.currentPage.Caption := md; pageControl.currentPage.Caption := md;
end; end;