From 4ab4945f0a3b3b7a61172c841d65c5310809af0e Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 17 May 2014 15:35:09 +0000 Subject: [PATCH] [BUG_FIXED] Fix SaveAll command hanging issue while session snapshot is enabled. [CHANGE_BEHAVIOUR] Disable session snapshot while command line -nosession is used. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1240 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/Notepad_plus.h | 2 -- PowerEditor/src/Notepad_plus_Window.cpp | 5 +++-- PowerEditor/src/NppBigSwitch.cpp | 9 ++++++--- PowerEditor/src/NppNotification.cpp | 10 ---------- PowerEditor/src/Parameters.h | 7 ++++--- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index ef88827f..074631d1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -128,7 +128,7 @@ Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(N _linkTriggered(true), _isHotspotDblClicked(false), _isFolding(false), _sysMenuEntering(false), _autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg), - _isFileOpening(false), _rememberThisSession(true), _pAnsiCharPanel(NULL), _pClipboardHistoryPanel(NULL) + _isFileOpening(false), _pAnsiCharPanel(NULL), _pClipboardHistoryPanel(NULL) { ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange)); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index cc443320..75a120dd 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -422,8 +422,6 @@ private: vector > _hideLinesMarks; StyleArray _hotspotStyles; - bool _rememberThisSession; // always true. except -nosession is indicated on the launch time - AnsiCharPanel *_pAnsiCharPanel; ClipboardHistoryPanel *_pClipboardHistoryPanel; diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index 7de788f0..a9f4a306 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -63,7 +63,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); NppParameters *pNppParams = NppParameters::getInstance(); - const NppGUI & nppGUI = pNppParams->getNppGUI(); + NppGUI & nppGUI = (NppGUI &)pNppParams->getNppGUI(); if (cmdLineParams->_isNoPlugin) _notepad_plus_plus_core._pluginsManager.disable(); @@ -131,7 +131,8 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin { ::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0); } - _notepad_plus_plus_core._rememberThisSession = !cmdLineParams->_isNoSession; + + nppGUI._isCmdlineNosessionActivated = cmdLineParams->_isNoSession; if (nppGUI._rememberLastSession && !cmdLineParams->_isNoSession) { _notepad_plus_plus_core.loadLastSession(); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index a264e042..ee3ef463 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -474,7 +474,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; pNppParam->setCmdlineParam(*cmdLineParam); - _rememberThisSession = !cmdLineParam->_isNoSession; + NppGUI nppGui = (NppGUI)pNppParam->getNppGUI(); + nppGui._isCmdlineNosessionActivated = cmdLineParam->_isNoSession; break; } @@ -530,7 +531,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_SAVECURRENTSESSION: { NppParameters *nppParam = NppParameters::getInstance(); - if (nppParam->getNppGUI()._rememberLastSession && _rememberThisSession) + const NppGUI nppGui = nppParam->getNppGUI(); + + if (nppGui._rememberLastSession && !nppGui._isCmdlineNosessionActivated) { Session currentSession; getCurrentOpenedFiles(currentSession, true); @@ -1472,7 +1475,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa saveUserDefineLangs(); saveShortcuts(); - if (nppgui._rememberLastSession && _rememberThisSession) + if (nppgui._rememberLastSession && !nppgui._isCmdlineNosessionActivated) saveSession(currentSession); //Sends WM_DESTROY, Notepad++ will end diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index a4381a02..49664e9e 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -109,16 +109,6 @@ BOOL Notepad_plus::notify(SCNotification *notification) } bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT; buf->setDirty(isDirty); - - if (notification->nmhdr.code == SCN_SAVEPOINTREACHED) - { - bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); - if (isSnapshotMode) - { - MainFileManager->backupCurrentBuffer(); - } - } - break; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e3386067..0b39d677 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -709,7 +709,7 @@ struct NppGUI _tabStatus(TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP), _splitterPos(POS_HORIZOTAL),\ _userDefineDlgStatus(UDD_DOCKED), _tabSize(8), _tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _fileAutoDetectionOriginalValue(_fileAutoDetection),\ _checkHistoryFiles(true) ,_enableSmartHilite(true), _disableSmartHiliteTmp(false), _enableTagsMatchHilite(true), _enableTagAttrsHilite(true), _enableHiliteNonHTMLZone(false),\ - _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _detectEncoding(true), _backup(bak_none), _useDir(false), _backupDir(TEXT("")),\ + _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _isCmdlineNosessionActivated(false), _detectEncoding(true), _backup(bak_none), _useDir(false), _backupDir(TEXT("")),\ _doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\ _autocStatus(autoc_both), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")),\ _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _enableMultiSelection(false), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false),\ @@ -752,7 +752,8 @@ struct NppGUI bool _isMaximized; bool _isMinimizedToTray; - bool _rememberLastSession; + bool _rememberLastSession; // remember next session boolean will be written in the settings + bool _isCmdlineNosessionActivated; // used for if -nosession is indicated on the launch time bool _detectEncoding; bool _doTaskList; bool _maitainIndent; @@ -815,7 +816,7 @@ struct NppGUI generic_string _themeName; MultiInstSetting _multiInstSetting; bool _fileSwitcherWithoutExtColumn; - bool isSnapshotMode() const {return _isSnapshotMode && _rememberLastSession;}; + bool isSnapshotMode() const {return _isSnapshotMode && _rememberLastSession && !_isCmdlineNosessionActivated;}; bool _isSnapshotMode; size_t _snapshotBackupTiming; };