Don't need AudacityException::Move, use std::exception_ptr
This commit is contained in:
parent
f7515c90d8
commit
ac373502a9
|
@ -1083,7 +1083,7 @@ bool AudacityApp::OnExceptionInMainLoop()
|
|||
// Use CallAfter to delay this to the next pass of the event loop,
|
||||
// rather than risk doing it inside stack unwinding.
|
||||
auto pProject = ::GetActiveProject();
|
||||
std::shared_ptr< AudacityException > pException { e.Move().release() };
|
||||
auto pException = std::current_exception();
|
||||
CallAfter( [=] // Capture pException by value!
|
||||
{
|
||||
|
||||
|
@ -1097,7 +1097,9 @@ bool AudacityApp::OnExceptionInMainLoop()
|
|||
pProject->RedrawProject();
|
||||
|
||||
// Give the user an alert
|
||||
pException->DelayedHandlerAction();
|
||||
try { std::rethrow_exception( pException ); }
|
||||
catch( AudacityException &e )
|
||||
{ e.DelayedHandlerAction(); }
|
||||
|
||||
} );
|
||||
|
||||
|
|
|
@ -85,12 +85,6 @@ wxString SimpleMessageBoxException::ErrorMessage() const
|
|||
return message;
|
||||
}
|
||||
|
||||
std::unique_ptr< AudacityException > SimpleMessageBoxException::Move()
|
||||
{
|
||||
return std::unique_ptr< AudacityException >
|
||||
{ safenew SimpleMessageBoxException{ std::move( *this ) } };
|
||||
}
|
||||
|
||||
// This is meant to be invoked via wxEvtHandler::CallAfter
|
||||
void MessageBoxException::DelayedHandlerAction()
|
||||
{
|
||||
|
|
|
@ -30,11 +30,6 @@ public:
|
|||
AudacityException() {}
|
||||
virtual ~AudacityException() = 0;
|
||||
|
||||
// This is intended as a "polymorphic move copy constructor"
|
||||
// which leaves this "empty".
|
||||
// We would not need this if we had std::exception_ptr
|
||||
virtual std::unique_ptr< AudacityException > Move() = 0;
|
||||
|
||||
// Action to do in the main thread at idle time of the event loop.
|
||||
virtual void DelayedHandlerAction() = 0;
|
||||
|
||||
|
@ -88,8 +83,6 @@ public:
|
|||
SimpleMessageBoxException &operator = (
|
||||
SimpleMessageBoxException && ) PROHIBITED;
|
||||
|
||||
std::unique_ptr< AudacityException > Move() override;
|
||||
|
||||
// Format a default, internationalized error message for this exception.
|
||||
virtual wxString ErrorMessage() const override;
|
||||
|
||||
|
@ -170,11 +163,15 @@ R GuardedCall
|
|||
catch ( AudacityException &e ) {
|
||||
|
||||
auto end = finally([&]{
|
||||
// At this point, e is the "current" exception, but not "uncaught"
|
||||
// unless it was rethrown by handler. handler might also throw some
|
||||
// other exception object.
|
||||
if (!std::uncaught_exception()) {
|
||||
auto pException =
|
||||
std::shared_ptr< AudacityException > { e.Move().release() };
|
||||
auto pException = std::current_exception(); // This points to e
|
||||
wxTheApp->CallAfter( [=] { // capture pException by value
|
||||
delayedHandler( pException.get() );
|
||||
try { std::rethrow_exception(pException); }
|
||||
catch( AudacityException &e )
|
||||
{ delayedHandler( &e ); }
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,12 +15,6 @@ FileException::~FileException()
|
|||
{
|
||||
}
|
||||
|
||||
std::unique_ptr< AudacityException > FileException::Move()
|
||||
{
|
||||
return std::unique_ptr< AudacityException >
|
||||
{ safenew FileException{ std::move( *this ) } };
|
||||
}
|
||||
|
||||
wxString FileException::ErrorMessage() const
|
||||
{
|
||||
wxString format;
|
||||
|
|
|
@ -37,8 +37,6 @@ public:
|
|||
~FileException() override;
|
||||
|
||||
protected:
|
||||
std::unique_ptr< AudacityException > Move() override;
|
||||
|
||||
// Format a default, internationalized error message for this exception.
|
||||
wxString ErrorMessage() const override;
|
||||
|
||||
|
|
|
@ -14,12 +14,6 @@ InconsistencyException::~InconsistencyException()
|
|||
{
|
||||
}
|
||||
|
||||
std::unique_ptr< AudacityException > InconsistencyException::Move()
|
||||
{
|
||||
return std::unique_ptr< AudacityException >
|
||||
{ safenew InconsistencyException{ std::move( *this ) } };
|
||||
}
|
||||
|
||||
wxString InconsistencyException::ErrorMessage() const
|
||||
{
|
||||
// Shorten the path
|
||||
|
|
|
@ -48,8 +48,6 @@ public:
|
|||
unsigned GetLine() const { return line; }
|
||||
|
||||
private:
|
||||
std::unique_ptr< AudacityException > Move() override;
|
||||
|
||||
// Format a default, internationalized error message for this exception.
|
||||
wxString ErrorMessage() const override;
|
||||
|
||||
|
|
|
@ -13,12 +13,6 @@ UserException::~UserException()
|
|||
{
|
||||
}
|
||||
|
||||
std::unique_ptr< AudacityException > UserException::Move()
|
||||
{
|
||||
return std::unique_ptr< AudacityException >
|
||||
{ safenew UserException{ std::move( *this ) } };
|
||||
}
|
||||
|
||||
void UserException::DelayedHandlerAction()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -30,9 +30,6 @@ public:
|
|||
~UserException() override;
|
||||
|
||||
void DelayedHandlerAction() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr< AudacityException > Move() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,12 +14,6 @@ NotYetAvailableException::~NotYetAvailableException()
|
|||
{
|
||||
}
|
||||
|
||||
std::unique_ptr< AudacityException > NotYetAvailableException::Move()
|
||||
{
|
||||
return std::unique_ptr< AudacityException >
|
||||
{ safenew NotYetAvailableException{ std::move( *this ) } };
|
||||
}
|
||||
|
||||
wxString NotYetAvailableException::ErrorMessage() const
|
||||
{
|
||||
return wxString::Format(
|
||||
|
|
|
@ -25,7 +25,6 @@ public:
|
|||
~NotYetAvailableException();
|
||||
|
||||
protected:
|
||||
std::unique_ptr< AudacityException > Move() override;
|
||||
wxString ErrorMessage() const override;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user