From 6388d48e0ce5707e822f287203e46a2923f2881f Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Sat, 18 Feb 2017 16:27:04 +0530 Subject: [PATCH] Enhance Load/Save Session Feature 1. If any session ext is set, then give preference to session ext instead of "All Types (* . *). This is applicable for both save/load session methods. 2. Show error message when user tries to load wrong session file (e.g. any text file which is not a valid session file). 3. Correct typo and wrong description in a messagebox. Closes #2921 --- PowerEditor/installer/nativeLang/english.xml | 3 ++- PowerEditor/installer/nativeLang/hindi.xml | 1 + PowerEditor/src/NppIO.cpp | 13 +++++++++++-- .../WinControls/OpenSaveFileDialog/FileDialog.cpp | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 8d641daa2..15a0afa2a 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -916,8 +916,9 @@ - + + diff --git a/PowerEditor/installer/nativeLang/hindi.xml b/PowerEditor/installer/nativeLang/hindi.xml index f607b38d3..045fb7b89 100644 --- a/PowerEditor/installer/nativeLang/hindi.xml +++ b/PowerEditor/installer/nativeLang/hindi.xml @@ -933,6 +933,7 @@ + diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 4cd2cef85..441a88f7d 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1769,7 +1769,6 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) if (fn == NULL) { FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst()); - fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); const TCHAR *ext = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); generic_string sessionExt = TEXT(""); if (*ext != '\0') @@ -1779,6 +1778,7 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) sessionExt += ext; fDlg.setExtFilter(TEXT("Session file"), sessionExt.c_str(), NULL); } + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); sessionFileName = fDlg.doOpenSingleFileDlg(); } else @@ -1810,6 +1810,7 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) args += sessionFileName; args += TEXT("\""); ::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW); + result = true; } else { @@ -1824,6 +1825,14 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) if (!isAllSuccessful) (NppParameters::getInstance())->writeSession(session2Load, sessionFileName); } + if (result == false) + { + _nativeLangSpeaker.messageBox("SessionFileInvalidError", + NULL, + TEXT("Session file is either corrupted or not valid."), + TEXT("Could not Load Session"), + MB_OK); + } } return result; } @@ -1857,7 +1866,6 @@ const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames) FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst()); const TCHAR *ext = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); - fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); generic_string sessionExt = TEXT(""); if (*ext != '\0') { @@ -1866,6 +1874,7 @@ const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames) sessionExt += ext; fDlg.setExtFilter(TEXT("Session file"), sessionExt.c_str(), NULL); } + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); sessionFileName = fDlg.doSaveDlg(); return fileSaveSession(nbFile, fileNames, sessionFileName); diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 7e6ab682a..03cddaf49 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -183,7 +183,7 @@ TCHAR* FileDialog::doOpenSingleFileDlg() } catch(std::exception e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } catch(...) { - ::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK); + ::MessageBox(NULL, TEXT("doOpenSingleFileDlg crashes!!!"), TEXT(""), MB_OK); } ::SetCurrentDirectory(dir);