Audacity  3.0.3
Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
MessageBoxException Class Referenceabstract

Abstract AudacityException subclass displays a message, specified by further subclass. More...

#include <AudacityException.h>

Inheritance diagram for MessageBoxException:
[legend]
Collaboration diagram for MessageBoxException:
[legend]

Protected Member Functions

 MessageBoxException (ExceptionType exceptionType, const TranslatableString &caption)
 If default-constructed with empty caption, it makes no message box. More...
 
 ~MessageBoxException () override
 
 MessageBoxException (const MessageBoxException &)
 
virtual TranslatableString ErrorMessage () const =0
 Format the error message for this exception. More...
 
virtual wxString ErrorHelpUrl () const
 
- Protected Member Functions inherited from AudacityException
 AudacityException (const AudacityException &)=default
 Make this protected to prevent slicing copies. More...
 
 AudacityException (AudacityException &&) PROHIBITED
 Don't allow moves of this class or subclasses. More...
 
AudacityExceptionoperator= (const AudacityException &) PROHIBITED
 Disallow assignment. More...
 

Protected Attributes

wxString helpUrl { "" }
 

Private Member Functions

void DelayedHandlerAction () final
 Do not allow subclasses to change behavior, except by overriding ErrorMessage(). More...
 
virtual void DelayedHandlerAction ()=0
 Privatize the inherited function. More...
 

Private Attributes

TranslatableString caption
 Stored caption. More...
 
ExceptionType exceptionType
 Exception type. More...
 
bool moved { false }
 Whether *this has been the source of a copy. More...
 

Additional Inherited Members

- Public Member Functions inherited from AudacityException
 AudacityException ()
 
virtual ~AudacityException ()=0
 
- Static Public Member Functions inherited from AudacityException
static void EnqueueAction (std::exception_ptr pException, std::function< void(AudacityException *)> delayedHandler)
 

Detailed Description

Abstract AudacityException subclass displays a message, specified by further subclass.

At most one message will be displayed for each pass through the main event idle loop, no matter how many exceptions were caught.

Definition at line 60 of file AudacityException.h.

Constructor & Destructor Documentation

◆ MessageBoxException() [1/2]

MessageBoxException::MessageBoxException ( ExceptionType  exceptionType,
const TranslatableString caption 
)
explicitprotected

If default-constructed with empty caption, it makes no message box.

Parameters
exceptionTypeException type
captionShown in message box's frame; not the actual message

Definition at line 39 of file AudacityException.cpp.

41  : caption { caption_ }
42  , exceptionType { exceptionType_ }
43 {
44  if (!caption.empty())
45  wxAtomicInc( sOutstandingMessages );
46  else
47  // invalidate me
48  moved = true;
49 }

◆ ~MessageBoxException()

MessageBoxException::~MessageBoxException ( )
overrideprotected

Definition at line 64 of file AudacityException.cpp.

65 {
66  if (!moved)
67  // If exceptions are used properly, you should never reach this,
68  // because moved should become true earlier in the object's lifetime.
69  wxAtomicDec( sOutstandingMessages );
70 }

References moved, and sOutstandingMessages.

◆ MessageBoxException() [2/2]

MessageBoxException::MessageBoxException ( const MessageBoxException that)
protected

Definition at line 55 of file AudacityException.cpp.

56 {
57  caption = that.caption;
58  moved = that.moved;
59  helpUrl = that.helpUrl;
61  that.moved = true;
62 }

References caption, exceptionType, helpUrl, and moved.

Member Function Documentation

◆ DelayedHandlerAction() [1/2]

void MessageBoxException::DelayedHandlerAction ( )
finalprivatevirtual

Do not allow subclasses to change behavior, except by overriding ErrorMessage().

Implements AudacityException.

Definition at line 82 of file AudacityException.cpp.

83 {
84  if (!moved) {
85  // This test prevents accumulation of multiple messages between idle
86  // times of the main even loop. Only the last queued exception
87  // displays its message. We assume that multiple messages have a
88  // common cause such as exhaustion of disk space so that the others
89  // give the user no useful added information.
90 
91  using namespace BasicUI;
92  if ( wxAtomicDec( sOutstandingMessages ) == 0 ) {
94  && ErrorHelpUrl().IsEmpty()) {
95  // We show BadEnvironment and BadUserAction in a similar way
97  ErrorMessage(),
100  .IconStyle(Icon::Error) );
101  }
102  else {
103  using namespace BasicUI;
105  ? ErrorDialogType::ModalErrorReport : ErrorDialogType::ModalError;
106  ShowErrorDialog( {},
108  ErrorMessage(),
109  ErrorHelpUrl(),
110  ErrorDialogOptions{ type } );
111  }
112  }
113 
114  moved = true;
115  }
116 }

References BasicUI::MessageBoxOptions::Caption(), caption, BasicUI::DefaultCaption(), TranslatableString::empty(), ErrorHelpUrl(), ErrorMessage(), exceptionType, Internal, moved, BasicUI::ShowErrorDialog(), BasicUI::ShowMessageBox(), and sOutstandingMessages.

Here is the call graph for this function:

◆ DelayedHandlerAction() [2/2]

virtual void AudacityException::DelayedHandlerAction
privatevirtual

Privatize the inherited function.

Implements AudacityException.

◆ ErrorHelpUrl()

virtual wxString MessageBoxException::ErrorHelpUrl ( ) const
inlineprotectedvirtual

Reimplemented in FileException.

Definition at line 81 of file AudacityException.h.

81 { return helpUrl; };

Referenced by DelayedHandlerAction().

Here is the caller graph for this function:

◆ ErrorMessage()

virtual TranslatableString MessageBoxException::ErrorMessage ( ) const
protectedpure virtual

Format the error message for this exception.

Implemented in NotYetAvailableException, FileException, InconsistencyException, and SimpleMessageBoxException.

Referenced by DelayedHandlerAction().

Here is the caller graph for this function:

Member Data Documentation

◆ caption

TranslatableString MessageBoxException::caption
private

Stored caption.

Definition at line 84 of file AudacityException.h.

Referenced by DelayedHandlerAction(), and MessageBoxException().

◆ exceptionType

ExceptionType MessageBoxException::exceptionType
private

◆ helpUrl

wxString MessageBoxException::helpUrl { "" }
mutableprotected

Definition at line 89 of file AudacityException.h.

Referenced by MessageBoxException().

◆ moved

bool MessageBoxException::moved { false }
mutableprivate

Whether *this has been the source of a copy.

Definition at line 87 of file AudacityException.h.

Referenced by DelayedHandlerAction(), MessageBoxException(), and ~MessageBoxException().


The documentation for this class was generated from the following files:
TranslatableString::empty
bool empty() const
Definition: TranslatableString.h:72
BasicUI::MessageBoxOptions
Definition: BasicUI.h:91
BasicUI::ShowErrorDialog
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Definition: BasicUI.h:233
BasicUI::ShowMessageBox
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:248
MessageBoxException::exceptionType
ExceptionType exceptionType
Exception type.
Definition: AudacityException.h:85
MessageBoxException::ErrorHelpUrl
virtual wxString ErrorHelpUrl() const
Definition: AudacityException.h:81
MessageBoxException::ErrorMessage
virtual TranslatableString ErrorMessage() const =0
Format the error message for this exception.
BasicUI::ErrorDialogOptions
Options for variations of error dialogs; the default is for modal dialogs.
Definition: BasicUI.h:49
BasicUI
Definition: Export.h:39
BasicUI::MessageBoxOptions::Caption
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:98
MessageBoxException::helpUrl
wxString helpUrl
Definition: AudacityException.h:89
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
BasicUI::DefaultCaption
TranslatableString DefaultCaption()
"Message", suitably translated
Definition: BasicUI.cpp:70
sOutstandingMessages
wxAtomicInt sOutstandingMessages
Definition: AudacityException.cpp:37
MessageBoxException::caption
TranslatableString caption
Stored caption.
Definition: AudacityException.h:81
MessageBoxException::moved
bool moved
Whether *this has been the source of a copy.
Definition: AudacityException.h:87