Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27701/src/gui
Modified Files:
wxMApp.cpp
Log Message:
use new debug reporting classes instead of old wxCrashReport
Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.295
retrieving revision 1.296
diff -b -u -2 -r1.295 -r1.296
--- wxMApp.cpp 24 Oct 2004 12:52:00 -0000 1.295
+++ wxMApp.cpp 9 Apr 2005 15:37:03 -0000 1.296
@@ -460,4 +460,64 @@
// ----------------------------------------------------------------------------
+// MDebugReport
+// ----------------------------------------------------------------------------
+
+#if wxUSE_DEBUGREPORT
+
+#include "wx/debugrpt.h"
+#include "wx/file.h"
+
+#include "SendMessage.h"
+
+class MDebugReport : public wxDebugReportCompress
+{
+public:
+ MDebugReport(const char *msg)
+ {
+ AddAll(msg == NULL ? Context_Exception : Context_Current);
+
+ // TODO: include msg in report if not NUL
+ }
+
+protected:
+ virtual bool DoProcess()
+ {
+ if ( !wxDebugReportCompress::DoProcess() )
+ return false;
+
+ Profile *profile = mApplication ? mApplication->GetProfile() : NULL;
+
+ if ( profile )
+ {
+ // create a mail message and send it
+ SendMessage_obj sm(SendMessage::Create(profile, Prot_SMTP));
+ sm->SetSubject(_T("Mahogany crash report"));
+ sm->SetAddresses(_T("[EMAIL PROTECTED]"));
+
+ wxFile file(GetCompressedFileName());
+ if ( !file.IsOpened() )
+ return false;
+
+ const wxFileOffset len = file.Length();
+ wxCharBuffer buf(len);
+ if ( !file.Read(buf.data(), len) )
+ return false;
+
+ sm->AddPart(MimeType::APPLICATION, buf, len,
+ _T("OCTET-STREAM"), _T("ATTACHMENT"));
+ if ( sm->SendOrQueue(SendMessage::NeverQueue | SendMessage::Silent) )
+ {
+ // sent successfully
+ return true;
+ }
+ }
+
+ return false;
+ }
+};
+
+#endif // wxUSE_DEBUGREPORT
+
+// ----------------------------------------------------------------------------
// wxMApp ctor/dtor
// ----------------------------------------------------------------------------
@@ -575,5 +635,5 @@
static void
-SafeMsgBox(const String& msg)
+FatalMsgBox(const String& msg)
{
static const wxChar *title = gettext_noop("Fatal application error");
@@ -582,15 +642,21 @@
// have no such choice
#ifdef __WXMSW__
- ::MessageBox(NULL, wxGetTranslation(msg), wxGetTranslation(title),
MB_ICONSTOP);
+ ::MessageBox(NULL, msg, wxGetTranslation(title), MB_ICONSTOP);
#else // !MSW
- wxMessageBox(wxGetTranslation(msg), wxGetTranslation(title), wxICON_STOP |
wxOK);
+ wxMessageBox(msg, wxGetTranslation(title), wxICON_STOP | wxOK);
#endif // MSW/!MSW
}
void
-wxMApp::OnAbnormalTermination()
+wxMApp::OnAbnormalTermination(const char *msgOrig)
{
- // no more background processing
- gs_mutexBlockBg.Lock();
+ static bool s_crashed = false;
+
+ if ( s_crashed )
+ return;
+ s_crashed = true;
+
+ // no background processing in this function
+ MLocker lock(gs_mutexBlockBg);
@@ -600,9 +666,12 @@
int nSaved = SaveAll();
- wxString msg;
+ String msg(_("The application is terminating abnormally,\n"
+ "sorry for the inconvenience.\n\n"));
+
+ String msgComposer;
switch ( nSaved )
{
case -1:
- msg = _("Not all composer windows could be saved.");
+ msgComposer = _("Not all composer windows could be saved.");
break;
@@ -612,76 +681,59 @@
default:
- msg.Printf(_("%d unsaved messages were saved,\n"
+ msgComposer.Printf
+ (
+ _("%d unsaved messages were saved,\n"
"they will be restored on the next program startup."),
- nSaved);
+ nSaved
+ );
}
- static const wxChar *msgCrash =
- gettext_noop("The application is terminating abnormally.\n"
- "\n"
- "Please report the bug via our bugtracker at\n"
- "\n"
- " http://mahogany.sourceforge.net/bugz\n"
- "\n"
- "Be sure to mention your OS and Mahogany version\n"
- "and what exactly you were doing before this message\n"
- "box appeared as well as any other useful details!.\n"
- "\n"
- "Thank you!");
-
- if ( !msg.empty() )
+ if ( !msgComposer.empty() )
{
- msg += _T("\n\n");
+ msg << msgComposer << _T('\n');
}
- msg += msgCrash;
-
-#ifdef wxHAS_CRASH_REPORT
- msg += "\n\n";
- msg += String::Format
- (
- _("P.S. Mahogany will also try to generate bug report in the
file\n"
- "\n"
- " %s\n"
- "\n"
- "after you close this message box. Please look at this\n"
- "file if the program terminates without giving any other\n"
- "messages, it might contain some additional information."),
- wxCrashReport::GetFileName()
- );
-#endif // wxCrashReport available
-
- SafeMsgBox(msg);
-
-#ifdef wxHAS_CRASH_REPORT
- if ( wxCrashReport::Generate() )
+#if wxUSE_DEBUGREPORT
+ MDebugReport report(msgOrig);
+ if ( wxDebugReportPreviewStd().Show(report) )
{
- msg.Printf
- (
- _("Detailed crash report has been generated in the file\n"
- "\n"
- " %s\n"
- "\n"
- "please join it to your bug report.\n"
+ if ( report.Process() )
+ {
+ msg += _("Debug report was successfully sent to Mahogany dev-team.\n"
"\n"
- "Thank you in advance!"),
- wxCrashReport::GetFileName()
- );
+ "Thank you for your help!");
}
- else // failed to generate crash dump
+ else // failed to send debug report
{
- msg.Printf
- (
- _("Crash report generation failed, please look in the file\n"
+ msg += _("Debug report couldn't be sent.");
+
+ const wxString& fname = report.GetCompressedFileName();
+ if ( wxFile::Exists(fname) )
+ msg << _("Debug report couldn't be sent but was generated in "
+ "the file\n")
+ << _T(" ") << fname << _T("\n\n")
+ << _("Please attach this file to the the bug if you open\n"
+ "one in Mahogany bug tracker, thank you in advance.");
+ else
+ msg += _("Debug report couldn't be generated.");
+ }
+ }
+ else // user cancelled the report
+ {
+ msg += _("Debug report generation has been cancelled.");
+ }
+#else // !wxUSE_DEBUGREPORT
+ msg += _("Please report the bug via our bugtracker at\n"
"\n"
- " %s\n"
+ " http://mahogany.sourceforge.net/bugz\n"
"\n"
- "for the explanation of why it failed."),
- wxCrashReport::GetFileName()
- );
- }
+ "Be sure to mention your OS and Mahogany version\n"
+ "and what exactly you were doing before this message\n"
+ "box appeared as well as any other useful details!.\n"
+ "\n"
+ "Thank you!");
+#endif // wxUSE_DEBUGREPORT/!wxUSE_DEBUGREPORT
- SafeMsgBox(msg);
-#endif // wxCrashReport available
+ FatalMsgBox(msg);
}
@@ -816,9 +868,6 @@
wxMApp::OnInit()
{
- // in release build we handle any exceptions we generate (i.e. crashes)
- // ourselves
-#ifndef DEBUG
+ // we want our OnAbnormalTermination() be called if we crash
wxHandleFatalExceptions();
-#endif
// create a semaphore indicating that we're running - or check if another
@@ -2018,7 +2067,9 @@
void
-wxMApp::FatalError(const wxChar * /* message */)
+wxMApp::FatalError(const wxChar *message)
{
- OnAbnormalTermination();
+ OnAbnormalTermination(message);
+
+ abort();
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates