Fix issue of showing save dialog twice

The issue:
While running "close all" command the 2nd save dialog is shown for a unsaved cloned doc, but user has repplyed "No" to the unsaved original doc.
This comit make save dialog show once if user's answer is No.

Fix #7523, close #7558
pull/7613/head
Rajendra Singh 5 years ago committed by Don HO
parent 9e37a167f9
commit b694ff23bb
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

@ -36,6 +36,7 @@
#include "functionListPanel.h" #include "functionListPanel.h"
#include "ReadDirectoryChanges.h" #include "ReadDirectoryChanges.h"
#include <tchar.h> #include <tchar.h>
#include <unordered_set>
using namespace std; using namespace std;
@ -899,10 +900,18 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
//closes all documents, makes the current view the only one visible //closes all documents, makes the current view the only one visible
//first check if we need to save any file //first check if we need to save any file
//check in the both view
std::unordered_set<BufferID> uniqueBuffers;
for (size_t i = 0; i < _mainDocTab.nbItem() && !noSaveToAll; ++i) for (size_t i = 0; i < _mainDocTab.nbItem() && !noSaveToAll; ++i)
{ {
BufferID id = _mainDocTab.getBufferByIndex(i); BufferID id = _mainDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager.getBufferByID(id); Buffer * buf = MainFileManager.getBufferByID(id);
// Put all the BufferID from main vaiew to hash table
// hash table is used for fast searching
uniqueBuffers.insert(id);
if (buf->isUntitled() && buf->docLength() == 0) if (buf->isUntitled() && buf->docLength() == 0)
{ {
// Do nothing // Do nothing
@ -981,6 +990,11 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
{ {
BufferID id = _subDocTab.getBufferByIndex(i); BufferID id = _subDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager.getBufferByID(id); Buffer * buf = MainFileManager.getBufferByID(id);
// Is this buffer already included?
if (uniqueBuffers.find(id) != uniqueBuffers.end())
continue;
if (buf->isUntitled() && buf->docLength() == 0) if (buf->isUntitled() && buf->docLength() == 0)
{ {
// Do nothing // Do nothing

Loading…
Cancel
Save