diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index fa99039ea..e35c41e13 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2848,8 +2848,10 @@ void Notepad_plus::command(int id) switch (id) { case IDM_FILE_NEW: + { fileNew(); - break; + } + break; case IDM_FILE_OPEN: fileOpen(); @@ -8789,30 +8791,17 @@ bool Notepad_plus::str2Cliboard(const TCHAR *str2cpy) //ONLY CALL IN CASE OF EMERGENCY: EXCEPTION //This function is destructive -bool Notepad_plus::emergency() { - const TCHAR * outdir = TEXT("C:\\N++RECOV"); +bool Notepad_plus::emergency(generic_string emergencySavedDir) +{ bool filestatus = false; bool dumpstatus = false; do { - if (::CreateDirectory(outdir, NULL) == FALSE && ::GetLastError() != ERROR_ALREADY_EXISTS) { + if (::CreateDirectory(emergencySavedDir.c_str(), NULL) == FALSE && ::GetLastError() != ERROR_ALREADY_EXISTS) { break; } - filestatus = dumpFiles(outdir, TEXT("File")); -/* - HANDLE hProcess = ::GetCurrentProcess(); - DWORD processId = ::GetCurrentProcessId(); + filestatus = dumpFiles(emergencySavedDir.c_str(), TEXT("File")); - TCHAR dumpFile[MAX_PATH]; - _snprintf(dumpFile, MAX_PATH, TEXT("%s\\NPP_DUMP.dmp"), outdir); - HANDLE hFile = ::CreateFile(dumpFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (hFile == INVALID_HANDLE_VALUE) { - ::MessageBox(NULL, TEXT("Failed to write dump file!"), dumpFile, MB_OK|MB_ICONWARNING); - } - - BOOL ret = ::MiniDumpWriteDump(hProcess, processId, hFile, MiniDumpNormal, NULL, NULL, NULL); //might want to add exception info aswell - dumpstatus = (ret == TRUE); -*/ } while (false); bool status = filestatus;// && dumpstatus; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 9cf4122fb..c627b9669 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -94,8 +94,8 @@ struct PostItConf { bool isToolbarShown; bool isTabbarShown; bool isStatusbarShown; - PostItConf() : isPostIt(true), isSizable(false), isAlwaysOnTop(true),\ - isMenuShown(false), isToolbarShown(false), isTabbarShown(false), isStatusbarShown(false){}; + PostItConf() : isPostIt(false), isSizable(true), isAlwaysOnTop(false),\ + isMenuShown(true), isToolbarShown(true), isTabbarShown(true), isStatusbarShown(true){}; }; class FileDialog; @@ -200,7 +200,8 @@ public: bool loadSession(Session & session); winVer getWinVersion() const {return _winVersion;}; - bool emergency(); + bool emergency(generic_string emergencySavedDir); + void notifyBufferChanged(Buffer * buffer, int mask); bool findInFiles(); diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index f7b0bcc41..07cb843ed 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -321,9 +321,17 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh void doException(Notepad_plus & notepad_plus_plus) { Win32Exception::removeHandler(); //disable exception handler after excpetion, we dont want corrupt data structurs to crash the exception handler printMsg(TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION); - bool res = notepad_plus_plus.emergency(); + + TCHAR tmpDir[1024]; + GetTempPath(1024, tmpDir); + generic_string emergencySavedDir = tmpDir; + emergencySavedDir += TEXT("\\N++RECOV"); + + bool res = notepad_plus_plus.emergency(emergencySavedDir); if (res) { - printMsg(TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at N++RECOV directory, located in your system temporary directory."), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION); + generic_string displayText = TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at :\r\n"); + displayText += emergencySavedDir; + printMsg(displayText.c_str(), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION); } else { printMsg(TEXT("Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data."), TEXT("Recovery failure"), MB_OK | MB_ICONERROR); }