From e4b9b7b505ea1af2daa93526a08d97a8aa5516c4 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 20 Oct 2017 23:22:07 -0400 Subject: [PATCH] Avoid long repetitions of message boxes for opening corrupt project --- src/AudacityException.cpp | 6 +++++- src/AudacityException.h | 3 ++- src/FileException.h | 2 +- src/InconsistencyException.h | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/AudacityException.cpp b/src/AudacityException.cpp index e37edf175..f8191aec4 100644 --- a/src/AudacityException.cpp +++ b/src/AudacityException.cpp @@ -13,7 +13,11 @@ wxAtomicInt sOutstandingMessages {}; MessageBoxException::MessageBoxException( const wxString &caption_ ) : caption{ caption_ } { - wxAtomicInc( sOutstandingMessages ); + if (!caption.empty()) + wxAtomicInc( sOutstandingMessages ); + else + // invalidate me + moved = true; } // The class needs a copy constructor to be throwable diff --git a/src/AudacityException.h b/src/AudacityException.h index 31e2e3382..061c5d0c7 100644 --- a/src/AudacityException.h +++ b/src/AudacityException.h @@ -55,6 +55,7 @@ class MessageBoxException /* not final */ : public AudacityException void DelayedHandlerAction() override; protected: + // If default-constructed with empty caption, it makes no message box. explicit MessageBoxException( const wxString &caption = wxString{} ); ~MessageBoxException() override; @@ -74,7 +75,7 @@ class SimpleMessageBoxException /* not final */ : public MessageBoxException { public: explicit SimpleMessageBoxException( const wxString &message_, - const wxString &caption = wxString{} ) + const wxString &caption = _("Message") ) : MessageBoxException{ caption } , message{ message_ } {} diff --git a/src/FileException.h b/src/FileException.h index 0d0225fc0..6a6fcb6ec 100644 --- a/src/FileException.h +++ b/src/FileException.h @@ -19,7 +19,7 @@ public: explicit FileException ( Cause cause_, const wxFileName &fileName_, - const wxString &caption = wxString{}, + const wxString &caption = _("File Error"), const wxFileName &renameTarget_ = {}) : MessageBoxException{ caption } , cause{ cause_ }, fileName{ fileName_ }, renameTarget{ renameTarget_ } diff --git a/src/InconsistencyException.h b/src/InconsistencyException.h index 065919eff..a3fc21c5a 100644 --- a/src/InconsistencyException.h +++ b/src/InconsistencyException.h @@ -22,7 +22,8 @@ public: explicit InconsistencyException ( const char *fn, const char *f, unsigned l ) - : func { fn }, file { f }, line { l } + : MessageBoxException{ _("Internal Error") } + , func { fn }, file { f }, line { l } {} InconsistencyException(InconsistencyException&& that)