Skip to content

Commit 8b57a57

Browse files
committed
Prevent application crash
When the last file was closed the new file was not grabbing focus, and when switching back to the application the current editor was null. This forces focus on the new file and adds an additional check to prevent any future issues. Closes #749
1 parent 8c014d0 commit 8b57a57

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/NotepadNext/dialogs/MainWindow.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,8 @@ void MainWindow::newFile()
960960
}
961961

962962
if (canUseName) {
963-
app->getEditorManager()->createEditor(newFileName);
963+
ScintillaNext *editor = app->getEditorManager()->createEditor(newFileName);
964+
editor->grabFocus();
964965
break;
965966
}
966967
}
@@ -1886,8 +1887,12 @@ void MainWindow::focusIn()
18861887
{
18871888
qInfo(Q_FUNC_INFO);
18881889

1889-
if (checkFileForModification(currentEditor())) {
1890-
updateGui(currentEditor());
1890+
ScintillaNext *editor = currentEditor();
1891+
1892+
if (editor) {
1893+
if (checkFileForModification(currentEditor())) {
1894+
updateGui(currentEditor());
1895+
}
18911896
}
18921897
}
18931898

0 commit comments

Comments
 (0)