Fix wrong backup file deleted isuue

On doClose() delete the right backup file

Fix #4744, close #4745
This commit is contained in:
Pavel Nedev 2018-08-06 15:42:40 +03:00 committed by Don HO
parent 4969f377ad
commit b48c086831
3 changed files with 5 additions and 5 deletions

View File

@ -618,7 +618,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
((_mainWindowStatus & WindowSubActive) == WindowSubActive ? _subDocTab.nbItem() : 0);
if (doDeleteBackup)
MainFileManager->deleteCurrentBufferBackup();
MainFileManager->deleteBufferBackup(id);
Buffer * buf = MainFileManager->getBufferByID(id);

View File

@ -975,7 +975,7 @@ private:
HANDLE _h;
};
bool FileManager::deleteCurrentBufferBackup()
bool FileManager::deleteBufferBackup(BufferID id)
{
HANDLE writeEvent = ::OpenEvent(EVENT_ALL_ACCESS, TRUE, TEXT("nppWrittingEvent"));
if (!writeEvent)
@ -988,7 +988,7 @@ bool FileManager::deleteCurrentBufferBackup()
if (::WaitForSingleObject(writeEvent, INFINITE) != WAIT_OBJECT_0)
{
// problem!!!
printStr(TEXT("WaitForSingleObject problem in deleteCurrentBufferBackup()!"));
printStr(TEXT("WaitForSingleObject problem in deleteBufferBackup()!"));
return false;
}
@ -998,7 +998,7 @@ bool FileManager::deleteCurrentBufferBackup()
EventReset reset(writeEvent); // Will reset event in destructor.
Buffer* buffer = _pNotepadPlus->getCurrentBuffer();
Buffer* buffer = getBufferByID(id);
bool result = true;
generic_string backupFilePath = buffer->getBackupFileName();
if (not backupFilePath.empty())

View File

@ -102,7 +102,7 @@ public:
bool reloadBufferDeferred(BufferID id);
bool saveBuffer(BufferID id, const TCHAR* filename, bool isCopy = false, generic_string * error_msg = NULL);
bool backupCurrentBuffer();
bool deleteCurrentBufferBackup();
bool deleteBufferBackup(BufferID id);
bool deleteFile(BufferID id);
bool moveFile(BufferID id, const TCHAR * newFilename);
bool createEmptyFile(const TCHAR * path);