pcsx2|common: use DESTRUCTOR_CATCHALL to catch exception in various destructor

Allow to print a nice error message instead of a brutal abort in case of
massive failure
This commit is contained in:
Gregory Hainaut 2015-09-22 19:06:12 +02:00
parent 0bb62bb0fd
commit 2eb73644e9
14 changed files with 95 additions and 38 deletions

View File

@ -558,7 +558,10 @@ ConsoleIndentScope::ConsoleIndentScope( int tabs )
ConsoleIndentScope::~ConsoleIndentScope() throw()
{
LeaveScope();
try {
LeaveScope();
}
DESTRUCTOR_CATCHALL
}
void ConsoleIndentScope::EnterScope()
@ -581,8 +584,11 @@ ConsoleAttrScope::ConsoleAttrScope( ConsoleColors newcolor, int indent )
ConsoleAttrScope::~ConsoleAttrScope() throw()
{
Console.SetColor( m_old_color );
Console.SetIndent( -m_tabsize );
try {
Console.SetColor( m_old_color );
Console.SetIndent( -m_tabsize );
}
DESTRUCTOR_CATCHALL
}

View File

@ -261,10 +261,13 @@ FastFormatUnicode::FastFormatUnicode()
FastFormatUnicode::~FastFormatUnicode() throw()
{
if (m_deleteDest)
delete m_dest;
else
m_buffer_tls.Get()->ReleaseBuffer();
try {
if (m_deleteDest)
delete m_dest;
else
m_buffer_tls.Get()->ReleaseBuffer();
}
DESTRUCTOR_CATCHALL
}
void FastFormatUnicode::Clear()
@ -396,10 +399,13 @@ FastFormatAscii::FastFormatAscii()
FastFormatAscii::~FastFormatAscii() throw()
{
if (m_deleteDest)
delete m_dest;
else
m_buffer_tls.Get()->ReleaseBuffer();
try {
if (m_deleteDest)
delete m_dest;
else
m_buffer_tls.Get()->ReleaseBuffer();
}
DESTRUCTOR_CATCHALL
}
void FastFormatAscii::Clear()

View File

@ -90,7 +90,10 @@ void SysMtgsThread::OnStart()
SysMtgsThread::~SysMtgsThread() throw()
{
_parent::Cancel();
try {
_parent::Cancel();
}
DESTRUCTOR_CATCHALL
}
void SysMtgsThread::OnResumeReady()

View File

@ -64,7 +64,10 @@ VU_Thread::VU_Thread(BaseVUmicroCPU*& _vuCPU, VURegs& _vuRegs) :
VU_Thread::~VU_Thread() throw()
{
pxThread::Cancel();
try {
pxThread::Cancel();
}
DESTRUCTOR_CATCHALL
}
void VU_Thread::Reset()

View File

@ -322,8 +322,11 @@ CpuInitializer< CpuType >::CpuInitializer()
template< typename CpuType >
CpuInitializer< CpuType >::~CpuInitializer() throw()
{
if (MyCpu)
MyCpu->Shutdown();
try {
if (MyCpu)
MyCpu->Shutdown();
}
DESTRUCTOR_CATCHALL
}
// --------------------------------------------------------------------------------------
@ -366,7 +369,10 @@ SysMainMemory::SysMainMemory()
SysMainMemory::~SysMainMemory() throw()
{
ReleaseAll();
try {
ReleaseAll();
}
DESTRUCTOR_CATCHALL
}
void SysMainMemory::ReserveAll()

View File

@ -55,7 +55,10 @@ SysCoreThread::SysCoreThread()
SysCoreThread::~SysCoreThread() throw()
{
SysCoreThread::Cancel();
try {
SysCoreThread::Cancel();
}
DESTRUCTOR_CATCHALL
}
void SysCoreThread::Cancel( bool isBlocking )

View File

@ -66,8 +66,11 @@ public:
virtual ~BaseCpuProvider() throw()
{
if( m_Reserved != 0 )
Console.Warning( "Cleanup miscount detected on CPU provider. Count=%d", m_Reserved );
try {
if( m_Reserved != 0 )
Console.Warning( "Cleanup miscount detected on CPU provider. Count=%d", m_Reserved );
}
DESTRUCTOR_CATCHALL
}
virtual const char* GetShortName() const=0;

View File

@ -24,12 +24,15 @@
BaseCompressThread::~BaseCompressThread() throw()
{
_parent::Cancel();
if( m_PendingSaveFlag )
{
wxGetApp().ClearPendingSave();
m_PendingSaveFlag = false;
try {
_parent::Cancel();
if( m_PendingSaveFlag )
{
wxGetApp().ClearPendingSave();
m_PendingSaveFlag = false;
}
}
DESTRUCTOR_CATCHALL
}
void BaseCompressThread::SetPendingSave()

View File

@ -89,7 +89,10 @@ AppCoreThread::AppCoreThread() : SysCoreThread()
AppCoreThread::~AppCoreThread() throw()
{
_parent::Cancel(); // use parent's, skips thread affinity check.
try {
_parent::Cancel(); // use parent's, skips thread affinity check.
}
DESTRUCTOR_CATCHALL
}
static void _Cancel()
@ -734,8 +737,11 @@ ScopedCoreThreadClose::ScopedCoreThreadClose()
ScopedCoreThreadClose::~ScopedCoreThreadClose() throw()
{
if( m_alreadyScoped ) return;
_parent::DoResume();
ScopedCore_IsFullyClosed = false;
try {
_parent::DoResume();
ScopedCore_IsFullyClosed = false;
}
DESTRUCTOR_CATCHALL
}
ScopedCoreThreadPause::ScopedCoreThreadPause( BaseSysExecEvent_ScopedCore* abuse_me )
@ -761,8 +767,11 @@ ScopedCoreThreadPause::ScopedCoreThreadPause( BaseSysExecEvent_ScopedCore* abuse
ScopedCoreThreadPause::~ScopedCoreThreadPause() throw()
{
if( m_alreadyScoped ) return;
_parent::DoResume();
ScopedCore_IsPaused = false;
try {
_parent::DoResume();
ScopedCore_IsPaused = false;
}
DESTRUCTOR_CATCHALL
}
ScopedCoreThreadPopup::ScopedCoreThreadPopup()

View File

@ -48,7 +48,10 @@ protected:
public:
AppGameDatabase() {}
virtual ~AppGameDatabase() throw() {
Console.WriteLn( "(GameDB) Unloading..." );
try {
Console.WriteLn( "(GameDB) Unloading..." );
}
DESTRUCTOR_CATCHALL
}
AppGameDatabase& LoadFromFile(const wxString& file = Path::Combine( PathDefs::GetProgramDataDir(), wxFileName(L"GameIndex.dbf") ), const wxString& key = L"Serial" );

View File

@ -374,7 +374,10 @@ public:
virtual ~GameDatabaseLoaderThread() throw()
{
_parent::Cancel();
try {
_parent::Cancel();
}
DESTRUCTOR_CATCHALL
}
protected:

View File

@ -163,7 +163,10 @@ ConsoleLogFrame::ColorArray::ColorArray( int fontsize )
ConsoleLogFrame::ColorArray::~ColorArray() throw()
{
Cleanup();
try {
Cleanup();
}
DESTRUCTOR_CATCHALL
}
void ConsoleLogFrame::ColorArray::Create( int fontsize )

View File

@ -544,12 +544,15 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
MainEmuFrame::~MainEmuFrame() throw()
{
if( m_RestartEmuOnDelete )
{
sApp.SetExitOnFrameDelete( false );
sApp.PostAppMethod( &Pcsx2App::DetectCpuAndUserMode );
sApp.WipeUserModeSettings();
try {
if( m_RestartEmuOnDelete )
{
sApp.SetExitOnFrameDelete( false );
sApp.PostAppMethod( &Pcsx2App::DetectCpuAndUserMode );
sApp.WipeUserModeSettings();
}
}
DESTRUCTOR_CATCHALL
}
void MainEmuFrame::DoGiveHelp(const wxString& text, bool show)

View File

@ -561,7 +561,10 @@ namespace Panels
public:
virtual ~EnumThread() throw()
{
pxThread::Cancel();
try {
pxThread::Cancel();
}
DESTRUCTOR_CATCHALL
}
EnumThread( PluginSelectorPanel& master );