mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 17:10:05 +02:00
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,
|
// Use CallAfter to delay this to the next pass of the event loop,
|
||||||
// rather than risk doing it inside stack unwinding.
|
// rather than risk doing it inside stack unwinding.
|
||||||
auto pProject = ::GetActiveProject();
|
auto pProject = ::GetActiveProject();
|
||||||
std::shared_ptr< AudacityException > pException { e.Move().release() };
|
auto pException = std::current_exception();
|
||||||
CallAfter( [=] // Capture pException by value!
|
CallAfter( [=] // Capture pException by value!
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1097,7 +1097,9 @@ bool AudacityApp::OnExceptionInMainLoop()
|
|||||||
pProject->RedrawProject();
|
pProject->RedrawProject();
|
||||||
|
|
||||||
// Give the user an alert
|
// 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;
|
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
|
// This is meant to be invoked via wxEvtHandler::CallAfter
|
||||||
void MessageBoxException::DelayedHandlerAction()
|
void MessageBoxException::DelayedHandlerAction()
|
||||||
{
|
{
|
||||||
|
@ -30,11 +30,6 @@ public:
|
|||||||
AudacityException() {}
|
AudacityException() {}
|
||||||
virtual ~AudacityException() = 0;
|
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.
|
// Action to do in the main thread at idle time of the event loop.
|
||||||
virtual void DelayedHandlerAction() = 0;
|
virtual void DelayedHandlerAction() = 0;
|
||||||
|
|
||||||
@ -88,8 +83,6 @@ public:
|
|||||||
SimpleMessageBoxException &operator = (
|
SimpleMessageBoxException &operator = (
|
||||||
SimpleMessageBoxException && ) PROHIBITED;
|
SimpleMessageBoxException && ) PROHIBITED;
|
||||||
|
|
||||||
std::unique_ptr< AudacityException > Move() override;
|
|
||||||
|
|
||||||
// Format a default, internationalized error message for this exception.
|
// Format a default, internationalized error message for this exception.
|
||||||
virtual wxString ErrorMessage() const override;
|
virtual wxString ErrorMessage() const override;
|
||||||
|
|
||||||
@ -170,11 +163,15 @@ R GuardedCall
|
|||||||
catch ( AudacityException &e ) {
|
catch ( AudacityException &e ) {
|
||||||
|
|
||||||
auto end = finally([&]{
|
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()) {
|
if (!std::uncaught_exception()) {
|
||||||
auto pException =
|
auto pException = std::current_exception(); // This points to e
|
||||||
std::shared_ptr< AudacityException > { e.Move().release() };
|
|
||||||
wxTheApp->CallAfter( [=] { // capture pException by value
|
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 FileException::ErrorMessage() const
|
||||||
{
|
{
|
||||||
wxString format;
|
wxString format;
|
||||||
|
@ -37,8 +37,6 @@ public:
|
|||||||
~FileException() override;
|
~FileException() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr< AudacityException > Move() override;
|
|
||||||
|
|
||||||
// Format a default, internationalized error message for this exception.
|
// Format a default, internationalized error message for this exception.
|
||||||
wxString ErrorMessage() const override;
|
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
|
wxString InconsistencyException::ErrorMessage() const
|
||||||
{
|
{
|
||||||
// Shorten the path
|
// Shorten the path
|
||||||
|
@ -48,8 +48,6 @@ public:
|
|||||||
unsigned GetLine() const { return line; }
|
unsigned GetLine() const { return line; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr< AudacityException > Move() override;
|
|
||||||
|
|
||||||
// Format a default, internationalized error message for this exception.
|
// Format a default, internationalized error message for this exception.
|
||||||
wxString ErrorMessage() const override;
|
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()
|
void UserException::DelayedHandlerAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,6 @@ public:
|
|||||||
~UserException() override;
|
~UserException() override;
|
||||||
|
|
||||||
void DelayedHandlerAction() override;
|
void DelayedHandlerAction() override;
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr< AudacityException > Move() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#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
|
wxString NotYetAvailableException::ErrorMessage() const
|
||||||
{
|
{
|
||||||
return wxString::Format(
|
return wxString::Format(
|
||||||
|
@ -25,7 +25,6 @@ public:
|
|||||||
~NotYetAvailableException();
|
~NotYetAvailableException();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr< AudacityException > Move() override;
|
|
||||||
wxString ErrorMessage() const override;
|
wxString ErrorMessage() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user