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,7 +511,9 @@ end;
procedure TCEEditorWidget.updatePageCaption;
var
md: string = '';
md: string = '<new document>';
begin
if fDoc.isNotNil then
begin
if fDoc.isDSource then
begin
@ -522,8 +525,7 @@ begin
end
else if fDoc.fileName.fileExists then
md := fDoc.fileName.extractFileName
else
md := '<new document>';
end;
pageControl.currentPage.Caption := md;
end;