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

View File

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

View File

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

View File

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

View File

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