Fix file saving crash due to invald buffer
While trying to save a untitled empty document, user could open a existing file that erases the untitled document's buffer, then save action make Notepad++ crash: https://www.youtube.com/watch?v=balHtvy4Toc Fixes #1857, Closes #1904
This commit is contained in:
parent
4c26009a2e
commit
15561c8d69
@ -453,6 +453,18 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
|
|||||||
|
|
||||||
bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
||||||
{
|
{
|
||||||
|
const int index = MainFileManager->getBufferIndexByID(id);
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
_nativeLangSpeaker.messageBox("BufferInvalidWarning",
|
||||||
|
_pPublicInterface->getHSelf(),
|
||||||
|
TEXT("Cannot save: Buffer is invalid."),
|
||||||
|
TEXT("Save failed"),
|
||||||
|
MB_OK | MB_ICONWARNING);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SCNotification scnN;
|
SCNotification scnN;
|
||||||
// Notify plugins that current file is about to be saved
|
// Notify plugins that current file is about to be saved
|
||||||
if (!isCopy)
|
if (!isCopy)
|
||||||
|
Loading…
Reference in New Issue
Block a user