From 4e00903dccfdacf1dce6fbd9d75879dd245299e4 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 17:15:41 +0100 Subject: [PATCH 01/15] Back out from 5bb3dad --HG-- branch : feature-crashreport --- code/nel/include/nel/misc/report.h | 17 ++- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/displayer.cpp | 174 ++++++++++++++++++++++++++++- code/nel/src/misc/report.cpp | 19 +++- 4 files changed, 205 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/misc/report.h b/code/nel/include/nel/misc/report.h index 6bf3df959..11745b6e3 100644 --- a/code/nel/include/nel/misc/report.h +++ b/code/nel/include/nel/misc/report.h @@ -21,8 +21,21 @@ namespace NLMISC { -/// Prepares the error report, writes it to disk and launches the error reporter -void report ( const std::string &body ); +/** Display a custom message box. + * + * \param title set the title of the report. If empty, it'll display "NeL report". + * \param header message displayed before the edit text box. If empty, it displays the default message. + * \param body message displayed in the edit text box. This string will be sent by email. + * \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior + * + * + * + * \return the button clicked or error + */ + +enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; + +TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const std::string &attachedFile = ""); /** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail); */ diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 67c8cb0f3..aaa551f1f 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -553,7 +553,7 @@ public: // yoyo: allow only to send the crash report once. Because users usually click ignore, // which create noise into list of bugs (once a player crash, it will surely continues to do it). bool i = false; - report ( _Reason ); + report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE); // no more sent mail for crash setCrashAlreadyReported(true); diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 8296d1c0b..35ae27964 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,7 +529,114 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { - + + bool needSpace = false; +// stringstream ss; + string str; + + // create the string for the clipboard + + if (args.Date != 0) + { + str += dateToHumanString(args.Date); + needSpace = true; + } + + if (args.LogType != CLog::LOG_NO) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += logTypeToString(args.LogType); + needSpace = true; + } + + if (!args.ProcessName.empty()) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += args.ProcessName; + needSpace = true; + } + + if (args.FileName != NULL) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += CFile::getFilename(args.FileName); + needSpace = true; + } + + if (args.Line != -1) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString(args.Line); + needSpace = true; + } + + if (args.FuncName != NULL) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += args.FuncName; + needSpace = true; + } + + if (needSpace) { str += ": "; needSpace = false; } + + str += message; + + CSystemUtils::copyTextToClipboard(str); + + // create the string on the screen + needSpace = false; +// stringstream ss2; + string str2; + +#ifdef NL_DEBUG + if (!args.ProcessName.empty()) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += args.ProcessName; + needSpace = true; + } + + if (args.FileName != NULL) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += CFile::getFilename(args.FileName); + needSpace = true; + } + + if (args.Line != -1) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += NLMISC::toString(args.Line); + needSpace = true; + } + + if (args.FuncName != NULL) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += args.FuncName; + needSpace = true; + } + + if (needSpace) { str2 += ": "; needSpace = false; } + +#endif // NL_DEBUG + + str2 += message; + str2 += "\n\n(this message was copied in the clipboard)"; + +/* if (IsDebuggerPresent ()) + { + // Must break in assert call + DebugNeedAssert = true; + } + else +*/ { + // Display the report string body; @@ -549,8 +656,69 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m body += "Reason: " + toString(message); body += args.CallstackAndLog; - - report( body ); + + string subject; + + // procname is host/service_name-sid we only want the service_name to avoid redondant mail + string procname; + string::size_type pos = args.ProcessName.find ("/"); + if (pos == string::npos) + { + procname = args.ProcessName; + } + else + { + string::size_type pos2 = args.ProcessName.find ("-", pos+1); + if (pos2 == string::npos) + { + procname = args.ProcessName.substr (pos+1); + } + else + { + procname = args.ProcessName.substr (pos+1, pos2-pos-1); + } + } + + subject += procname + " NeL " + toString(LogTypeToString[0][args.LogType]) + " " + (args.FileName?string(args.FileName):"") + " " + toString(args.Line) + " " + (args.FuncName?string(args.FuncName):""); + + // Check the envvar NEL_IGNORE_ASSERT + if (getenv ("NEL_IGNORE_ASSERT") == NULL) + { + // yoyo: allow only to send the crash report once. Because users usually click ignore, + // which create noise into list of bugs (once a player crash, it will surely continues to do it). + std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE; + + if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str())) + { + INelContext::getInstance().setDebugNeedAssert(true); + } + + // no more sent mail for crash + setCrashAlreadyReported(true); + } + +/* // Check the envvar NEL_IGNORE_ASSERT + if (getenv ("NEL_IGNORE_ASSERT") == NULL) + { + // Ask the user to continue, debug or ignore + int result = MessageBox (NULL, ss2.str().c_str (), logTypeToString(args.LogType, true), MB_ABORTRETRYIGNORE | MB_ICONSTOP); + if (result == IDABORT) + { + // Exit the program now + exit (EXIT_FAILURE); + } + else if (result == IDRETRY) + { + // Give the debugger a try + DebugNeedAssert = true; + } + else if (result == IDIGNORE) + { + // Continue, do nothing + } + } +*/ } + } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 54c456ade..b165e29f5 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -22,8 +22,23 @@ #include "nel/misc/report.h" #include "nel/misc/path.h" +#ifdef NL_OS_WINDOWS +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif +# include +# include +# include +#endif // NL_OS_WINDOWS + +#define NL_NO_DEBUG_FILES 1 + using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { @@ -37,7 +52,7 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } -void report ( const std::string &body ) +TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) { std::string fname = "rcerrorlog.txt"; @@ -63,6 +78,8 @@ void report ( const std::string &body ) #endif // quit without calling atexit or static object dtors. abort(); + + return ReportQuit; } From 7efbee6d0a67030281c823a91f5c0c6ba5c40cdd Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 17:20:24 +0100 Subject: [PATCH 02/15] Backed out from 5942903 --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 8 +++++++- code/nel/src/misc/displayer.cpp | 2 ++ code/nel/src/misc/report.cpp | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index aaa551f1f..2d09f5ef8 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -1193,7 +1193,13 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) INelContext::getInstance().setAssertLog(new CLog (CLog::LOG_ASSERT)); sd = new CStdDisplayer ("DEFAULT_SD"); - DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); + +#ifdef NL_OS_WINDOWS + if (TrapCrashInDebugger || !IsDebuggerPresent ()) + { + DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); + } +#endif #if LOG_IN_FILE if (logInFile) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 35ae27964..d48c44d02 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,6 +529,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { +#ifdef NL_OS_WINDOWS bool needSpace = false; // stringstream ss; @@ -719,6 +720,7 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m } */ } +#endif } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index b165e29f5..88c707aaa 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -52,6 +52,16 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } +#ifndef NL_OS_WINDOWS + +// GNU/Linux, do nothing + +void report () +{ +} + +#else + TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) { std::string fname = "rcerrorlog.txt"; @@ -82,5 +92,7 @@ TReportResult report (const std::string &title, const std::string &header, const return ReportQuit; } +#endif + } // NLMISC From 3d9357637b6d48d806ab5f0d76a33325d0b96770 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 17:38:06 +0100 Subject: [PATCH 03/15] Backed out from fdc0d40 --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/report.cpp | 291 +++++++++++++++++++++++++++++++++-- 2 files changed, 278 insertions(+), 15 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 2d09f5ef8..c7667acc2 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -83,7 +83,7 @@ using namespace std; #define LOG_IN_FILE NEL_LOG_IN_FILE // If true, debug system will trap crash even if the application is in debugger -static const bool TrapCrashInDebugger = true; +static const bool TrapCrashInDebugger = false; #ifdef DEBUG_NEW #define new DEBUG_NEW diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 88c707aaa..20b2b1c11 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -42,14 +42,25 @@ using namespace std; namespace NLMISC { +#ifdef NL_OS_WINDOWS +static HWND sendReport=NULL; +#endif + //old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false); typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck); +#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; } + static TEmailFunction EmailFunction = NULL; void setReportEmailFunction (void *emailFunction) { EmailFunction = (TEmailFunction)emailFunction; + +#ifdef NL_OS_WINDOWS + if (sendReport) + EnableWindow(sendReport, FALSE); +#endif } #ifndef NL_OS_WINDOWS @@ -62,24 +73,91 @@ void report () #else -TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) +// Windows specific version + +static string Body; +static string Subject; +static string AttachedFile; + +static HWND checkIgnore=NULL; +static HWND debug=NULL; +static HWND ignore=NULL; +static HWND quit=NULL; +static HWND dialog=NULL; + +static bool NeedExit; +static TReportResult Result; +static bool IgnoreNextTime; +static bool CanSendMailReport= false; + +static bool DebugDefaultBehavior, QuitDefaultBehavior; + +static void sendEmail() { - std::string fname = "rcerrorlog.txt"; - - std::ofstream f; - f.open( fname.c_str() ); - if( f.good() ) + if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) { - f << body; - f.close(); - -#ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "rcerror.exe", fname ); -#else - NLMISC::launchProgram( "rcerror", fname ); + bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); + if (res) + { + // EnableWindow(sendReport, FALSE); + // MessageBox (dialog, "The email was successfully sent", "email", MB_OK); +#ifndef NL_NO_DEBUG_FILES + CFile::createEmptyFile(getLogDirectory() + "report_sent"); +#endif + } + else + { +#ifndef NL_NO_DEBUG_FILES + CFile::createEmptyFile(getLogDirectory() + "report_failed"); +#endif + // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); + } + } + else + { +#ifndef NL_NO_DEBUG_FILES + CFile::createEmptyFile(getLogDirectory() + "report_refused"); #endif } +} +static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //MSGFILTER *pmf; + + if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED) + { + if ((HWND) lParam == checkIgnore) + { + IgnoreNextTime = !IgnoreNextTime; + } + else if ((HWND) lParam == debug) + { + sendEmail(); + NeedExit = true; + Result = ReportDebug; + if (DebugDefaultBehavior) + { + NLMISC_BREAKPOINT; + } + } + else if ((HWND) lParam == ignore) + { + sendEmail(); + NeedExit = true; + Result = ReportIgnore; + } + else if ((HWND) lParam == quit) + { + sendEmail(); + NeedExit = true; + Result = ReportQuit; + + if (QuitDefaultBehavior) + { + // ace: we cannot call exit() because it's call the static object dtor and can crash the application + // if the dtor call order is not good. + //exit(EXIT_SUCCESS); #ifdef NL_OS_WINDOWS #ifndef NL_COMP_MINGW // disable the Windows popup telling that the application aborted and disable the dr watson report. @@ -88,8 +166,193 @@ TReportResult report (const std::string &title, const std::string &header, const #endif // quit without calling atexit or static object dtors. abort(); + } + } + /*else if ((HWND) lParam == sendReport) + { + if (EmailFunction != NULL) + { + bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); + if (res) + { + EnableWindow(sendReport, FALSE); + MessageBox (dialog, "The email was successfully sent", "email", MB_OK); + CFile::createEmptyFile(getLogDirectory() + "report_sent"); + } + else + { + MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); + } + } + }*/ + } + else if (message == WM_CHAR) + { + if (wParam == 27) + { + // ESC -> ignore + sendEmail(); + NeedExit = true; + Result = ReportIgnore; + } + } - return ReportQuit; + return DefWindowProc (hWnd, message, wParam, lParam); +} + +TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) +{ + // register the window + static bool AlreadyRegister = false; + if(!AlreadyRegister) + { + WNDCLASSW wc; + memset (&wc,0,sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = (WNDPROC)WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = GetModuleHandle(NULL); + wc.hIcon = NULL; + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground = (HBRUSH)COLOR_WINDOW; + wc.lpszClassName = L"NLReportWindow"; + wc.lpszMenuName = NULL; + if (!RegisterClassW(&wc)) return ReportError; + AlreadyRegister = true; + } + + ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title); + + + // create the window + dialog = CreateWindowW (L"NLReportWindow", (LPCWSTR)formatedTitle.c_str(), WS_DLGFRAME | WS_CAPTION /*| WS_THICKFRAME*/, CW_USEDEFAULT, CW_USEDEFAULT, 456, 400, NULL, NULL, GetModuleHandle(NULL), NULL); + + // create the font + HFONT font = CreateFont (-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + + Subject = subject; + AttachedFile = attachedFile; + + // create the edit control + HWND edit = CreateWindowW (L"EDIT", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_LEFT | ES_MULTILINE, 7, 70, 429, 212, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (edit, WM_SETFONT, (WPARAM) font, TRUE); + + // set the edit text limit to lot of :) + SendMessage (edit, EM_LIMITTEXT, ~0U, 0); + + Body = addSlashR (body); + + // set the message in the edit text + SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.c_str()); + + if (enableCheckIgnore) + { + // create the combo box control + checkIgnore = CreateWindowW (L"BUTTON", L"Don't display this report again", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKBOX, 7, 290, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (checkIgnore, WM_SETFONT, (WPARAM) font, TRUE); + + if(ignoreNextTime) + { + SendMessage (checkIgnore, BM_SETCHECK, BST_CHECKED, 0); + } + } + + // create the debug button control + debug = CreateWindowW (L"BUTTON", L"Debug", WS_CHILD | WS_VISIBLE, 7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (debug, WM_SETFONT, (WPARAM) font, TRUE); + + if (debugButton == 0) + EnableWindow(debug, FALSE); + + // create the ignore button control + ignore = CreateWindowW (L"BUTTON", L"Ignore", WS_CHILD | WS_VISIBLE, 75+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (ignore, WM_SETFONT, (WPARAM) font, TRUE); + + if (ignoreButton == 0) + EnableWindow(ignore, FALSE); + + // create the quit button control + quit = CreateWindowW (L"BUTTON", L"Quit", WS_CHILD | WS_VISIBLE, 75+75+7+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (quit, WM_SETFONT, (WPARAM) font, TRUE); + + if (quitButton == 0) + EnableWindow(quit, FALSE); + + // create the debug button control + sendReport = CreateWindowW (L"BUTTON", L"Don't send the report", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 7, 315+32, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (sendReport, WM_SETFONT, (WPARAM) font, TRUE); + + string formatedHeader; + if (header.empty()) + { + formatedHeader = "This application stopped to display this report."; + } + else + { + formatedHeader = header; + } + + // ace don't do that because it s slow to try to send a mail + //CanSendMailReport = sendReportButton && EmailFunction != NULL && EmailFunction("", "", "", "", "", true); + CanSendMailReport = sendReportButton && EmailFunction != NULL; + + if (CanSendMailReport) + formatedHeader += " Send report will only email the contents of the box below. Please, send it to help us (it could take few minutes to send the email, be patient)."; + else + EnableWindow(sendReport, FALSE); + + ucstring uc = ucstring::makeFromUtf8(formatedHeader); + + // create the label control + HWND label = CreateWindowW (L"STATIC", (LPCWSTR)uc.c_str(), WS_CHILD | WS_VISIBLE /*| SS_WHITERECT*/, 7, 7, 429, 51, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); + SendMessage (label, WM_SETFONT, (WPARAM) font, TRUE); + + + DebugDefaultBehavior = debugButton==1; + QuitDefaultBehavior = quitButton==1; + + IgnoreNextTime = ignoreNextTime; + + // show until the cursor really show :) + while (ShowCursor(TRUE) < 0) + ; + + SetWindowPos (dialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + + SetFocus(dialog); + SetForegroundWindow(dialog); + + NeedExit = false; + + while(!NeedExit) + { + MSG msg; + while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + nlSleep (1); + } + + // set the user result + ignoreNextTime = IgnoreNextTime; + + ShowWindow(dialog, SW_HIDE); + + + + DELETE_OBJECT(sendReport) + DELETE_OBJECT(quit) + DELETE_OBJECT(ignore) + DELETE_OBJECT(debug) + DELETE_OBJECT(checkIgnore) + DELETE_OBJECT(edit) + DELETE_OBJECT(label) + DELETE_OBJECT(dialog) + + return Result; } #endif From 24aa500d0b1c2fccf1e2a547a77bb54c1002092a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 18:45:41 +0100 Subject: [PATCH 04/15] Launch the error report application instead of sending an email. --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 3 ++- code/nel/src/misc/report.cpp | 38 ++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index c7667acc2..3f0c26f69 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -83,7 +83,8 @@ using namespace std; #define LOG_IN_FILE NEL_LOG_IN_FILE // If true, debug system will trap crash even if the application is in debugger -static const bool TrapCrashInDebugger = false; +//static const bool TrapCrashInDebugger = false; +static const bool TrapCrashInDebugger = true; #ifdef DEBUG_NEW #define new DEBUG_NEW diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 20b2b1c11..d761373fd 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -92,6 +92,36 @@ static bool CanSendMailReport= false; static bool DebugDefaultBehavior, QuitDefaultBehavior; +static void doSendReport() +{ + std::string filename; + + // Unfortunately Qt 4.8.5 on Windows messes up arguments. + // As a workaround the report filename is hardcoded for now. + // + //filename = "report_"; + //filename += NLMISC::toString( time( NULL ) ); + //filename += ".txt"; + + filename = "rcerrorlog.txt"; + + std::ofstream f; + f.open( filename.c_str() ); + if( !f.good() ) + return; + + f << Body; + + f.close(); + +#ifdef NL_OS_WINDOWS + NLMISC::launchProgram( "rcerror.exe", filename ); +#else + NLMISC::launchProgram( "rcerror", filename ); +#endif + +} + static void sendEmail() { if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) @@ -133,7 +163,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM } else if ((HWND) lParam == debug) { - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportDebug; if (DebugDefaultBehavior) @@ -143,13 +173,13 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM } else if ((HWND) lParam == ignore) { - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportIgnore; } else if ((HWND) lParam == quit) { - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportQuit; @@ -191,7 +221,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM if (wParam == 27) { // ESC -> ignore - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportIgnore; } From bdb20d32dd37be4e7b513e2be9a52c1a20896cdc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 18:59:35 +0100 Subject: [PATCH 05/15] Copyright header changed to Nel... --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror.cpp | 2 +- code/nel/rcerror/rcerror_socket.cpp | 2 +- code/nel/rcerror/rcerror_socket.h | 2 +- code/nel/rcerror/rcerror_widget.cpp | 2 +- code/nel/rcerror/rcerror_widget.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp index 0d5088167..4f9174f78 100644 --- a/code/nel/rcerror/rcerror.cpp +++ b/code/nel/rcerror/rcerror.cpp @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index 8a011c046..721265d1e 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index a37fa32d0..f64b8a708 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index a28afbca6..86c68504e 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index 1dd51c2af..7393793e9 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core From b5c72182edfb8b26b74efaa2f7bb0474ff2ada0a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:04:11 +0100 Subject: [PATCH 06/15] Class names in Nel start with a C... --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror.cpp | 2 +- code/nel/rcerror/rcerror_data.h | 2 +- code/nel/rcerror/rcerror_socket.cpp | 12 ++++++------ code/nel/rcerror/rcerror_socket.h | 12 ++++++------ code/nel/rcerror/rcerror_widget.cpp | 20 ++++++++++---------- code/nel/rcerror/rcerror_widget.h | 10 +++++----- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp index 4f9174f78..f26886735 100644 --- a/code/nel/rcerror/rcerror.cpp +++ b/code/nel/rcerror/rcerror.cpp @@ -25,7 +25,7 @@ int main( int argc, char **argv ) { QApplication app( argc, argv ); - RCErrorWidget w; + CRCErrorWidget w; w.setFileName( "rcerrorlog.txt" ); w.show(); diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/rcerror/rcerror_data.h index 9f12b12fd..8accc75a3 100644 --- a/code/nel/rcerror/rcerror_data.h +++ b/code/nel/rcerror/rcerror_data.h @@ -23,7 +23,7 @@ #include -struct RCErrorData +struct SRCErrorData { QString description; QString report; diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index 721265d1e..720cb792b 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -27,26 +27,26 @@ namespace static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; } -class RCErrorSocketPvt +class CRCErrorSocketPvt { public: QNetworkAccessManager mgr; }; -RCErrorSocket::RCErrorSocket( QObject *parent ) : +CRCErrorSocket::CRCErrorSocket( QObject *parent ) : QObject( parent ) { - m_pvt = new RCErrorSocketPvt(); + m_pvt = new CRCErrorSocketPvt(); connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) ); } -RCErrorSocket::~RCErrorSocket() +CRCErrorSocket::~CRCErrorSocket() { delete m_pvt; } -void RCErrorSocket::sendReport( const RCErrorData &data ) +void CRCErrorSocket::sendReport( const SRCErrorData &data ) { QUrl params; params.addQueryItem( "report", data.report ); @@ -60,7 +60,7 @@ void RCErrorSocket::sendReport( const RCErrorData &data ) m_pvt->mgr.post( request, params.encodedQuery() ); } -void RCErrorSocket::onFinished( QNetworkReply *reply ) +void CRCErrorSocket::onFinished( QNetworkReply *reply ) { if( reply->error() != QNetworkReply::NoError ) Q_EMIT reportFailed(); diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index f64b8a708..95092a250 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -23,18 +23,18 @@ #include #include "rcerror_data.h" -class RCErrorSocketPvt; +class CRCErrorSocketPvt; class QNetworkReply; -class RCErrorSocket : public QObject +class CRCErrorSocket : public QObject { Q_OBJECT public: - RCErrorSocket( QObject *parent ); - ~RCErrorSocket(); + CRCErrorSocket( QObject *parent ); + ~CRCErrorSocket(); - void sendReport( const RCErrorData &data ); + void sendReport( const SRCErrorData &data ); Q_SIGNALS: void reportSent(); @@ -44,7 +44,7 @@ private Q_SLOTS: void onFinished( QNetworkReply *reply ); private: - RCErrorSocketPvt *m_pvt; + CRCErrorSocketPvt *m_pvt; }; #endif diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index 86c68504e..04d06ff94 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -25,12 +25,12 @@ #include #include -RCErrorWidget::RCErrorWidget( QWidget *parent ) : +CRCErrorWidget::CRCErrorWidget( QWidget *parent ) : QWidget( parent ) { m_ui.setupUi( this ); - m_socket = new RCErrorSocket( this ); + m_socket = new CRCErrorSocket( this ); QTimer::singleShot( 1, this, SLOT( onLoad() ) ); @@ -42,12 +42,12 @@ QWidget( parent ) connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) ); } -RCErrorWidget::~RCErrorWidget() +CRCErrorWidget::~CRCErrorWidget() { m_socket = NULL; } -void RCErrorWidget::onLoad() +void CRCErrorWidget::onLoad() { QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); @@ -64,12 +64,12 @@ void RCErrorWidget::onLoad() f.close(); } -void RCErrorWidget::onSendClicked() +void CRCErrorWidget::onSendClicked() { m_ui.sendButton->setEnabled( false ); QApplication::setOverrideCursor( Qt::WaitCursor ); - RCErrorData data; + SRCErrorData data; data.description = m_ui.descriptionEdit->toPlainText(); data.report = m_ui.reportEdit->toPlainText(); data.email = m_ui.emailEdit->text(); @@ -77,17 +77,17 @@ void RCErrorWidget::onSendClicked() m_socket->sendReport( data ); } -void RCErrorWidget::onCancelClicked() +void CRCErrorWidget::onCancelClicked() { close(); } -void RCErrorWidget::onCBClicked() +void CRCErrorWidget::onCBClicked() { m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } -void RCErrorWidget::onReportSent() +void CRCErrorWidget::onReportSent() { QApplication::setOverrideCursor( Qt::ArrowCursor ); @@ -98,7 +98,7 @@ void RCErrorWidget::onReportSent() close(); } -void RCErrorWidget::onReportFailed() +void CRCErrorWidget::onReportFailed() { QApplication::setOverrideCursor( Qt::ArrowCursor ); diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index 7393793e9..1d016fa52 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -23,14 +23,14 @@ #include "ui_rcerror_widget.h" -class RCErrorSocket; +class CRCErrorSocket; -class RCErrorWidget : public QWidget +class CRCErrorWidget : public QWidget { Q_OBJECT public: - RCErrorWidget( QWidget *parent = NULL ); - ~RCErrorWidget(); + CRCErrorWidget( QWidget *parent = NULL ); + ~CRCErrorWidget(); void setFileName( const char *fn ){ m_fileName = fn; } @@ -46,7 +46,7 @@ private Q_SLOTS: private: Ui::RCErrorWidget m_ui; QString m_fileName; - RCErrorSocket *m_socket; + CRCErrorSocket *m_socket; }; #endif From 4ec87b3d6ddaa2a02e0e884364c92b42cab93066 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:24:38 +0100 Subject: [PATCH 07/15] Moved to nel\tools\misc --HG-- branch : feature-crashreport --- code/nel/CMakeLists.txt | 4 ---- code/nel/tools/misc/CMakeLists.txt | 1 + code/nel/{ => tools/misc}/rcerror/CMakeLists.txt | 0 code/nel/{ => tools/misc}/rcerror/rcerror.cpp | 0 code/nel/{ => tools/misc}/rcerror/rcerror_data.h | 0 code/nel/{ => tools/misc}/rcerror/rcerror_socket.cpp | 0 code/nel/{ => tools/misc}/rcerror/rcerror_socket.h | 0 code/nel/{ => tools/misc}/rcerror/rcerror_widget.cpp | 0 code/nel/{ => tools/misc}/rcerror/rcerror_widget.h | 0 code/nel/{ => tools/misc}/rcerror/rcerror_widget.ui | 0 10 files changed, 1 insertion(+), 4 deletions(-) rename code/nel/{ => tools/misc}/rcerror/CMakeLists.txt (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror.cpp (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_data.h (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_socket.cpp (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_socket.h (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_widget.cpp (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_widget.h (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_widget.ui (100%) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 00290d097..16a8166fe 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -83,7 +83,3 @@ IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) ENDIF(WITH_NEL_TOOLS) ADD_SUBDIRECTORY(tools) ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) - -IF(WITH_QT) - ADD_SUBDIRECTORY(rcerror) -ENDIF(WITH_QT) diff --git a/code/nel/tools/misc/CMakeLists.txt b/code/nel/tools/misc/CMakeLists.txt index 5386cbbc6..1cda7e8e6 100644 --- a/code/nel/tools/misc/CMakeLists.txt +++ b/code/nel/tools/misc/CMakeLists.txt @@ -3,6 +3,7 @@ SUBDIRS(bnp_make disp_sheet_id extract_filename lock make_sheet_id xml_packer) IF(WITH_QT) ADD_SUBDIRECTORY(words_dic_qt) ADD_SUBDIRECTORY(message_box_qt) + ADD_SUBDIRECTORY(rcerror) ENDIF(WITH_QT) IF(WIN32) diff --git a/code/nel/rcerror/CMakeLists.txt b/code/nel/tools/misc/rcerror/CMakeLists.txt similarity index 100% rename from code/nel/rcerror/CMakeLists.txt rename to code/nel/tools/misc/rcerror/CMakeLists.txt diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/tools/misc/rcerror/rcerror.cpp similarity index 100% rename from code/nel/rcerror/rcerror.cpp rename to code/nel/tools/misc/rcerror/rcerror.cpp diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/tools/misc/rcerror/rcerror_data.h similarity index 100% rename from code/nel/rcerror/rcerror_data.h rename to code/nel/tools/misc/rcerror/rcerror_data.h diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/tools/misc/rcerror/rcerror_socket.cpp similarity index 100% rename from code/nel/rcerror/rcerror_socket.cpp rename to code/nel/tools/misc/rcerror/rcerror_socket.cpp diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/tools/misc/rcerror/rcerror_socket.h similarity index 100% rename from code/nel/rcerror/rcerror_socket.h rename to code/nel/tools/misc/rcerror/rcerror_socket.h diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/tools/misc/rcerror/rcerror_widget.cpp similarity index 100% rename from code/nel/rcerror/rcerror_widget.cpp rename to code/nel/tools/misc/rcerror/rcerror_widget.cpp diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/tools/misc/rcerror/rcerror_widget.h similarity index 100% rename from code/nel/rcerror/rcerror_widget.h rename to code/nel/tools/misc/rcerror/rcerror_widget.h diff --git a/code/nel/rcerror/rcerror_widget.ui b/code/nel/tools/misc/rcerror/rcerror_widget.ui similarity index 100% rename from code/nel/rcerror/rcerror_widget.ui rename to code/nel/tools/misc/rcerror/rcerror_widget.ui From 195dfcc3f3061d714c4a9ae7ba0557a33a031072 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:26:03 +0100 Subject: [PATCH 08/15] Changed default title to NeL Error Report. --HG-- branch : feature-crashreport --- code/nel/tools/misc/rcerror/rcerror_widget.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.ui b/code/nel/tools/misc/rcerror/rcerror_widget.ui index 72e5f92f5..b92ac65a6 100644 --- a/code/nel/tools/misc/rcerror/rcerror_widget.ui +++ b/code/nel/tools/misc/rcerror/rcerror_widget.ui @@ -14,7 +14,7 @@ - Ryzom Core error report + NeL Error Report From 97de06bff27a607df229b3eb4131d2573a5cff99 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:28:02 +0100 Subject: [PATCH 09/15] renamed directory. --HG-- branch : feature-crashreport --- code/nel/tools/misc/CMakeLists.txt | 2 +- code/nel/tools/misc/{rcerror => crash_report}/CMakeLists.txt | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror.cpp | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_data.h | 0 .../nel/tools/misc/{rcerror => crash_report}/rcerror_socket.cpp | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_socket.h | 0 .../nel/tools/misc/{rcerror => crash_report}/rcerror_widget.cpp | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.h | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.ui | 0 9 files changed, 1 insertion(+), 1 deletion(-) rename code/nel/tools/misc/{rcerror => crash_report}/CMakeLists.txt (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror.cpp (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_data.h (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_socket.cpp (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_socket.h (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.cpp (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.h (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.ui (100%) diff --git a/code/nel/tools/misc/CMakeLists.txt b/code/nel/tools/misc/CMakeLists.txt index 1cda7e8e6..c9bbcd058 100644 --- a/code/nel/tools/misc/CMakeLists.txt +++ b/code/nel/tools/misc/CMakeLists.txt @@ -3,7 +3,7 @@ SUBDIRS(bnp_make disp_sheet_id extract_filename lock make_sheet_id xml_packer) IF(WITH_QT) ADD_SUBDIRECTORY(words_dic_qt) ADD_SUBDIRECTORY(message_box_qt) - ADD_SUBDIRECTORY(rcerror) + ADD_SUBDIRECTORY(crash_report) ENDIF(WITH_QT) IF(WIN32) diff --git a/code/nel/tools/misc/rcerror/CMakeLists.txt b/code/nel/tools/misc/crash_report/CMakeLists.txt similarity index 100% rename from code/nel/tools/misc/rcerror/CMakeLists.txt rename to code/nel/tools/misc/crash_report/CMakeLists.txt diff --git a/code/nel/tools/misc/rcerror/rcerror.cpp b/code/nel/tools/misc/crash_report/rcerror.cpp similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror.cpp rename to code/nel/tools/misc/crash_report/rcerror.cpp diff --git a/code/nel/tools/misc/rcerror/rcerror_data.h b/code/nel/tools/misc/crash_report/rcerror_data.h similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_data.h rename to code/nel/tools/misc/crash_report/rcerror_data.h diff --git a/code/nel/tools/misc/rcerror/rcerror_socket.cpp b/code/nel/tools/misc/crash_report/rcerror_socket.cpp similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_socket.cpp rename to code/nel/tools/misc/crash_report/rcerror_socket.cpp diff --git a/code/nel/tools/misc/rcerror/rcerror_socket.h b/code/nel/tools/misc/crash_report/rcerror_socket.h similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_socket.h rename to code/nel/tools/misc/crash_report/rcerror_socket.h diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.cpp b/code/nel/tools/misc/crash_report/rcerror_widget.cpp similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_widget.cpp rename to code/nel/tools/misc/crash_report/rcerror_widget.cpp diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.h b/code/nel/tools/misc/crash_report/rcerror_widget.h similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_widget.h rename to code/nel/tools/misc/crash_report/rcerror_widget.h diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.ui b/code/nel/tools/misc/crash_report/rcerror_widget.ui similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_widget.ui rename to code/nel/tools/misc/crash_report/rcerror_widget.ui From 6be70dd39c090d1d80ff80d08695f51cd726fce8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:33:12 +0100 Subject: [PATCH 10/15] Renames. --HG-- branch : feature-crashreport --- .../tools/misc/crash_report/CMakeLists.txt | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/code/nel/tools/misc/crash_report/CMakeLists.txt b/code/nel/tools/misc/crash_report/CMakeLists.txt index 51522cf0c..0e2d2a9bc 100644 --- a/code/nel/tools/misc/crash_report/CMakeLists.txt +++ b/code/nel/tools/misc/crash_report/CMakeLists.txt @@ -1,14 +1,14 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR} ${QT_INCLUDES}) -FILE(GLOB RCERROR_SRC *.cpp) -FILE(GLOB RCERROR_HDR *h) +FILE(GLOB CRASHREPORT_SRC *.cpp) +FILE(GLOB CRASHREPORT_HDR *h) -SET(RCERROR_MOC_HDR -rcerror_socket.h -rcerror_widget.h +SET(CRASHREPORT_MOC_HDR +crash_report_socket.h +crash_report_widget.h ) -SET(RCERROR_UI -rcerror_widget.ui +SET(CRASHREPORT_UI +crash_report_widget.ui ) SET(QT_USE_QTGUI TRUE) @@ -20,20 +20,20 @@ SET(QT_USE_QTXML FALSE) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) -QT4_WRAP_CPP(RCERROR_MOC_SRC ${RCERROR_MOC_HDR}) -QT4_WRAP_UI(RCERROR_UI_HDR ${RCERROR_UI}) +QT4_WRAP_CPP(CRASHREPORT_MOC_SRC ${CRASHREPORT_MOC_HDR}) +QT4_WRAP_UI(CRASHREPORT_UI_HDR ${CRASHREPORT_UI}) -SOURCE_GROUP(QtResources FILES ${RCERROR_UI}) -SOURCE_GROUP(QtGeneratedUiHdr FILES ${RCERROR_UI_HDR}) -SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${RCERROR_MOC_SRC}) -SOURCE_GROUP("source files" FILES ${RCERROR_SRC}) -SOURCE_GROUP("header files" FILES ${RCERROR_HDR}) +SOURCE_GROUP(QtResources FILES ${CRASHREPORT_UI}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${CRASHREPORT_UI_HDR}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${CRASHREPORT_MOC_SRC}) +SOURCE_GROUP("source files" FILES ${CRASHREPORT_SRC}) +SOURCE_GROUP("header files" FILES ${CRASHREPORT_HDR}) -ADD_EXECUTABLE(rcerror WIN32 MACOSX_BUNDLE ${RCERROR_SRC} ${RCERROR_MOC_HDR} ${RCERROR_MOC_SRC} ${RCERROR_UI_HDR}) -TARGET_LINK_LIBRARIES(rcerror ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) +ADD_EXECUTABLE(crash_report WIN32 MACOSX_BUNDLE ${CRASHREPORT_SRC} ${CRASHREPORT_MOC_HDR} ${CRASHREPORT_MOC_SRC} ${CRASHREPORT_UI_HDR}) +TARGET_LINK_LIBRARIES(crash_report ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) -NL_DEFAULT_PROPS(rcerror "Ryzom Core Error Reporter") -NL_ADD_RUNTIME_FLAGS(rcerror) +NL_DEFAULT_PROPS(crash_report "NeL, Tools, Misc: Crash Report") +NL_ADD_RUNTIME_FLAGS(crash_report) -INSTALL(TARGETS rcerror RUNTIME DESTINATION ${NL_BIN_PREFIX}) +INSTALL(TARGETS crash_report RUNTIME DESTINATION ${NL_BIN_PREFIX}) From 39879717926f8bfdc06fefe1f0158bad1cf31165 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:33:38 +0100 Subject: [PATCH 11/15] Renames. --HG-- branch : feature-crashreport --- .../nel/tools/misc/crash_report/{rcerror.cpp => crash_report.cpp} | 0 .../misc/crash_report/{rcerror_data.h => crash_report_data.h} | 0 .../crash_report/{rcerror_socket.cpp => crash_report_socket.cpp} | 0 .../misc/crash_report/{rcerror_socket.h => crash_report_socket.h} | 0 .../crash_report/{rcerror_widget.cpp => crash_report_widget.cpp} | 0 .../misc/crash_report/{rcerror_widget.h => crash_report_widget.h} | 0 .../crash_report/{rcerror_widget.ui => crash_report_widget.ui} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename code/nel/tools/misc/crash_report/{rcerror.cpp => crash_report.cpp} (100%) rename code/nel/tools/misc/crash_report/{rcerror_data.h => crash_report_data.h} (100%) rename code/nel/tools/misc/crash_report/{rcerror_socket.cpp => crash_report_socket.cpp} (100%) rename code/nel/tools/misc/crash_report/{rcerror_socket.h => crash_report_socket.h} (100%) rename code/nel/tools/misc/crash_report/{rcerror_widget.cpp => crash_report_widget.cpp} (100%) rename code/nel/tools/misc/crash_report/{rcerror_widget.h => crash_report_widget.h} (100%) rename code/nel/tools/misc/crash_report/{rcerror_widget.ui => crash_report_widget.ui} (100%) diff --git a/code/nel/tools/misc/crash_report/rcerror.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror.cpp rename to code/nel/tools/misc/crash_report/crash_report.cpp diff --git a/code/nel/tools/misc/crash_report/rcerror_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_data.h rename to code/nel/tools/misc/crash_report/crash_report_data.h diff --git a/code/nel/tools/misc/crash_report/rcerror_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_socket.cpp rename to code/nel/tools/misc/crash_report/crash_report_socket.cpp diff --git a/code/nel/tools/misc/crash_report/rcerror_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_socket.h rename to code/nel/tools/misc/crash_report/crash_report_socket.h diff --git a/code/nel/tools/misc/crash_report/rcerror_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_widget.cpp rename to code/nel/tools/misc/crash_report/crash_report_widget.cpp diff --git a/code/nel/tools/misc/crash_report/rcerror_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_widget.h rename to code/nel/tools/misc/crash_report/crash_report_widget.h diff --git a/code/nel/tools/misc/crash_report/rcerror_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_widget.ui rename to code/nel/tools/misc/crash_report/crash_report_widget.ui From cfe2d603503d7da01e87dc8e14a90942e7544843 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:52:01 +0100 Subject: [PATCH 12/15] More renames... --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 4 +-- .../tools/misc/crash_report/crash_report.cpp | 4 +-- .../misc/crash_report/crash_report_data.h | 2 +- .../misc/crash_report/crash_report_socket.cpp | 14 +++++----- .../misc/crash_report/crash_report_socket.h | 14 +++++----- .../misc/crash_report/crash_report_widget.cpp | 26 +++++++++---------- .../misc/crash_report/crash_report_widget.h | 14 +++++----- .../misc/crash_report/crash_report_widget.ui | 4 +-- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index d761373fd..09cfc1178 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -115,9 +115,9 @@ static void doSendReport() f.close(); #ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "rcerror.exe", filename ); + NLMISC::launchProgram( "crash_report.exe", filename ); #else - NLMISC::launchProgram( "rcerror", filename ); + NLMISC::launchProgram( "crash_report", filename ); #endif } diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index f26886735..d04928d21 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -17,7 +17,7 @@ // along with this program. If not, see . -#include "rcerror_widget.h" +#include "crash_report_widget.h" #include #include @@ -25,7 +25,7 @@ int main( int argc, char **argv ) { QApplication app( argc, argv ); - CRCErrorWidget w; + CCrashReportWidget w; w.setFileName( "rcerrorlog.txt" ); w.show(); diff --git a/code/nel/tools/misc/crash_report/crash_report_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h index 8accc75a3..5884e7eb4 100644 --- a/code/nel/tools/misc/crash_report/crash_report_data.h +++ b/code/nel/tools/misc/crash_report/crash_report_data.h @@ -23,7 +23,7 @@ #include -struct SRCErrorData +struct SCrashReportData { QString description; QString report; diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp index 720cb792b..209ea89e8 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_socket.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "rcerror_socket.h" +#include "crash_report_socket.h" #include #include #include @@ -27,26 +27,26 @@ namespace static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; } -class CRCErrorSocketPvt +class CCrashReportSocketPvt { public: QNetworkAccessManager mgr; }; -CRCErrorSocket::CRCErrorSocket( QObject *parent ) : +CCrashReportSocket::CCrashReportSocket( QObject *parent ) : QObject( parent ) { - m_pvt = new CRCErrorSocketPvt(); + m_pvt = new CCrashReportSocketPvt(); connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) ); } -CRCErrorSocket::~CRCErrorSocket() +CCrashReportSocket::~CCrashReportSocket() { delete m_pvt; } -void CRCErrorSocket::sendReport( const SRCErrorData &data ) +void CCrashReportSocket::sendReport( const SCrashReportData &data ) { QUrl params; params.addQueryItem( "report", data.report ); @@ -60,7 +60,7 @@ void CRCErrorSocket::sendReport( const SRCErrorData &data ) m_pvt->mgr.post( request, params.encodedQuery() ); } -void CRCErrorSocket::onFinished( QNetworkReply *reply ) +void CCrashReportSocket::onFinished( QNetworkReply *reply ) { if( reply->error() != QNetworkReply::NoError ) Q_EMIT reportFailed(); diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h index 95092a250..24bf6c451 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.h +++ b/code/nel/tools/misc/crash_report/crash_report_socket.h @@ -21,20 +21,20 @@ #define RCERROR_SOCKET #include -#include "rcerror_data.h" +#include "crash_report_data.h" -class CRCErrorSocketPvt; +class CCrashReportSocketPvt; class QNetworkReply; -class CRCErrorSocket : public QObject +class CCrashReportSocket : public QObject { Q_OBJECT public: - CRCErrorSocket( QObject *parent ); - ~CRCErrorSocket(); + CCrashReportSocket( QObject *parent ); + ~CCrashReportSocket(); - void sendReport( const SRCErrorData &data ); + void sendReport( const SCrashReportData &data ); Q_SIGNALS: void reportSent(); @@ -44,7 +44,7 @@ private Q_SLOTS: void onFinished( QNetworkReply *reply ); private: - CRCErrorSocketPvt *m_pvt; + CCrashReportSocketPvt *m_pvt; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 04d06ff94..49925765d 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -17,20 +17,20 @@ // along with this program. If not, see . -#include "rcerror_widget.h" -#include "rcerror_socket.h" -#include "rcerror_data.h" +#include "crash_report_widget.h" +#include "crash_report_socket.h" +#include "crash_report_data.h" #include #include #include #include -CRCErrorWidget::CRCErrorWidget( QWidget *parent ) : +CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) { m_ui.setupUi( this ); - m_socket = new CRCErrorSocket( this ); + m_socket = new CCrashReportSocket( this ); QTimer::singleShot( 1, this, SLOT( onLoad() ) ); @@ -42,12 +42,12 @@ QWidget( parent ) connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) ); } -CRCErrorWidget::~CRCErrorWidget() +CCrashReportWidget::~CCrashReportWidget() { m_socket = NULL; } -void CRCErrorWidget::onLoad() +void CCrashReportWidget::onLoad() { QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); @@ -64,12 +64,12 @@ void CRCErrorWidget::onLoad() f.close(); } -void CRCErrorWidget::onSendClicked() +void CCrashReportWidget::onSendClicked() { m_ui.sendButton->setEnabled( false ); QApplication::setOverrideCursor( Qt::WaitCursor ); - SRCErrorData data; + SCrashReportData data; data.description = m_ui.descriptionEdit->toPlainText(); data.report = m_ui.reportEdit->toPlainText(); data.email = m_ui.emailEdit->text(); @@ -77,17 +77,17 @@ void CRCErrorWidget::onSendClicked() m_socket->sendReport( data ); } -void CRCErrorWidget::onCancelClicked() +void CCrashReportWidget::onCancelClicked() { close(); } -void CRCErrorWidget::onCBClicked() +void CCrashReportWidget::onCBClicked() { m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } -void CRCErrorWidget::onReportSent() +void CCrashReportWidget::onReportSent() { QApplication::setOverrideCursor( Qt::ArrowCursor ); @@ -98,7 +98,7 @@ void CRCErrorWidget::onReportSent() close(); } -void CRCErrorWidget::onReportFailed() +void CCrashReportWidget::onReportFailed() { QApplication::setOverrideCursor( Qt::ArrowCursor ); diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 1d016fa52..47d16ad77 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -21,16 +21,16 @@ #define RCERROR_WIDGET -#include "ui_rcerror_widget.h" +#include "ui_crash_report_widget.h" -class CRCErrorSocket; +class CCrashReportSocket; -class CRCErrorWidget : public QWidget +class CCrashReportWidget : public QWidget { Q_OBJECT public: - CRCErrorWidget( QWidget *parent = NULL ); - ~CRCErrorWidget(); + CCrashReportWidget( QWidget *parent = NULL ); + ~CCrashReportWidget(); void setFileName( const char *fn ){ m_fileName = fn; } @@ -44,9 +44,9 @@ private Q_SLOTS: void onReportFailed(); private: - Ui::RCErrorWidget m_ui; + Ui::CrashReportWidget m_ui; QString m_fileName; - CRCErrorSocket *m_socket; + CCrashReportSocket *m_socket; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index b92ac65a6..589810578 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -1,7 +1,7 @@ - RCErrorWidget - + CrashReportWidget + Qt::ApplicationModal From 955ef484608242126953099a8c5935f263143e96 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 21:51:17 +0100 Subject: [PATCH 13/15] Parametrize crash reporter. --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 21 ++++--- .../tools/misc/crash_report/crash_report.cpp | 61 ++++++++++++++++++- .../misc/crash_report/crash_report_socket.cpp | 7 +-- .../misc/crash_report/crash_report_socket.h | 4 ++ .../misc/crash_report/crash_report_widget.cpp | 56 ++++++++++++++++- .../misc/crash_report/crash_report_widget.h | 7 +++ 6 files changed, 139 insertions(+), 17 deletions(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 09cfc1178..58740ce28 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -92,18 +92,21 @@ static bool CanSendMailReport= false; static bool DebugDefaultBehavior, QuitDefaultBehavior; +static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; + static void doSendReport() { std::string filename; - // Unfortunately Qt 4.8.5 on Windows messes up arguments. - // As a workaround the report filename is hardcoded for now. - // - //filename = "report_"; - //filename += NLMISC::toString( time( NULL ) ); - //filename += ".txt"; + filename = "report_"; + filename += NLMISC::toString( time( NULL ) ); + filename += ".txt"; - filename = "rcerrorlog.txt"; + std::string params; + params = "-log "; + params += filename; + params += " -host "; + params += URL; std::ofstream f; f.open( filename.c_str() ); @@ -115,9 +118,9 @@ static void doSendReport() f.close(); #ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "crash_report.exe", filename ); + NLMISC::launchProgram( "crash_report.exe", params ); #else - NLMISC::launchProgram( "crash_report", filename ); + NLMISC::launchProgram( "crash_report", params ); #endif } diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index d04928d21..e083de126 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -21,12 +21,71 @@ #include #include +#include +#include +#include + +class CCmdLineParser +{ +public: + static void parse( int argc, char **argv, std::vector< std::pair< std::string, std::string > > &v ) + { + std::stack< std::string > stack; + std::string key; + std::string value; + + for( int i = argc - 1 ; i >= 0; i-- ) + { + stack.push( std::string( argv[ i ] ) ); + } + + while( !stack.empty() ) + { + key = stack.top(); + stack.pop(); + + // If not a real parameter ( they start with '-' ), discard. + if( key[ 0 ] != '-' ) + continue; + + // Remove the '-' + key = key.substr( 1 ); + + // No more parameters + if( stack.empty() ) + { + v.push_back( std::make_pair( key, "" ) ); + break; + } + + value = stack.top(); + + // If next parameter is a key, process it in the next iteration + if( value[ 0 ] == '-' ) + { + v.push_back( std::make_pair( key, "" ) ); + continue; + } + // Otherwise store the pair + else + { + v.push_back( std::make_pair( key, value ) ); + stack.pop(); + } + } + } +}; + int main( int argc, char **argv ) { QApplication app( argc, argv ); + std::vector< std::pair< std::string, std::string > > params; + + CCmdLineParser::parse( argc, argv, params ); + CCrashReportWidget w; - w.setFileName( "rcerrorlog.txt" ); + w.setup( params ); w.show(); return app.exec(); diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp index 209ea89e8..5f8720e05 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_socket.cpp @@ -22,11 +22,6 @@ #include #include -namespace -{ - static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; -} - class CCrashReportSocketPvt { public: @@ -53,7 +48,7 @@ void CCrashReportSocket::sendReport( const SCrashReportData &data ) params.addQueryItem( "descr", data.description ); params.addQueryItem( "email", data.email ); - QUrl url( BUG_URL ); + QUrl url( m_url ); QNetworkRequest request( url ); request.setRawHeader( "Connection", "close" ); diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h index 24bf6c451..32ccc5da0 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.h +++ b/code/nel/tools/misc/crash_report/crash_report_socket.h @@ -34,6 +34,9 @@ public: CCrashReportSocket( QObject *parent ); ~CCrashReportSocket(); + void setURL( const char *URL ){ m_url = URL; } + QString url() const{ return m_url; } + void sendReport( const SCrashReportData &data ); Q_SIGNALS: @@ -45,6 +48,7 @@ private Q_SLOTS: private: CCrashReportSocketPvt *m_pvt; + QString m_url; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 49925765d..ff0028223 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -47,8 +47,39 @@ CCrashReportWidget::~CCrashReportWidget() m_socket = NULL; } +void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::string > > ¶ms ) +{ + for( int i = 0; i < params.size(); i++ ) + { + const std::pair< std::string, std::string > &p = params[ i ]; + const std::string &k = p.first; + const std::string &v = p.second; + + if( k == "log" ) + { + m_fileName = v.c_str(); + } + else + if( k == "host" ) + { + m_socket->setURL( v.c_str() ); + } + else + if( k == "title" ) + { + setWindowTitle( v.c_str() ); + } + } +} + void CCrashReportWidget::onLoad() { + if( !checkSettings() ) + { + close(); + return; + } + QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); if( !b ) @@ -57,6 +88,7 @@ void CCrashReportWidget::onLoad() tr( "No log file found" ), tr( "There was no log file found, therefore nothing to report. Exiting..." ) ); close(); + return; } QTextStream ss( &f ); @@ -107,4 +139,26 @@ void CCrashReportWidget::onReportFailed() tr( "Failed to send the report..." ) ); close(); -} \ No newline at end of file +} + +bool CCrashReportWidget::checkSettings() +{ + if( m_fileName.isEmpty() ) + { + QMessageBox::information( this, + tr( "No log file specified." ), + tr( "No log file specified. Exiting..." ) ); + return false; + } + + if( m_socket->url().isEmpty() ) + { + QMessageBox::information( this, + tr( "No host specified." ), + tr( "No host specified. Exiting..." ) ); + return false; + } + + return true; +} + diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 47d16ad77..0baf2521d 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -22,6 +22,8 @@ #include "ui_crash_report_widget.h" +#include +#include class CCrashReportSocket; @@ -34,6 +36,8 @@ public: void setFileName( const char *fn ){ m_fileName = fn; } + void setup( const std::vector< std::pair< std::string, std::string > > ¶ms ); + private Q_SLOTS: void onLoad(); void onSendClicked(); @@ -44,6 +48,9 @@ private Q_SLOTS: void onReportFailed(); private: + bool checkSettings(); + + Ui::CrashReportWidget m_ui; QString m_fileName; CCrashReportSocket *m_socket; From 2bb5e8e9ba6be80184635505cc570176b1a153b7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 22:34:07 +0100 Subject: [PATCH 14/15] Remove generated log file when quitting the reporter. --HG-- branch : feature-crashreport --- .../tools/misc/crash_report/crash_report_widget.cpp | 13 ++++++++++--- .../tools/misc/crash_report/crash_report_widget.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index ff0028223..968978f94 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -24,6 +24,7 @@ #include #include #include +#include CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) @@ -111,7 +112,7 @@ void CCrashReportWidget::onSendClicked() void CCrashReportWidget::onCancelClicked() { - close(); + removeAndQuit(); } void CCrashReportWidget::onCBClicked() @@ -127,7 +128,7 @@ void CCrashReportWidget::onReportSent() tr( "Report sent" ), tr( "The report has been sent." ) ); - close(); + removeAndQuit(); } void CCrashReportWidget::onReportFailed() @@ -138,7 +139,7 @@ void CCrashReportWidget::onReportFailed() tr( "Report failed" ), tr( "Failed to send the report..." ) ); - close(); + removeAndQuit(); } bool CCrashReportWidget::checkSettings() @@ -162,3 +163,9 @@ bool CCrashReportWidget::checkSettings() return true; } +void CCrashReportWidget::removeAndQuit() +{ + QFile::remove( m_fileName ); + close(); +} + diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 0baf2521d..61b56e340 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -49,7 +49,7 @@ private Q_SLOTS: private: bool checkSettings(); - + void removeAndQuit(); Ui::CrashReportWidget m_ui; QString m_fileName; From 8bf372056f1290301b75e38eac367eb74306383d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 23 Feb 2015 01:36:50 +0100 Subject: [PATCH 15/15] Use CMsgBoxDisplayer on non-windows platforms as well. --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/displayer.cpp | 4 +- code/nel/src/misc/report.cpp | 79 ++++++++++++++++++--------------- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 3f0c26f69..86752a412 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -1197,10 +1197,10 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) #ifdef NL_OS_WINDOWS if (TrapCrashInDebugger || !IsDebuggerPresent ()) +#endif { DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); } -#endif #if LOG_IN_FILE if (logInFile) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index d48c44d02..86fc1d726 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,7 +529,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { -#ifdef NL_OS_WINDOWS +//#ifdef NL_OS_WINDOWS bool needSpace = false; // stringstream ss; @@ -720,7 +720,7 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m } */ } -#endif +//#endif } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 58740ce28..784f49a9a 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -63,19 +63,61 @@ void setReportEmailFunction (void *emailFunction) #endif } +static string Body; +static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; + + +static void doSendReport() +{ + std::string filename; + + filename = "report_"; + filename += NLMISC::toString( int( time( NULL ) ) ); + filename += ".txt"; + + std::string params; + params = "-log "; + params += filename; + params += " -host "; + params += URL; + + std::ofstream f; + f.open( filename.c_str() ); + if( !f.good() ) + return; + + f << Body; + + f.close(); + +#ifdef NL_OS_WINDOWS + NLMISC::launchProgram( "crash_report.exe", params ); +#else + NLMISC::launchProgram( "crash_report", params ); +#endif + + // Added because NLSMIC::launcProgram needs time to launch + nlSleep( 2 * 1000 ); + +} + #ifndef NL_OS_WINDOWS // GNU/Linux, do nothing -void report () +TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) { + Body = addSlashR( body ); + + doSendReport(); + + return ReportQuit; } #else // Windows specific version -static string Body; static string Subject; static string AttachedFile; @@ -92,39 +134,6 @@ static bool CanSendMailReport= false; static bool DebugDefaultBehavior, QuitDefaultBehavior; -static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; - -static void doSendReport() -{ - std::string filename; - - filename = "report_"; - filename += NLMISC::toString( time( NULL ) ); - filename += ".txt"; - - std::string params; - params = "-log "; - params += filename; - params += " -host "; - params += URL; - - std::ofstream f; - f.open( filename.c_str() ); - if( !f.good() ) - return; - - f << Body; - - f.close(); - -#ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "crash_report.exe", params ); -#else - NLMISC::launchProgram( "crash_report", params ); -#endif - -} - static void sendEmail() { if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED)