Audacity 3.2.0
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 &&)=delete
 Don't allow moves of this class or subclasses. More...
 
AudacityExceptionoperator= (const AudacityException &)=delete
 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
 
virtual void DelayedHandlerAction ()=0
 Action to do in the main thread at idle time of the event loop. More...
 
- 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}
wxAtomicInt sOutstandingMessages
bool moved
Whether *this has been the source of a copy.
TranslatableString caption
Stored caption.
ExceptionType exceptionType
Exception type.

References caption, TranslatableString::empty(), moved, and sOutstandingMessages.

Here is the call graph for this function:

◆ ~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
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}
@ Internal
Indicates internal failure from Audacity.
virtual TranslatableString ErrorMessage() const =0
Format the error message for this exception.
virtual wxString ErrorHelpUrl() const
TranslatableString DefaultCaption()
"Message", suitably translated
Definition: BasicUI.cpp:259
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:272
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:287
Options for variations of error dialogs; the default is for modal dialogs.
Definition: BasicUI.h:52
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:101

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 SimpleMessageBoxException, InconsistencyException, and FileException.

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

Exception type.

Definition at line 85 of file AudacityException.h.

Referenced by DelayedHandlerAction(), and MessageBoxException().

◆ 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: