Fix repeated requests of reloading from disk

A popuped message appear for the 1st modification from outside of
Notepad++, if users ignore it and save another change outside, the 2nd
popuped message appears. This commit fix this bad behaviour, which could
lead crash.

Closes #3307
This commit is contained in:
Boris 2017-05-23 00:17:27 +03:00 committed by Don HO
parent 71ffe870c5
commit 85216fe577
2 changed files with 20 additions and 4 deletions

View File

@ -250,7 +250,12 @@ bool Buffer::checkFileState() //eturns true if the status has been changed (it c
_currentStatus = DOC_MODIFIED;
_timeStamp = buf.st_mtime;
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
if (_reloadFromDiskRequestGuard.try_lock())
{
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
_reloadFromDiskRequestGuard.unlock();
}
isOK = true;
}
}
@ -273,10 +278,17 @@ bool Buffer::checkFileState() //eturns true if the status has been changed (it c
if (mask != 0)
{
doNotify(mask);
isOK = true;
if (_reloadFromDiskRequestGuard.try_lock())
{
doNotify(mask);
_reloadFromDiskRequestGuard.unlock();
return true;
}
}
isOK = false;
return false;
}
if (isWow64Off)

View File

@ -25,6 +25,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#pragma once
#include <mutex>
#include "Utf8_16.h"
@ -413,4 +415,6 @@ private:
bool _hasLangBeenSetFromMenu = false;
MapPosition _mapPosition;
std::mutex _reloadFromDiskRequestGuard;
};