From 7fd0c57640a9493fc5b1a8e955575269bb374d35 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 8 Sep 2012 13:26:55 +0000 Subject: [PATCH] [BUG_FIXED] (Author: Andreas Jonsson) Fix a crash issue on save as command. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@954 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppIO.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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);