Use unique_ptr instead of ScopedPtr for exceptions

This commit is contained in:
Jonathan Li 2016-01-27 17:50:51 +00:00
parent 115b14bc94
commit 92bb849e7c
5 changed files with 19 additions and 19 deletions

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include "Assertions.h" #include "Assertions.h"
#include "ScopedPtr.h" #include <memory>
// Because wxTrap isn't available on Linux builds of wxWidgets (non-Debug, typically) // Because wxTrap isn't available on Linux builds of wxWidgets (non-Debug, typically)
void pxTrap(); void pxTrap();
@ -108,7 +108,7 @@ namespace Exception
virtual BaseException* Clone() const=0; virtual BaseException* Clone() const=0;
}; };
typedef ScopedPtr<BaseException> ScopedExcept; typedef std::unique_ptr<BaseException> ScopedExcept;
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// Ps2Generic Exception // Ps2Generic Exception

View File

@ -55,14 +55,14 @@ void BaseDeletableObject::DoDeletion()
void SynchronousActionState::SetException( const BaseException& ex ) void SynchronousActionState::SetException( const BaseException& ex )
{ {
m_exception = ex.Clone(); m_exception = ScopedExcept(ex.Clone());
} }
void SynchronousActionState::SetException( BaseException* ex ) void SynchronousActionState::SetException( BaseException* ex )
{ {
if( !m_posted ) if( !m_posted )
{ {
m_exception = ex; m_exception = ScopedExcept(ex);
} }
else if( wxTheApp ) else if( wxTheApp )
{ {

View File

@ -325,13 +325,13 @@ CpuInitializer< CpuType >::CpuInitializer()
{ {
Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() ); Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() );
MyCpu = NULL; MyCpu = NULL;
ExThrown = ex.Clone(); ExThrown = ScopedExcept(ex.Clone());
} }
catch( std::runtime_error& ex ) catch( std::runtime_error& ex )
{ {
Console.Error( L"CPU provider error (STL Exception)\n\tDetails:" + fromUTF8( ex.what() ) ); Console.Error( L"CPU provider error (STL Exception)\n\tDetails:" + fromUTF8( ex.what() ) );
MyCpu = NULL; MyCpu = NULL;
ExThrown = new Exception::RuntimeError(ex); ExThrown = ScopedExcept(new Exception::RuntimeError(ex));
} }
} }
@ -492,7 +492,7 @@ SysCpuProviderPack::SysCpuProviderPack()
} }
catch( Exception::RuntimeError& ex ) catch( Exception::RuntimeError& ex )
{ {
m_RecExceptionEE = ex.Clone(); m_RecExceptionEE = ScopedExcept(ex.Clone());
Console.Error( L"EE Recompiler Reservation Failed:\n" + ex.FormatDiagnosticMessage() ); Console.Error( L"EE Recompiler Reservation Failed:\n" + ex.FormatDiagnosticMessage() );
recCpu.Shutdown(); recCpu.Shutdown();
} }
@ -502,7 +502,7 @@ SysCpuProviderPack::SysCpuProviderPack()
} }
catch( Exception::RuntimeError& ex ) catch( Exception::RuntimeError& ex )
{ {
m_RecExceptionIOP = ex.Clone(); m_RecExceptionIOP = ScopedExcept(ex.Clone());
Console.Error( L"IOP Recompiler Reservation Failed:\n" + ex.FormatDiagnosticMessage() ); Console.Error( L"IOP Recompiler Reservation Failed:\n" + ex.FormatDiagnosticMessage() );
psxRec.Shutdown(); psxRec.Shutdown();
} }
@ -518,14 +518,14 @@ SysCpuProviderPack::SysCpuProviderPack()
bool SysCpuProviderPack::IsRecAvailable_MicroVU0() const { return CpuProviders->microVU0.IsAvailable(); } bool SysCpuProviderPack::IsRecAvailable_MicroVU0() const { return CpuProviders->microVU0.IsAvailable(); }
bool SysCpuProviderPack::IsRecAvailable_MicroVU1() const { return CpuProviders->microVU1.IsAvailable(); } bool SysCpuProviderPack::IsRecAvailable_MicroVU1() const { return CpuProviders->microVU1.IsAvailable(); }
BaseException* SysCpuProviderPack::GetException_MicroVU0() const { return CpuProviders->microVU0.ExThrown; } BaseException* SysCpuProviderPack::GetException_MicroVU0() const { return CpuProviders->microVU0.ExThrown.get(); }
BaseException* SysCpuProviderPack::GetException_MicroVU1() const { return CpuProviders->microVU1.ExThrown; } BaseException* SysCpuProviderPack::GetException_MicroVU1() const { return CpuProviders->microVU1.ExThrown.get(); }
#ifndef DISABLE_SVU #ifndef DISABLE_SVU
bool SysCpuProviderPack::IsRecAvailable_SuperVU0() const { return CpuProviders->superVU0.IsAvailable(); } bool SysCpuProviderPack::IsRecAvailable_SuperVU0() const { return CpuProviders->superVU0.IsAvailable(); }
bool SysCpuProviderPack::IsRecAvailable_SuperVU1() const { return CpuProviders->superVU1.IsAvailable(); } bool SysCpuProviderPack::IsRecAvailable_SuperVU1() const { return CpuProviders->superVU1.IsAvailable(); }
BaseException* SysCpuProviderPack::GetException_SuperVU0() const { return CpuProviders->superVU0.ExThrown; } BaseException* SysCpuProviderPack::GetException_SuperVU0() const { return CpuProviders->superVU0.ExThrown.get(); }
BaseException* SysCpuProviderPack::GetException_SuperVU1() const { return CpuProviders->superVU1.ExThrown; } BaseException* SysCpuProviderPack::GetException_SuperVU1() const { return CpuProviders->superVU1.ExThrown.get(); }
#endif #endif

View File

@ -150,8 +150,8 @@ public:
bool IsRecAvailable_EE() const { return !m_RecExceptionEE; } bool IsRecAvailable_EE() const { return !m_RecExceptionEE; }
bool IsRecAvailable_IOP() const { return !m_RecExceptionIOP; } bool IsRecAvailable_IOP() const { return !m_RecExceptionIOP; }
BaseException* GetException_EE() const { return m_RecExceptionEE; } BaseException* GetException_EE() const { return m_RecExceptionEE.get(); }
BaseException* GetException_IOP() const { return m_RecExceptionIOP; } BaseException* GetException_IOP() const { return m_RecExceptionIOP.get(); }
bool IsRecAvailable_MicroVU0() const; bool IsRecAvailable_MicroVU0() const;
bool IsRecAvailable_MicroVU1() const; bool IsRecAvailable_MicroVU1() const;

View File

@ -641,9 +641,9 @@ void recStep()
#if !PCSX2_SEH #if !PCSX2_SEH
# define SETJMP_CODE(x) x # define SETJMP_CODE(x) x
static jmp_buf m_SetJmp_StateCheck; static jmp_buf m_SetJmp_StateCheck;
static ScopedPtr<BaseR5900Exception> m_cpuException; static std::unique_ptr<BaseR5900Exception> m_cpuException;
static ScopedExcept m_Exception; static ScopedExcept m_Exception;
#else #else
# define SETJMP_CODE(x) # define SETJMP_CODE(x)
#endif #endif
@ -2045,7 +2045,7 @@ static void recThrowException( const BaseR5900Exception& ex )
ex.Rethrow(); ex.Rethrow();
#else #else
if (!eeCpuExecuting) ex.Rethrow(); if (!eeCpuExecuting) ex.Rethrow();
m_cpuException = ex.Clone(); m_cpuException = std::unique_ptr<BaseR5900Exception>(ex.Clone());
recExitExecution(); recExitExecution();
#endif #endif
} }
@ -2056,7 +2056,7 @@ static void recThrowException( const BaseException& ex )
ex.Rethrow(); ex.Rethrow();
#else #else
if (!eeCpuExecuting) ex.Rethrow(); if (!eeCpuExecuting) ex.Rethrow();
m_Exception = ex.Clone(); m_Exception = ScopedExcept(ex.Clone());
recExitExecution(); recExitExecution();
#endif #endif
} }