From 84e19b10ef39e602ba32683cc72afc3a8850e409 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek%gmail.com" Date: Fri, 25 Jan 2008 11:24:02 +0000 Subject: [PATCH] bug 394490 - pending extra and dmp files should be deleted when not submitting report. r=dcamp git-svn-id: svn://10.0.0.236/trunk@243978 18797224-902f-48f8-a5cc-f745e15eee43 --- .../crashreporter/client/crashreporter.cpp | 23 +++++++++++-------- .../crashreporter/client/crashreporter.h | 5 +++- .../client/crashreporter_linux.cpp | 6 ++++- .../crashreporter/client/crashreporter_osx.h | 1 + .../crashreporter/client/crashreporter_osx.mm | 15 +++++++++++- .../client/crashreporter_win.cpp | 13 ++++++----- 6 files changed, 45 insertions(+), 18 deletions(-) diff --git a/mozilla/toolkit/crashreporter/client/crashreporter.cpp b/mozilla/toolkit/crashreporter/client/crashreporter.cpp index ccbb38ffbae..68734d031ba 100644 --- a/mozilla/toolkit/crashreporter/client/crashreporter.cpp +++ b/mozilla/toolkit/crashreporter/client/crashreporter.cpp @@ -324,17 +324,21 @@ static bool AddSubmittedReport(const string& serverResponse) return true; } +void DeleteDump() +{ + const char* noDelete = getenv("MOZ_CRASHREPORTER_NO_DELETE_DUMP"); + if (!noDelete || *noDelete == '\0') { + if (!gDumpFile.empty()) + UIDeleteFile(gDumpFile); + if (!gExtraFile.empty()) + UIDeleteFile(gExtraFile); + } +} + bool SendCompleted(bool success, const string& serverResponse) { if (success) { - const char* noDelete = getenv("MOZ_CRASHREPORTER_NO_DELETE_DUMP"); - if (!noDelete || *noDelete == '\0') { - if (!gDumpFile.empty()) - UIDeleteFile(gDumpFile); - if (!gExtraFile.empty()) - UIDeleteFile(gExtraFile); - } - + DeleteDump(); return AddSubmittedReport(serverResponse); } return true; @@ -508,7 +512,8 @@ int main(int argc, char** argv) sendURL = urlEnv; } - UIShowCrashUI(gDumpFile, queryParameters, sendURL, restartArgs); + if (!UIShowCrashUI(gDumpFile, queryParameters, sendURL, restartArgs)) + DeleteDump(); } UIShutdown(); diff --git a/mozilla/toolkit/crashreporter/client/crashreporter.h b/mozilla/toolkit/crashreporter/client/crashreporter.h index 77255484c10..357849f8d44 100644 --- a/mozilla/toolkit/crashreporter/client/crashreporter.h +++ b/mozilla/toolkit/crashreporter/client/crashreporter.h @@ -100,6 +100,7 @@ namespace CrashReporter { StringTable& strings, bool escape); void LogMessage(const std::string& message); + void DeleteDump(); } //============================================================================= @@ -113,7 +114,9 @@ void UIShutdown(); void UIShowDefaultUI(); // Run the UI for when the app was launched with a dump file -void UIShowCrashUI(const std::string& dumpfile, +// Return true if the user sent (or tried to send) the crash report, +// false if they chose not to, and it should be deleted. +bool UIShowCrashUI(const std::string& dumpfile, const StringTable& queryParameters, const std::string& sendURL, const std::vector& restartArgs); diff --git a/mozilla/toolkit/crashreporter/client/crashreporter_linux.cpp b/mozilla/toolkit/crashreporter/client/crashreporter_linux.cpp index b200cfd8a7a..e3f76d1d95d 100644 --- a/mozilla/toolkit/crashreporter/client/crashreporter_linux.cpp +++ b/mozilla/toolkit/crashreporter/client/crashreporter_linux.cpp @@ -73,6 +73,7 @@ static GtkWidget* gCloseButton = 0; static GtkWidget* gRestartButton = 0; static bool gInitialized = false; +static bool gDidTrySend = false; static string gDumpFile; static StringTable gQueryParameters; static string gSendURL; @@ -278,6 +279,7 @@ static void RestartClicked(GtkButton* button, RestartApplication(); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) { + gDidTrySend = true; SendReport(); } else { gtk_main_quit(); @@ -545,7 +547,7 @@ void UIShowDefaultUI() gtk_dialog_run(GTK_DIALOG(errorDialog)); } -void UIShowCrashUI(const string& dumpfile, +bool UIShowCrashUI(const string& dumpfile, const StringTable& queryParameters, const string& sendURL, const vector& restartArgs) @@ -719,6 +721,8 @@ void UIShowCrashUI(const string& dumpfile, gtk_widget_hide_all(gThrobber); gtk_main(); + + return gDidTrySend; } void UIError_impl(const string& message) diff --git a/mozilla/toolkit/crashreporter/client/crashreporter_osx.h b/mozilla/toolkit/crashreporter/client/crashreporter_osx.h index da0bb99ed9e..22eee78e83d 100644 --- a/mozilla/toolkit/crashreporter/client/crashreporter_osx.h +++ b/mozilla/toolkit/crashreporter/client/crashreporter_osx.h @@ -97,6 +97,7 @@ - (void)uploadComplete:(id)data; -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication; +-(void)applicationWillTerminate:(NSNotification *)aNotification; @end diff --git a/mozilla/toolkit/crashreporter/client/crashreporter_osx.mm b/mozilla/toolkit/crashreporter/client/crashreporter_osx.mm index 3dea60cf4f4..c8123f4de28 100644 --- a/mozilla/toolkit/crashreporter/client/crashreporter_osx.mm +++ b/mozilla/toolkit/crashreporter/client/crashreporter_osx.mm @@ -58,6 +58,7 @@ static StringTable gQueryParameters; static string gURLParameter; static string gSendURL; static vector gRestartArgs; +static bool gDidTrySend = false; #define NSSTR(s) [NSString stringWithUTF8String:(s).c_str()] @@ -276,6 +277,7 @@ static bool RestartApplication() // Hide the dialog after "closing", but leave it around to coordinate // with the upload thread [window orderOut:nil]; + gDidTrySend = true; [self sendReport]; } else { [NSApp terminate:self]; @@ -289,6 +291,7 @@ static bool RestartApplication() // Hide the dialog after "closing", but leave it around to coordinate // with the upload thread [window orderOut:nil]; + gDidTrySend = true; [self sendReport]; } else { [NSApp terminate:self]; @@ -488,6 +491,14 @@ static bool RestartApplication() return NO; } +-(void)applicationWillTerminate:(NSNotification *)aNotification +{ + // since we use [NSApp terminate:] we never return to main, + // so do our cleanup here + if (!gDidTrySend) + DeleteDump(); +} + @end /* === Crashreporter UI Functions === */ @@ -512,7 +523,7 @@ void UIShowDefaultUI() [NSApp run]; } -void UIShowCrashUI(const string& dumpfile, +bool UIShowCrashUI(const string& dumpfile, const StringTable& queryParameters, const string& sendURL, const vector& restartArgs) @@ -523,6 +534,8 @@ void UIShowCrashUI(const string& dumpfile, queryParameters: queryParameters sendURL: sendURL]; [NSApp run]; + + return gDidTrySend; } void UIError_impl(const string& message) diff --git a/mozilla/toolkit/crashreporter/client/crashreporter_win.cpp b/mozilla/toolkit/crashreporter/client/crashreporter_win.cpp index 0537a44890d..88800f42d4f 100644 --- a/mozilla/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/mozilla/toolkit/crashreporter/client/crashreporter_win.cpp @@ -911,7 +911,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message, Str(ST_REPORTSUBMITSUCCESS).c_str() : Str(ST_SUBMITFAILED).c_str()); // close dialog after 5 seconds - SetTimer(hwndDlg, success ? 1 : 0, 5000, NULL); + SetTimer(hwndDlg, 0, 5000, NULL); // return TRUE; } @@ -932,8 +932,9 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message, } case WM_TIMER: { - // wParam is the second parameter from SetTimer above - EndCrashReporterDialog(hwndDlg, wParam); + // The "1" gets used down in UIShowCrashUI to indicate that we at least + // tried to send the report. + EndCrashReporterDialog(hwndDlg, 1); return FALSE; } @@ -1027,7 +1028,7 @@ void UIShowDefaultUI() MB_OK | MB_ICONSTOP); } -void UIShowCrashUI(const string& dumpFile, +bool UIShowCrashUI(const string& dumpFile, const StringTable& queryParameters, const string& sendURL, const vector& restartArgs) @@ -1055,8 +1056,8 @@ void UIShowCrashUI(const string& dumpFile, gRestartArgs = restartArgs; - DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_SENDDIALOG), NULL, - (DLGPROC)CrashReporterDialogProc, 0); + return DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_SENDDIALOG), NULL, + (DLGPROC)CrashReporterDialogProc, 0) == 1; } void UIError_impl(const string& message)