diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index d2121395..69e68a7e 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -833,8 +833,17 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy) fDlg.setDefFileName(buf->getFileName()); fDlg.setExtIndex(langTypeIndex+1); // +1 for "All types" + + // Disable file autodetection before opening save dialog to prevent use-after-delete bug. + NppParameters *pNppParam = NppParameters::getInstance(); + ChangeDetect cdBefore = ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection; + ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection = cdDisabled; + TCHAR *pfn = fDlg.doSaveDlg(); + // Enable file autodetection again. + ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection = cdBefore; + if (pfn) { BufferID other = _pNonDocTab->findBufferByName(pfn);