From 55f2644953b4de88a1995e5e6ad92ac9a0bc8cce Mon Sep 17 00:00:00 2001 From: mere-human <9664141+mere-human@users.noreply.github.com> Date: Wed, 1 Sep 2021 22:18:10 +0300 Subject: [PATCH] Fix regression: no error message when locked file could not be saved Show file locked warning. This is a regression from commit 469fa62c0ebc438c8003c735e6a801c6d098df7c Fix #9994, close #10487 --- PowerEditor/src/NppIO.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 7a99648f3..12312a607 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -569,9 +569,18 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy) } else if (res == SavingStatus::SaveOpenFailed) { - // try to open Notepad++ in admin mode - if (!_isAdministrator) + if (_isAdministrator) { + // Already in admin mode? File is probably locked. + _nativeLangSpeaker.messageBox("FileLockedWarning", + _pPublicInterface->getHSelf(), + TEXT("Please check whether if this file is opened in another program"), + TEXT("Save failed"), + MB_OK | MB_ICONWARNING); + } + else + { + // try to open Notepad++ in admin mode bool isSnapshotMode = NppParameters::getInstance().getNppGUI().isSnapshotMode(); if (isSnapshotMode) // if both rememberSession && backup mode are enabled { // Open the 2nd Notepad++ instance in Admin mode, then close the 1st instance.