[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
This commit is contained in:
Don Ho 2012-09-08 13:26:55 +00:00
parent f1a2acd85f
commit 7fd0c57640
1 changed files with 9 additions and 0 deletions

View File

@ -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);