From 92bb849e7ca1c301b64f5b51262c1246275e3f36 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Wed, 27 Jan 2016 17:50:51 +0000 Subject: [PATCH] Use unique_ptr instead of ScopedPtr for exceptions --- common/include/Utilities/Exceptions.h | 4 ++-- common/src/Utilities/wxAppWithHelpers.cpp | 4 ++-- pcsx2/System.cpp | 16 ++++++++-------- pcsx2/System.h | 4 ++-- pcsx2/x86/ix86-32/iR5900-32.cpp | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/common/include/Utilities/Exceptions.h b/common/include/Utilities/Exceptions.h index 635564e336..9eb3b83a1a 100644 --- a/common/include/Utilities/Exceptions.h +++ b/common/include/Utilities/Exceptions.h @@ -16,7 +16,7 @@ #pragma once #include "Assertions.h" -#include "ScopedPtr.h" +#include // 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 ScopedExcept; + typedef std::unique_ptr ScopedExcept; // -------------------------------------------------------------------------------------- // Ps2Generic Exception diff --git a/common/src/Utilities/wxAppWithHelpers.cpp b/common/src/Utilities/wxAppWithHelpers.cpp index e86e9edf31..c231a6a2db 100644 --- a/common/src/Utilities/wxAppWithHelpers.cpp +++ b/common/src/Utilities/wxAppWithHelpers.cpp @@ -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 ) { diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 62fc32d8d2..42572ece47 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -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 diff --git a/pcsx2/System.h b/pcsx2/System.h index 75c855d20a..2071527791 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -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; diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 4648ac08a6..6093792147 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -641,9 +641,9 @@ void recStep() #if !PCSX2_SEH # define SETJMP_CODE(x) x - static jmp_buf m_SetJmp_StateCheck; - static ScopedPtr m_cpuException; - static ScopedExcept m_Exception; + static jmp_buf m_SetJmp_StateCheck; + static std::unique_ptr m_cpuException; + static ScopedExcept m_Exception; #else # define SETJMP_CODE(x) #endif @@ -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(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 }