From 9a6e4fceba4358906507786e595356e8588ef0eb Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 21 Nov 2010 01:44:40 +0000 Subject: [PATCH] [BUG_FIXED] Fix x64 system files problems : 1. not included in recent file history list while closing a file. 2. not remembered in the next session problem. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@712 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 53 ++++++++++----- PowerEditor/src/NppIO.cpp | 68 +++++++++++++++++-- .../src/ScitillaComponent/FindReplaceDlg.cpp | 1 - 3 files changed, 98 insertions(+), 24 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index e5ad01eef..9ee3ecc5f 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3814,25 +3814,46 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session) { BufferID bufID = _mainDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(bufID); - if (!buf->isUntitled() && PathFileExists(buf->getFullPathName())) + + if (!buf->isUntitled()) { - generic_string languageName = getLangFromMenu(buf); - const TCHAR *langName = languageName.c_str(); - - sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(&_mainEditView)); - - //_mainEditView.activateBuffer(buf->getID()); - _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument()); - int maxLine = _invisibleEditView.execute(SCI_GETLINECOUNT); - - for (int j = 0 ; j < maxLine ; j++) + // if the file doesn't exist, it could be redirected + // So we turn Wow64 off + bool isWow64Off = false; + NppParameters *pNppParam = NppParameters::getInstance(); + if (!PathFileExists(buf->getFullPathName())) { - if ((_invisibleEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0) - { - sfi.marks.push_back(j); - } + pNppParam->safeWow64EnableWow64FsRedirection(FALSE); + isWow64Off = true; + } + + if (PathFileExists(buf->getFullPathName())) + { + generic_string languageName = getLangFromMenu(buf); + const TCHAR *langName = languageName.c_str(); + + sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(&_mainEditView)); + + //_mainEditView.activateBuffer(buf->getID()); + _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument()); + int maxLine = _invisibleEditView.execute(SCI_GETLINECOUNT); + + for (int j = 0 ; j < maxLine ; j++) + { + if ((_invisibleEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0) + { + sfi.marks.push_back(j); + } + } + session._mainViewFiles.push_back(sfi); + } + + // We enable Wow64 system, if it was disabled + if (isWow64Off) + { + pNppParam->safeWow64EnableWow64FsRedirection(TRUE); + isWow64Off = false; } - session._mainViewFiles.push_back(sfi); } } diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index f34af9339..24e6dca38 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -278,11 +278,31 @@ void Notepad_plus::doClose(BufferID id, int whichOne) { _pluginsManager.notify(&scnN); //add to recent files if its an existing file - if (!buf->isUntitled() && PathFileExists(buf->getFullPathName())) + if (!buf->isUntitled()) { - _lastRecentFileList.add(buf->getFullPathName()); + // if the file doesn't exist, it could be redirected + // So we turn Wow64 off + bool isWow64Off = false; + NppParameters *pNppParam = NppParameters::getInstance(); + if (!PathFileExists(buf->getFullPathName())) + { + pNppParam->safeWow64EnableWow64FsRedirection(FALSE); + isWow64Off = true; + } + + if (PathFileExists(buf->getFullPathName())) + _lastRecentFileList.add(buf->getFullPathName()); + + // We enable Wow64 system, if it was disabled + if (isWow64Off) + { + pNppParam->safeWow64EnableWow64FsRedirection(TRUE); + isWow64Off = false; + } } + + int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem()); //Do all the works @@ -873,6 +893,7 @@ bool Notepad_plus::isFileSession(const TCHAR * filename) { // return false if one or more sessions files fail to load (and session is modify to remove invalid files) bool Notepad_plus::loadSession(Session & session) { + NppParameters *pNppParam = NppParameters::getInstance(); bool allSessionFilesLoaded = true; BufferID lastOpened = BUFFER_INVALID; size_t i = 0; @@ -881,16 +902,33 @@ bool Notepad_plus::loadSession(Session & session) for ( ; i < session.nbMainFiles() ; ) { const TCHAR *pFn = session._mainViewFiles[i]._fileName.c_str(); - if (isFileSession(pFn)) { + if (isFileSession(pFn)) + { vector::iterator posIt = session._mainViewFiles.begin() + i; session._mainViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions } - if (PathFileExists(pFn)) { + + bool isWow64Off = false; + if (!PathFileExists(pFn)) + { + pNppParam->safeWow64EnableWow64FsRedirection(FALSE); + isWow64Off = true; + } + if (PathFileExists(pFn)) + { lastOpened = doOpen(pFn, false, session._mainViewFiles[i]._encoding); - } else { + } + else + { lastOpened = BUFFER_INVALID; } + if (isWow64Off) + { + pNppParam->safeWow64EnableWow64FsRedirection(TRUE); + isWow64Off = false; + } + if (lastOpened != BUFFER_INVALID) { showView(MAIN_VIEW); @@ -938,15 +976,31 @@ bool Notepad_plus::loadSession(Session & session) session._subViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions } - if (PathFileExists(pFn)) { + + bool isWow64Off = false; + if (!PathFileExists(pFn)) + { + pNppParam->safeWow64EnableWow64FsRedirection(FALSE); + isWow64Off = true; + } + if (PathFileExists(pFn)) + { lastOpened = doOpen(pFn, false, session._subViewFiles[k]._encoding); //check if already open in main. If so, clone if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) { loadBufferIntoView(lastOpened, SUB_VIEW); } - } else { + } + else + { lastOpened = BUFFER_INVALID; } + if (isWow64Off) + { + pNppParam->safeWow64EnableWow64FsRedirection(TRUE); + isWow64Off = false; + } + if (lastOpened != BUFFER_INVALID) { showView(SUB_VIEW); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index c44976949..ada36ea35 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -2103,7 +2103,6 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow) enableReplaceFunc(whichType == REPLACE_DLG); ::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT)); - //display(); display(toShow); }