1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +02:00

New library lib-exceptions

This commit is contained in:
Paul Licameli 2021-02-17 21:11:45 -05:00
parent e6c109b2cd
commit 0683d3c158
12 changed files with 45 additions and 19 deletions

View File

@ -9,6 +9,7 @@ set( LIBRARIES
lib-uuid
lib-components
lib-basic-ui
lib-exceptions
)
if ( ${_OPT}has_networking )

View File

@ -9,7 +9,6 @@
***********************************************************************/
#include "AudacityException.h"
#include <wx/atomic.h>

View File

@ -38,7 +38,7 @@ public:
//! Action to do in the main thread at idle time of the event loop.
virtual void DelayedHandlerAction() = 0;
AUDACITY_DLL_API static void EnqueueAction(
EXCEPTIONS_API static void EnqueueAction(
std::exception_ptr pException,
std::function<void(AudacityException*)> delayedHandler);
@ -48,16 +48,16 @@ protected:
//! Don't allow moves of this class or subclasses
// see https://bugzilla.audacityteam.org/show_bug.cgi?id=2442
AudacityException( AudacityException&& ) = delete;
AudacityException( AudacityException&& ) PROHIBITED;
//! Disallow assignment
AudacityException &operator = ( const AudacityException & ) = delete;
AudacityException &operator = ( const AudacityException & ) PROHIBITED;
};
//! 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. */
class AUDACITY_DLL_API MessageBoxException /* not final */
class EXCEPTIONS_API MessageBoxException /* not final */
: public AudacityException
{
//! Privatize the inherited function
@ -90,7 +90,7 @@ protected:
};
//! A MessageBoxException that shows a given, unvarying string.
class AUDACITY_DLL_API SimpleMessageBoxException /* not final */
class EXCEPTIONS_API SimpleMessageBoxException /* not final */
: public MessageBoxException
{
public:

View File

@ -0,0 +1,34 @@
#[[
Toolkit neutral library for exceptions.
Abstract class AudacityException with a member function for a delayed
handler action, enqueued in the main thread;
Some commonly useful subclasses, with delayed handlers that are no-ops or
are displays of messages to the user;
Function template GuardedCall which stops propagation of exceptions and
enqueues the delayed action.
But this library does NOT define a top-level handler for the whole application,
to catch all otherwise uncaught exceptions. That is a responsibility of high
level code.
]]#
list( APPEND SOURCES
AudacityException.cpp
AudacityException.h
InconsistencyException.cpp
InconsistencyException.h
UserException.cpp
UserException.h
)
set( LIBRARIES
lib-utility-interface
lib-basic-ui-interface
PRIVATE
wxBase
)
audacity_library( lib-exceptions "${SOURCES}" "${LIBRARIES}"
"" ""
)

View File

@ -7,7 +7,6 @@
*/
#include "InconsistencyException.h"
#include <wx/filename.h>

View File

@ -20,7 +20,7 @@
The error message identifies source file and line number, possibly the function too (depending on
the compiler), and suggests that the user inform the development team.
*/
class AUDACITY_DLL_API InconsistencyException final : public MessageBoxException
class EXCEPTIONS_API InconsistencyException final : public MessageBoxException
{
public:
InconsistencyException ()

View File

@ -6,7 +6,6 @@
*/
#include "UserException.h"
UserException::~UserException()

View File

@ -13,7 +13,7 @@
//! Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing
/*! This class does not inherit from MessageBoxException. */
class AUDACITY_DLL_API UserException final : public AudacityException
class EXCEPTIONS_API UserException final : public AudacityException
{
public:
UserException() {}

View File

@ -88,8 +88,6 @@ list( APPEND SOURCES
AudacityApp.cpp
AudacityApp.h
$<$<BOOL:${wxIS_MAC}>:AudacityApp.mm>
AudacityException.cpp
AudacityException.h
AudacityFileConfig.cpp
AudacityFileConfig.h
AudacityHeaders.cpp
@ -159,8 +157,6 @@ list( APPEND SOURCES
HitTestResult.h
ImageManipulation.cpp
ImageManipulation.h
InconsistencyException.cpp
InconsistencyException.h
InterpolateAudio.cpp
InterpolateAudio.h
KeyboardCapture.cpp
@ -325,8 +321,6 @@ list( APPEND SOURCES
UIHandle.h
UndoManager.cpp
UndoManager.h
UserException.cpp
UserException.h
ViewInfo.cpp
ViewInfo.h
VoiceKey.cpp

View File

@ -89,7 +89,7 @@ classes derived from it.
#include "CommandContext.h"
#include "../AudacityException.h"
#include "AudacityException.h"

View File

@ -31,7 +31,7 @@ and sample size to help you importing data of an unknown format.
#include "../Prefs.h"
#include "../ProjectSettings.h"
#include "../ShuttleGui.h"
#include "../UserException.h"
#include "UserException.h"
#include "../WaveTrack.h"
#include "../widgets/ProgressDialog.h"

View File

@ -16,7 +16,7 @@
#include "RawAudioGuess.h"
#include "../AudacityException.h"
#include "AudacityException.h"
#include <stdio.h>
#include <stdlib.h>