Fix Notepad++ doesn't exit correctly while Windows 10 update restart
If Windows 10 update needs to restart, and Notepad++ has one (some) dirty document(s), and "Enable session snapshot and periodic backup" is not enabled, then WM_ENDSESSION is send with wParam == FALSE, not waiting for WM_QUERYENDSESSION's treatment finish. In this case Notepad++ should quit after saving its current session. Fix #6086, fix #5831, fix #7854
This commit is contained in:
parent
4d5abdf1c8
commit
62efa463b0
|
@ -382,6 +382,12 @@ private:
|
|||
bool _isFileOpening = false;
|
||||
bool _isAdministrator = false;
|
||||
|
||||
bool _isEndingSessionButNotReady = false; // If Windows 10 update needs to restart
|
||||
// and Notepad++ has one (some) dirty document(s)
|
||||
// and "Enable session snapshot and periodic backup" is not enabled
|
||||
// then WM_ENDSESSION is send with wParam == FALSE
|
||||
// in this case this boolean is set true, so Notepad++ will quit and its current session will be saved
|
||||
|
||||
ScintillaCtrls _scintillaCtrls4Plugins;
|
||||
|
||||
std::vector<std::pair<int, int> > _hideLinesMarks;
|
||||
|
|
|
@ -1855,13 +1855,25 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
updater.run(nppParam.shouldDoUAC());
|
||||
}
|
||||
}
|
||||
|
||||
// _isEndingSessionButNotReady is true means WM_QUERYENDSESSION is sent but no time to finish saving data
|
||||
// then WM_ENDSESSION is sent with wParam == FALSE - Notepad++ should exit in this case
|
||||
if (_isEndingSessionButNotReady)
|
||||
::DestroyWindow(hwnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_ENDSESSION:
|
||||
{
|
||||
if (wParam == TRUE)
|
||||
{
|
||||
::DestroyWindow(hwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
_isEndingSessionButNotReady = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue