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