Add update Notepad++ on exit feature

And add `/relaunchNppAfterSilentInstall` into installer (ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/15280#issuecomment-2246816010)

Fix #16601, fix #13749, fix #10317, fix #8495, fix #8457, fix #3755, close #16626
This commit is contained in:
xomx 2025-06-02 19:49:21 +02:00 committed by Don Ho
parent abba79ceaa
commit bc99de07bb
11 changed files with 142 additions and 106 deletions

View File

@ -1352,13 +1352,18 @@ Translation note:
<Element name="DirectWrite (draw to GDI DC)"/>
<Element name="DirectWrite (DirectX 11)"/>
</ComboBox>
<ComboBox id="6364">
<Element name="Disable"/>
<Element name="Enable on Notepad++ startup"/>
<Element name="Enable on Notepad++ exit"/>
</ComboBox>
<Item id="6308" name="system tray"/>
<Item id="6363" name="rendering mode"/>
<Item id="6365" name="Auto-updater:"/>
<Item id="6312" name="File Status Auto-Detection"/>
<Item id="6313" name="Update silently"/>
<Item id="6325" name="Scroll to the last line after update"/>
<Item id="6322" name="Session file ext.:"/>
<Item id="6323" name="Enable Notepad++ auto-updater"/>
<Item id="6324" name="Document Switcher (Ctrl+TAB)"/>
<Item id="6331" name="Show only filename in title bar"/>
<Item id="6334" name="Autodetect character encoding"/>

View File

@ -1352,13 +1352,18 @@ Translation note:
<Element name="DirectWrite (draw to GDI DC)"/>
<Element name="DirectWrite (DirectX 11)"/>
</ComboBox>
<ComboBox id="6364">
<Element name="Disable"/>
<Element name="Enable on Notepad++ startup"/>
<Element name="Enable on Notepad++ exit"/>
</ComboBox>
<Item id="6308" name="system tray"/>
<Item id="6363" name="rendering mode"/>
<Item id="6365" name="Auto-updater:"/>
<Item id="6312" name="File Status Auto-Detection"/>
<Item id="6313" name="Update silently"/>
<Item id="6325" name="Scroll to the last line after update"/>
<Item id="6322" name="Session file ext.:"/>
<Item id="6323" name="Enable Notepad++ auto-updater"/>
<Item id="6324" name="Document Switcher (Ctrl+TAB)"/>
<Item id="6331" name="Show only filename in title bar"/>
<Item id="6334" name="Autodetect character encoding"/>

View File

@ -57,8 +57,9 @@ OutFile ".\build\npp.${APPVERSION}.Installer.exe"
VIAddVersionKey "FileVersion" "${Version}"
VIAddVersionKey "ProductVersion" "${ProdVer}"
; ------------------------------------------------------------------------
; Insert CheckIfRunning function as an installer and uninstaller function.
Var runningNppDetected
!insertmacro CheckIfRunning ""
!insertmacro CheckIfRunning "un."
@ -117,6 +118,7 @@ Var diffArchDir2Remove
Var noUpdater
Var closeRunningNpp
Var runNppAfterSilentInstall
Var relaunchNppAfterSilentInstall
!ifdef ARCH64 || ARCHARM64
; this is needed for the 64-bit InstallDirRegKey patch
@ -133,7 +135,7 @@ Function .onInit
; so the InstallDirRegKey checks for the irrelevant HKLM\SOFTWARE\WOW6432Node\Notepad++, explanation:
; https://nsis.sourceforge.io/Reference/SetRegView
;
!ifdef ARCH64 || ARCHARM64
!ifdef ARCH64 || ARCHARM64
${If} ${RunningX64}
System::Call kernel32::GetCommandLine()t.r0 ; get the original cmdline (where a possible "/D=..." is not hidden from us by NSIS)
${StrStr} $1 $0 "/D="
@ -152,6 +154,7 @@ Function .onInit
;
; --- PATCH END ---
StrCpy $runningNppDetected "false" ; reset
; Begin of "/closeRunningNpp"
${GetParameters} $R0
@ -172,14 +175,13 @@ closeRunningNppCheckDone:
IfSilent 0 notInSilentMode
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "nppInstance") i .R0'
IntCmp $R0 0 nppNotRunning
StrCpy $runningNppDetected "true"
System::Call 'kernel32::CloseHandle(i $R0)' ; a Notepad++ instance is running, tidy-up the opened mutex handle only
SetErrorLevel 5 ; set an exit code > 0 otherwise the installer returns 0 aka SUCCESS ('5' means here the future ERROR_ACCESS_DENIED when trying to overwrite the notepad++.exe file...)
Quit ; silent installation is silent, currently we cannot continue without a user interaction (TODO: a new "/closeRunningNppAutomatically" installer optional param...)
Quit ; silent installation is silent, we cannot continue here without a user interaction (or the installation should have been launched with the "/closeRunningNpp" param)
nppNotRunning:
notInSilentMode:
; End of "/closeRunningNpp"
; Begin of "/noUpdater"
${GetParameters} $R0
@ -200,7 +202,6 @@ updaterDone:
${EndIf}
; End of "/noUpdater"
; Begin of "/runNppAfterSilentInstall"
${GetParameters} $R0
${GetOptions} $R0 "/runNppAfterSilentInstall" $R1 ;case insensitive
@ -212,7 +213,18 @@ runNpp:
StrCpy $runNppAfterSilentInstall "true"
runNppDone:
; End of "/runNppAfterSilentInstall"
; Begin of "/relaunchNppAfterSilentInstall"
${GetParameters} $R0
${GetOptions} $R0 "/relaunchNppAfterSilentInstall" $R1 ;case insensitive
IfErrors noRelaunchNpp relaunchNpp
noRelaunchNpp:
StrCpy $relaunchNppAfterSilentInstall "false"
Goto relaunchNppDone
relaunchNpp:
StrCpy $relaunchNppAfterSilentInstall "true"
relaunchNppDone:
; End of "/relaunchNppAfterSilentInstall"
${If} ${SectionIsSelected} ${PluginsAdmin}
!insertmacro SetSectionFlag ${AutoUpdater} ${SF_RO}
@ -382,10 +394,14 @@ FunctionEnd
; which is visible in control panel in column named "size"
Section -FinishSection
Call writeInstallInfoInRegistry
IfSilent 0 theEnd
${If} $runNppAfterSilentInstall == "true"
Call LaunchNpp
Call writeInstallInfoInRegistry
IfSilent 0 theEnd
${If} $runNppAfterSilentInstall == "true"
Call LaunchNpp ; always launch
${ElseIf} $relaunchNppAfterSilentInstall == "true"
${If} $runningNppDetected == "true"
Call LaunchNpp ; relaunch
${EndIf}
${EndIf}
theEnd:
SectionEnd

View File

@ -52,6 +52,7 @@ FunctionEnd
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "nppInstance") i .R0'
IntCmp $R0 0 NotRunning
StrCpy $runningNppDetected "true"
System::Call 'kernel32::CloseHandle(i $R0)'
MessageBox MB_RETRYCANCEL|MB_DEFBUTTON1|MB_ICONSTOP "Cannot continue the installation: Notepad++ is running.\
$\n$\n\
@ -236,6 +237,7 @@ FunctionEnd
IntPtrCmp $0 0 processNotRunning
IsWindow $0 0 processNotRunning
StrCpy $runningNppDetected "true"
IfSilent skipDetailPrint 0
DetailPrint "Closing the ${RUNPROC_WND_CLASS} app running..."
skipDetailPrint:

View File

@ -765,7 +765,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_DISABLEAUTOUPDATE:
{
NppGUI & nppGUI = nppParam.getNppGUI();
nppGUI._autoUpdateOpt._doAutoUpdate = false;
nppGUI._autoUpdateOpt._doAutoUpdate = NppGUI::autoupdate_disabled;
return TRUE;
}
@ -3539,7 +3539,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
{
//printStr(L"you've got me"));
NppGUI & nppGUI = nppParam.getNppGUI();
nppGUI._autoUpdateOpt._doAutoUpdate = false;
nppGUI._autoUpdateOpt._doAutoUpdate = NppGUI::autoupdate_disabled;
return TRUE;
}

View File

@ -5943,7 +5943,11 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
{
const wchar_t* val = n->Value();
if (val)
_nppGUI._autoUpdateOpt._doAutoUpdate = (!lstrcmp(val, L"yes"))?false:true;
{
// for backward compatibility with older configs
_nppGUI._autoUpdateOpt._doAutoUpdate = (!lstrcmp(val, L"yes")) ?
NppGUI::AutoUpdateMode::autoupdate_disabled : NppGUI::AutoUpdateMode::autoupdate_on_startup;
}
int i;
val = element->Attribute(L"intervalDays", &i);
@ -5953,6 +5957,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
val = element->Attribute(L"nextUpdateDate");
if (val)
_nppGUI._autoUpdateOpt._nextUpdateDate = Date(val);
val = element->Attribute(L"autoUpdateMode", &i);
if (val)
_nppGUI._autoUpdateOpt._doAutoUpdate = static_cast<NppGUI::AutoUpdateMode>(i); // newer config, so overwrite
}
}
@ -7429,9 +7437,10 @@ void NppParameters::createXmlTreeFromGUIParams()
// <GUIConfig name="noUpdate" intervalDays="15" nextUpdateDate="20161022">no</GUIConfig>
{
TiXmlElement *element = insertGUIConfigBoolNode(newGUIRoot, L"noUpdate", !_nppGUI._autoUpdateOpt._doAutoUpdate);
TiXmlElement *element = insertGUIConfigBoolNode(newGUIRoot, L"noUpdate", !(_nppGUI._autoUpdateOpt._doAutoUpdate != NppGUI::autoupdate_disabled));
element->SetAttribute(L"intervalDays", _nppGUI._autoUpdateOpt._intervalDays);
element->SetAttribute(L"nextUpdateDate", _nppGUI._autoUpdateOpt._nextUpdateDate.toString().c_str());
element->SetAttribute(L"autoUpdateMode", _nppGUI._autoUpdateOpt._doAutoUpdate);
}
// <GUIConfig name="Auto-detection">yes</GUIConfig>

View File

@ -946,9 +946,10 @@ struct NppGUI final
// items with no Notepad++ GUI to set
std::wstring _commandLineInterpreter = CMD_INTERPRETER;
enum AutoUpdateMode { autoupdate_disabled, autoupdate_on_startup, autoupdate_on_exit };
struct AutoUpdateOptions
{
bool _doAutoUpdate = true;
AutoUpdateMode _doAutoUpdate = autoupdate_on_startup;
int _intervalDays = 15;
Date _nextUpdateDate;
AutoUpdateOptions(): _nextUpdateDate(Date()) {};

View File

@ -631,17 +631,19 @@ BEGIN
CONTROL "Peek on document map",IDC_CHECK_ENABLEDOCPEEKONMAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,269,71,140,10
COMBOBOX IDC_COMBO_SYSTRAY_ACTION_CHOICE,37,76,115,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "system tray",IDC_SYSTRAY_STATIC,157,78,88,8
LTEXT "system tray",IDC_SYSTRAY_STATIC,157,77,88,8
COMBOBOX IDC_COMBO_SC_TECHNOLOGY_CHOICE,37,96,115,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "rendering mode",IDC_SC_TECHNOLOGY_STATIC,157,97,88,8
// "Enable Notepad++ auto-updater" should be always the 1st item, because it'll be hidden if GUP.exe is absent
CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,118,210,10
CONTROL "Mute all sounds",IDC_CHECK_MUTE_SOUNDS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,133,190,10
CONTROL "Autodetect character encoding",IDC_CHECK_DETECTENCODING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,148,217,10
CONTROL "Show only filename in title bar",IDC_CHECK_SHORTTITLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,163,217,10
CONTROL "Enable Save All confirm dialog",IDC_CHECK_SAVEALLCONFIRM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,178,217,10
// "Notepad++ auto-updater" should be always the 1st item, because it'll be hidden if GUP.exe is absent
RTEXT "Auto-updater:",IDC_AUTOUPDATE_STATIC,15,117,84,10
COMBOBOX IDC_COMBO_AUTOUPDATE,104,116,130,10,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Mute all sounds",IDC_CHECK_MUTE_SOUNDS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,136,190,10
CONTROL "Autodetect character encoding",IDC_CHECK_DETECTENCODING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,151,217,10
CONTROL "Show only filename in title bar",IDC_CHECK_SHORTTITLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,166,217,10
CONTROL "Enable Save All confirm dialog",IDC_CHECK_SAVEALLCONFIRM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,181,217,10
RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,270,130,108,8
EDITTEXT IDC_EDIT_SESSIONFILEEXT,380,127,34,12,ES_AUTOHSCROLL

View File

@ -3088,13 +3088,20 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_CHECK_DETECTENCODING, BM_SETCHECK, nppGUI._detectEncoding, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SAVEALLCONFIRM, BM_SETCHECK, nppGUI._saveAllConfirm, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0);
::SendDlgItemMessage(_hSelf, IDC_COMBO_AUTOUPDATE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Disable"));
::SendDlgItemMessage(_hSelf, IDC_COMBO_AUTOUPDATE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Enable on Notepad++ startup"));
::SendDlgItemMessage(_hSelf, IDC_COMBO_AUTOUPDATE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Enable on Notepad++ exit"));
if ((nppGUI._autoUpdateOpt._doAutoUpdate < NppGUI::autoupdate_disabled) || (nppGUI._autoUpdateOpt._doAutoUpdate > NppGUI::autoupdate_on_exit))
nppGUI._autoUpdateOpt._doAutoUpdate = NppGUI::autoupdate_on_startup;
::SendDlgItemMessage(_hSelf, IDC_COMBO_AUTOUPDATE, CB_SETCURSEL, nppGUI._autoUpdateOpt._doAutoUpdate, 0);
::ShowWindow(::GetDlgItem(_hSelf, IDC_AUTOUPDATE_STATIC), nppGUI._doesExistUpdater ? SW_SHOW : SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_COMBO_AUTOUPDATE), nppGUI._doesExistUpdater ? SW_SHOW : SW_HIDE);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKER, BM_SETCHECK, nppGUI._isDocPeekOnTab ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKONMAP, BM_SETCHECK, nppGUI._isDocPeekOnMap ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_MUTE_SOUNDS, BM_SETCHECK, nppGUI._muteSounds ? BST_CHECKED : BST_UNCHECKED, 0);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_AUTOUPDATE), nppGUI._doesExistUpdater?SW_SHOW:SW_HIDE);
::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(nppGUI._definedSessionExt.c_str()));
::SendDlgItemMessage(_hSelf, IDC_EDIT_WORKSPACEFILEEXT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(nppGUI._definedWorkspaceExt.c_str()));
@ -3182,13 +3189,10 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
}
return TRUE;
case IDC_CHECK_AUTOUPDATE:
nppGUI._autoUpdateOpt._doAutoUpdate = isCheckedOrNot(static_cast<int32_t>(wParam));
return TRUE;
case IDC_CHECK_DETECTENCODING:
nppGUI._detectEncoding = isCheckedOrNot(static_cast<int32_t>(wParam));
return TRUE;
case IDC_CHECK_ENABLEDOCSWITCHER :
{
nppGUI._doTaskList = !nppGUI._doTaskList;
@ -3295,6 +3299,12 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
nppGUI._writeTechnologyEngine = static_cast<writeTechnologyEngine>(::SendDlgItemMessage(_hSelf,
IDC_COMBO_SC_TECHNOLOGY_CHOICE, CB_GETCURSEL, 0, 0));
}
else if (LOWORD(wParam) == IDC_COMBO_AUTOUPDATE)
{
nppGUI._autoUpdateOpt._doAutoUpdate = static_cast<NppGUI::AutoUpdateMode>(::SendDlgItemMessage(_hSelf,
IDC_COMBO_AUTOUPDATE, CB_GETCURSEL, 0, 0));
}
}
}
}

View File

@ -250,7 +250,7 @@
#define IDC_CHECK_CLICKABLELINK_NOUNDERLINE 6320
#define IDC_EDIT_SESSIONFILEEXT 6321
#define IDC_SESSIONFILEEXT_STATIC 6322
#define IDC_CHECK_AUTOUPDATE 6323
//#define IDC_CHECK_AUTOUPDATE 6323
#define IDC_DOCUMENTSWITCHER_STATIC 6324
#define IDC_CHECK_UPDATEGOTOEOF 6325
#define IDC_CHECK_ENABLSMARTHILITE 6326
@ -269,7 +269,6 @@
#define IDC_CHECK_SMARTHILITEUSEFINDSETTINGS 6339
#define IDC_CHECK_SMARTHILITEANOTHERRVIEW 6340
#define IDC_DOCUMENTPEEK_STATIC 6344
#define IDC_CHECK_ENABLEDOCPEEKER 6345
#define IDC_CHECK_ENABLEDOCPEEKONMAP 6346
@ -286,6 +285,9 @@
#define IDC_COMBO_SC_TECHNOLOGY_CHOICE 6362
#define IDC_SC_TECHNOLOGY_STATIC 6363
#define IDC_COMBO_AUTOUPDATE 6364
#define IDC_AUTOUPDATE_STATIC 6365
#define IDD_PREFERENCE_SUB_NEWDOCUMENT 6400
#define IDC_FORMAT_GB_STATIC 6401
#define IDC_RADIO_F_WIN 6402

View File

@ -375,6 +375,39 @@ void stripIgnoredParams(ParamVector & params)
}
}
bool launchUpdater(const std::wstring& updaterFullPath, const std::wstring& updaterDir)
{
NppParameters& nppParameters = NppParameters::getInstance();
NppGUI& nppGui = nppParameters.getNppGUI();
// check if update interval elapsed
Date today(0);
if (today < nppGui._autoUpdateOpt._nextUpdateDate)
return false;
std::wstring updaterParams = L"-v";
updaterParams += VERSION_INTERNAL_VALUE;
if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64)
{
updaterParams += L" -px64";
}
else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64)
{
updaterParams += L" -parm64";
}
Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str());
updater.run();
// Update next update date
if (nppGui._autoUpdateOpt._intervalDays < 0) // Make sure interval days value is positive
nppGui._autoUpdateOpt._intervalDays = 0 - nppGui._autoUpdateOpt._intervalDays;
nppGui._autoUpdateOpt._nextUpdateDate = Date(nppGui._autoUpdateOpt._intervalDays);
return true;
}
} // namespace
@ -505,8 +538,9 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
NppDarkMode::initDarkMode();
DPIManagerV2::initDpiAPI();
bool doUpdateNpp = nppGui._autoUpdateOpt._doAutoUpdate;
bool doUpdatePluginList = nppGui._autoUpdateOpt._doAutoUpdate;
bool doUpdateNpp = nppGui._autoUpdateOpt._doAutoUpdate != NppGUI::autoupdate_disabled;
bool updateAtExit = nppGui._autoUpdateOpt._doAutoUpdate == NppGUI::autoupdate_on_exit;
bool doUpdatePluginList = nppGui._autoUpdateOpt._doAutoUpdate != NppGUI::autoupdate_disabled;
if (doFunctionListExport || doPrintAndQuit) // export functionlist feature will serialize functionlist on the disk, then exit Notepad++. So it's important to not launch into existing instance, and keep it silent.
{
@ -622,25 +656,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
std::wstring updaterFullPath = updaterDir + L"gup.exe";
std::wstring updaterParams = L"-v";
updaterParams += VERSION_INTERNAL_VALUE;
bool isUpExist = nppGui._doesExistUpdater = doesFileExist(updaterFullPath.c_str());
if (doUpdateNpp) // check more detail
{
Date today(0);
if (today < nppGui._autoUpdateOpt._nextUpdateDate)
doUpdateNpp = false;
}
if (doUpdatePluginList)
{
// TODO: detect update frequency
// Due to the code signing problem, the Plugin List cannot be updated independently of Notepad++ for now.
}
// wingup doesn't work with the obsolete security layer (API) under xp since downloads are secured with SSL on notepad_plus_plus.org
winVer ver = nppParameters.getWinVersion();
bool isGtXP = ver > WV_XP;
@ -648,66 +665,16 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
SecurityGuard securityGuard;
bool isSignatureOK = securityGuard.checkModule(updaterFullPath, nm_gup);
if (TheFirstOne && isUpExist && isGtXP && isSignatureOK)
if (TheFirstOne && isUpExist && isGtXP && isSignatureOK && doUpdateNpp && !updateAtExit)
{
if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64)
{
updaterParams += L" -px64";
}
else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64)
{
updaterParams += L" -parm64";
}
if (doUpdateNpp)
{
Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str());
updater.run();
// Update next update date
if (nppGui._autoUpdateOpt._intervalDays < 0) // Make sure interval days value is positive
nppGui._autoUpdateOpt._intervalDays = 0 - nppGui._autoUpdateOpt._intervalDays;
nppGui._autoUpdateOpt._nextUpdateDate = Date(nppGui._autoUpdateOpt._intervalDays);
}
// to be removed
doUpdatePluginList = false;
if (doUpdatePluginList)
{
// Update Plugin List
std::wstring upPlParams = L"-v";
upPlParams += notepad_plus_plus.getPluginListVerStr();
if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64)
{
upPlParams += L" -px64";
}
else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64)
{
upPlParams += L" -parm64";
}
upPlParams += L" -upZip";
// override "InfoUrl" in gup.xml
upPlParams += L" https://notepad-plus-plus.org/update/pluginListDownloadUrl.php";
// indicate the pluginList installation location
upPlParams += nppParameters.getPluginConfDir();
Process updater(updaterFullPath.c_str(), upPlParams.c_str(), updaterDir.c_str());
updater.run();
// TODO: Update next update date
// Due to the code signing problem, the Plugin List cannot be updated independently of Notepad++ for now.
}
launchUpdater(updaterFullPath, updaterDir);
}
MSG msg{};
msg.wParam = 0;
Win32Exception::installHandler();
MiniDumper mdump; //for debugging purposes.
bool isException = false;
try
{
notepad_plus_plus.init(hInstance, NULL, quotFileName.c_str(), &cmdLineParams);
@ -732,6 +699,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
}
catch (int i)
{
isException = true;
wchar_t str[50] = L"God Damned Exception:";
wchar_t code[10];
wsprintf(code, L"%d", i);
@ -741,11 +709,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
}
catch (std::runtime_error & ex)
{
isException = true;
::MessageBoxA(Notepad_plus_Window::gNppHWND, ex.what(), "Runtime Exception", MB_OK);
doException(notepad_plus_plus);
}
catch (const Win32Exception & ex)
{
isException = true;
wchar_t message[1024];
wsprintf(message, L"An exception occurred. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n"
L"Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%p", ex.code(), ex.what(), ex.where());
@ -755,14 +725,28 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
}
catch (std::exception & ex)
{
isException = true;
::MessageBoxA(Notepad_plus_Window::gNppHWND, ex.what(), "General Exception", MB_OK);
doException(notepad_plus_plus);
}
catch (...) // this shouldn't ever have to happen
{
isException = true;
::MessageBoxA(Notepad_plus_Window::gNppHWND, "An exception that we did not yet found its name is just caught", "Unknown Exception", MB_OK);
doException(notepad_plus_plus);
}
doUpdateNpp = nppGui._autoUpdateOpt._doAutoUpdate != NppGUI::autoupdate_disabled; // refresh, maybe user activated these opts in Preferences
updateAtExit = nppGui._autoUpdateOpt._doAutoUpdate == NppGUI::autoupdate_on_exit; // refresh
if (!isException && !nppParameters.isEndSessionCritical() && TheFirstOne && isUpExist && isGtXP && isSignatureOK && doUpdateNpp && updateAtExit)
{
if (launchUpdater(updaterFullPath, updaterDir))
{
// for updating the nextUpdateDate in the already saved config.xml
nppParameters.createXmlTreeFromGUIParams();
nppParameters.saveConfig_xml();
}
}
return static_cast<int>(msg.wParam);
}