Merge pull request #1173 from turtleli/replace-scoped-ptr

Replace ScopedPtr with unique_ptr
This commit is contained in:
Gregory Hainaut 2016-02-13 13:49:18 +01:00
commit 38b9198dba
57 changed files with 262 additions and 477 deletions

View File

@ -182,7 +182,6 @@
<ClInclude Include="..\..\include\Utilities\pxStaticText.h" />
<ClInclude Include="..\..\include\Utilities\RedtapeWindows.h" />
<ClInclude Include="..\..\include\Utilities\SafeArray.h" />
<ClInclude Include="..\..\include\Utilities\ScopedPtr.h" />
<ClInclude Include="..\..\include\Utilities\StringHelpers.h" />
<ClInclude Include="..\..\include\Utilities\win_memzero.h" />
<ClInclude Include="..\..\include\Utilities\wxAppWithHelpers.h" />

View File

@ -201,9 +201,6 @@
<ClInclude Include="..\..\include\Utilities\SafeArray.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\Utilities\ScopedPtr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\Utilities\StringHelpers.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -199,6 +199,7 @@ public:
#include <vector>
#include <list>
#include <algorithm>
#include <memory>
#include "Pcsx2Defs.h"
@ -245,5 +246,4 @@ extern wxString fromAscii( const char* src );
#include "Utilities/Assertions.h"
#include "Utilities/Exceptions.h"
#include "Utilities/ScopedPtr.h"
#include "Utilities/ScopedAlloc.h"

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

@ -1,231 +0,0 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "Assertions.h"
// --------------------------------------------------------------------------------------
// ScopedPtr
// --------------------------------------------------------------------------------------
template< typename T >
class ScopedPtr
{
DeclareNoncopyableObject(ScopedPtr);
protected:
T* m_ptr;
public:
typedef T element_type;
wxEXPLICIT ScopedPtr(T * ptr = NULL)
{
m_ptr = ptr;
}
~ScopedPtr() throw() { Delete(); }
ScopedPtr& Reassign(T * ptr = NULL)
{
if ( ptr != m_ptr )
{
Delete();
m_ptr = ptr;
}
return *this;
}
ScopedPtr& Delete() throw()
{
// Thread-safe deletion: Set the pointer to NULL first, and then issue
// the deletion. This allows pending Application messages that might be
// dependent on the current object to nullify their actions.
T* deleteme = m_ptr;
m_ptr = NULL;
delete deleteme;
return *this;
}
// Removes the pointer from scoped management, but does not delete!
T *DetachPtr()
{
T *ptr = m_ptr;
m_ptr = NULL;
return ptr;
}
// Returns the managed pointer. Can return NULL as a valid result if the ScopedPtr
// has no object in management.
T* GetPtr() const
{
return m_ptr;
}
// Swaps two pointers between likened scoped pointer types. This method is useful for
// situations where you need to create a new object with a complex initializer that can
// throw exceptions -- and thusly should be disposed if the initialization fails. Use
// SwapPtr to assign the new object into the persistent ScopedPtr instance, and have
// the old object assigned to the local-scope ScopedPtr instance.
void SwapPtr(ScopedPtr& other)
{
T * const tmp = other.m_ptr;
other.m_ptr = m_ptr;
m_ptr = tmp;
}
// ----------------------------------------------------------------------------
// ScopedPtr Operators
// ----------------------------------------------------------------------------
// I've decided to use the ATL's approach to pointer validity tests, opposed to
// the wx/boost approach (which uses some bizarre member method pointer crap, and can't
// allow the T* implicit casting.
bool operator!() const throw()
{
return m_ptr == NULL;
}
operator T*() const
{
return m_ptr;
}
// Equality
bool operator==(T* pT) const throw()
{
return m_ptr == pT;
}
// Inequality
bool operator!=(T* pT) const throw()
{
return !operator==(pT);
}
// Convenient assignment operator. ScopedPtr = NULL will issue an automatic deletion
// of the managed pointer.
ScopedPtr& operator=( T* src )
{
return Reassign( src );
}
// Dereference operator, returns a handle to the managed pointer.
// Generates a debug assertion if the object is NULL!
T& operator*() const
{
pxAssert(m_ptr != NULL);
return *m_ptr;
}
T* operator->() const
{
pxAssert(m_ptr != NULL);
return m_ptr;
}
};
// --------------------------------------------------------------------------------------
// pxObjPtr -- fancified version of wxScopedPtr
// --------------------------------------------------------------------------------------
// This class is a non-null scoped pointer container. What that means is that the object
// always resets itself to a valid "placebo" function rather than NULL, such that methods
// can be invoked safely without fear of NULL pointer exceptions. This system is useful
// for objects where most or all public methods can fail silently, and still allow program
// execution flow to continue.
//
// It also implements basic scoped pointer behavior: when the pxObjPtr class is deleted,
// it will automatically delete the pointer in its posession, if the pointer is valid.
//
// Notes:
// * This class intentionally does not implement the "release" API, because it doesn't
// really make sense within the context of a non-nullable pointer specification.
//
template< typename T, T& DefaultStaticInst >
class pxObjPtr
{
DeclareNoncopyableObject(pxObjPtr);
protected:
T * m_ptr;
public:
typedef T element_type;
explicit pxObjPtr(T * ptr = &DefaultStaticInst) : m_ptr(ptr) { }
bool IsEmpty() const
{
return m_ptr != &DefaultStaticInst;
}
~pxObjPtr()
{
if( !IsEmpty() ) delete m_ptr;
m_ptr = NULL;
}
// test for pointer validity: defining conversion to unspecified_bool_type
// and not more obvious bool to avoid implicit conversions to integer types
typedef T *(pxObjPtr<T,DefaultStaticInst>::*unspecified_bool_type)() const;
operator unspecified_bool_type() const
{
return ( !IsEmpty() ) ? &ScopedPtr<T>::get : NULL;
}
void reset(T * ptr = &DefaultStaticInst)
{
if ( ptr != m_ptr )
{
if( !IsEmpty() )
delete m_ptr;
m_ptr = ptr;
}
}
T& operator*() const
{
pxAssert(m_ptr != NULL);
return *m_ptr;
}
T* operator->() const
{
pxAssert(m_ptr != NULL);
return m_ptr;
}
T* get() const
{
pxAssert(m_ptr != NULL);
return m_ptr;
}
void swap(pxObjPtr& other)
{
// Neither pointer in either container should ever be NULL...
pxAssert(m_ptr != NULL);
pxAssert(other.m_ptr != NULL);
T * const tmp = other.m_ptr;
other.m_ptr = m_ptr;
m_ptr = tmp;
}
};

View File

@ -24,7 +24,6 @@
#endif
#include "Pcsx2Defs.h"
#include "ScopedPtr.h"
#include "TraceLog.h"
#undef Yield // release the burden of windows.h global namespace spam.

View File

@ -16,6 +16,7 @@
#pragma once
#include "wx/filefn.h"
#include <memory>
// --------------------------------------------------------------------------------------
// pxStreamBase
@ -55,19 +56,19 @@ class pxOutputStream : public pxStreamBase
DeclareNoncopyableObject(pxOutputStream);
protected:
ScopedPtr<wxOutputStream> m_stream_out;
std::unique_ptr<wxOutputStream> m_stream_out;
public:
pxOutputStream(const wxString& filename, ScopedPtr<wxOutputStream>& output);
pxOutputStream(const wxString& filename, std::unique_ptr<wxOutputStream>& output);
pxOutputStream(const wxString& filename, wxOutputStream* output);
virtual ~pxOutputStream() throw() {}
virtual void Write( const void* data, size_t size );
void SetStream( const wxString& filename, ScopedPtr<wxOutputStream>& stream );
void SetStream( const wxString& filename, std::unique_ptr<wxOutputStream>& stream );
void SetStream( const wxString& filename, wxOutputStream* stream );
void Close() { m_stream_out.Delete(); }
void Close() { m_stream_out = nullptr; }
virtual wxStreamBase* GetWxStreamBase() const;
@ -89,19 +90,19 @@ class pxInputStream : public pxStreamBase
DeclareNoncopyableObject(pxInputStream);
protected:
ScopedPtr<wxInputStream> m_stream_in;
std::unique_ptr<wxInputStream> m_stream_in;
public:
pxInputStream(const wxString& filename, ScopedPtr<wxInputStream>& input);
pxInputStream(const wxString& filename, std::unique_ptr<wxInputStream>& input);
pxInputStream(const wxString& filename, wxInputStream* input);
virtual ~pxInputStream() throw() {}
virtual void Read( void* dest, size_t size );
void SetStream( const wxString& filename, ScopedPtr<wxInputStream>& stream );
void SetStream( const wxString& filename, std::unique_ptr<wxInputStream>& stream );
void SetStream( const wxString& filename, wxInputStream* stream );
void Close() { m_stream_in.Delete(); }
void Close() { m_stream_in = nullptr; }
virtual wxStreamBase* GetWxStreamBase() const;

View File

@ -28,7 +28,7 @@
#if wxUSE_GUI
#include "Dependencies.h"
#include "ScopedPtr.h"
#include <memory>
#include <stack>
#include <wx/wx.h>
@ -741,7 +741,7 @@ public:
class MoreStockCursors
{
protected:
ScopedPtr<wxCursor> m_arrowWait;
std::unique_ptr<wxCursor> m_arrowWait;
public:
MoreStockCursors() { }

View File

@ -101,7 +101,6 @@ set(UtilitiesHeaders
../../include/Utilities/RedtapeWindows.h
../../include/Utilities/SafeArray.h
../../include/Utilities/ScopedAlloc.h
../../include/Utilities/ScopedPtr.h
../../include/Utilities/ScopedPtrMT.h
../../include/Utilities/StringHelpers.h
../../include/Utilities/Threading.h

View File

@ -47,9 +47,9 @@ wxFileOffset pxStreamBase::Length() const
// Interface for reading data from a gzip stream.
//
pxInputStream::pxInputStream(const wxString& filename, ScopedPtr<wxInputStream>& input)
pxInputStream::pxInputStream(const wxString& filename, std::unique_ptr<wxInputStream>& input)
: pxStreamBase( filename )
, m_stream_in( input.DetachPtr() )
, m_stream_in( std::move(input) )
{
}
@ -59,7 +59,7 @@ pxInputStream::pxInputStream(const wxString& filename, wxInputStream* input)
{
}
wxStreamBase* pxInputStream::GetWxStreamBase() const { return m_stream_in.GetPtr(); }
wxStreamBase* pxInputStream::GetWxStreamBase() const { return m_stream_in.get(); }
wxFileOffset pxInputStream::Tell() const
{
@ -71,16 +71,16 @@ wxFileOffset pxInputStream::Seek( wxFileOffset ofs, wxSeekMode mode )
return m_stream_in->SeekI(ofs, mode);
}
void pxInputStream::SetStream( const wxString& filename, ScopedPtr<wxInputStream>& stream )
void pxInputStream::SetStream( const wxString& filename, std::unique_ptr<wxInputStream>& stream )
{
m_filename = filename;
m_stream_in = stream.DetachPtr();
m_stream_in = std::move(stream);
}
void pxInputStream::SetStream( const wxString& filename, wxInputStream* stream )
{
m_filename = filename;
m_stream_in = stream;
m_stream_in = std::unique_ptr<wxInputStream>(stream);
}
void pxInputStream::Read( void* dest, size_t size )
@ -108,9 +108,9 @@ void pxInputStream::Read( void* dest, size_t size )
// --------------------------------------------------------------------------------------
// pxOutputStream
// --------------------------------------------------------------------------------------
pxOutputStream::pxOutputStream(const wxString& filename, ScopedPtr<wxOutputStream>& output)
pxOutputStream::pxOutputStream(const wxString& filename, std::unique_ptr<wxOutputStream>& output)
: pxStreamBase( filename )
, m_stream_out( output.DetachPtr() )
, m_stream_out( std::move(output) )
{
}
@ -121,7 +121,7 @@ pxOutputStream::pxOutputStream(const wxString& filename, wxOutputStream* output)
{
}
wxStreamBase* pxOutputStream::GetWxStreamBase() const { return m_stream_out.GetPtr(); }
wxStreamBase* pxOutputStream::GetWxStreamBase() const { return m_stream_out.get(); }
wxFileOffset pxOutputStream::Tell() const
{
@ -133,16 +133,16 @@ wxFileOffset pxOutputStream::Seek( wxFileOffset ofs, wxSeekMode mode )
return m_stream_out->SeekO( ofs, mode );
}
void pxOutputStream::SetStream( const wxString& filename, ScopedPtr<wxOutputStream>& stream )
void pxOutputStream::SetStream( const wxString& filename, std::unique_ptr<wxOutputStream>& stream )
{
m_filename = filename;
m_stream_out = stream.DetachPtr();
m_stream_out = std::move(stream);
}
void pxOutputStream::SetStream( const wxString& filename, wxOutputStream* stream )
{
m_filename = filename;
m_stream_out = stream;
m_stream_out = std::unique_ptr<wxOutputStream>(stream);
}

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 )
{
@ -387,7 +387,7 @@ bool wxAppWithHelpers::ProcessEvent( wxEvent& evt )
bool wxAppWithHelpers::ProcessEvent( wxEvent* evt )
{
AffinityAssert_AllowFrom_MainUI();
ScopedPtr<wxEvent> deleteMe( evt );
std::unique_ptr<wxEvent> deleteMe( evt );
return _parent::ProcessEvent( *deleteMe );
}
@ -409,7 +409,7 @@ bool wxAppWithHelpers::ProcessEvent( pxActionEvent* evt )
{
if( wxThread::IsMain() )
{
ScopedPtr<wxEvent> deleteMe( evt );
std::unique_ptr<wxEvent> deleteMe( evt );
return _parent::ProcessEvent( *deleteMe );
}
else
@ -513,7 +513,7 @@ void wxAppWithHelpers::IdleEventDispatcher( const wxChar* action )
while( node = m_IdleEventQueue.begin(), node != m_IdleEventQueue.end() )
{
ScopedPtr<wxEvent> deleteMe(*node);
std::unique_ptr<wxEvent> deleteMe(*node);
m_IdleEventQueue.erase( node );
lock.Release();
@ -524,8 +524,8 @@ void wxAppWithHelpers::IdleEventDispatcher( const wxChar* action )
// thread to crash. So we disallow deletions when those waits are in action, and continue
// to postpone the deletion of the thread until such time that it is safe.
pxThreadLog.Write( ((pxThread*)((wxCommandEvent*)deleteMe.GetPtr())->GetClientData())->GetName(), L"Deletion postponed due to mutex or semaphore dependency." );
postponed.push_back(deleteMe.DetachPtr());
pxThreadLog.Write( ((pxThread*)((wxCommandEvent*)deleteMe.get())->GetClientData())->GetName(), L"Deletion postponed due to mutex or semaphore dependency." );
postponed.push_back(deleteMe.release());
}
else
{
@ -680,7 +680,7 @@ wxAppTraits* wxAppWithHelpers::CreateTraits()
// (thus we have a fairly automatic threaded exception system!)
void wxAppWithHelpers::OnDeleteThread( wxCommandEvent& evt )
{
ScopedPtr<pxThread> thr( (pxThread*)evt.GetClientData() );
std::unique_ptr<pxThread> thr( (pxThread*)evt.GetClientData() );
if( !thr )
{
pxThreadLog.Write( L"null", L"OnDeleteThread: NULL thread object received (and ignored)." );

View File

@ -562,7 +562,7 @@ void ScopedBusyCursor::SetManualBusyCursor( BusyCursorType busytype )
const wxCursor& MoreStockCursors::GetArrowWait()
{
if( !m_arrowWait )
m_arrowWait = new wxCursor( wxCURSOR_ARROWWAIT );
m_arrowWait = std::unique_ptr<wxCursor>(new wxCursor( wxCURSOR_ARROWWAIT ));
return *m_arrowWait;
}

View File

@ -17,6 +17,7 @@
#include "IopCommon.h"
#include "AppConfig.h"
#include <memory>
#include <ctype.h>
#include <wx/datetime.h>
@ -341,8 +342,6 @@ static __fi ElfObject* loadElf( const wxString filename )
static __fi void _reloadElfInfo(wxString elfpath)
{
ScopedPtr<ElfObject> elfptr;
// Now's a good time to reload the ELF info...
ScopedLock locker( Mutex_NewDiskCB );
@ -357,7 +356,7 @@ static __fi void _reloadElfInfo(wxString elfpath)
if (fname.Matches(L"????_???.??*"))
DiscSerial = fname(0,4) + L"-" + fname(5,3) + fname(9,2);
elfptr = loadElf(elfpath);
std::unique_ptr<ElfObject> elfptr(loadElf(elfpath));
elfptr->loadHeaders();
ElfCRC = elfptr->getCRC();

View File

@ -18,6 +18,7 @@
#include "IsoFS.h"
#include "IsoFile.h"
#include <memory>
//////////////////////////////////////////////////////////////////////////
// IsoDirectory
@ -172,7 +173,7 @@ IsoFileDescriptor IsoDirectory::FindFile(const wxString& filePath) const
wxFileName parts( filePath, wxPATH_DOS );
IsoFileDescriptor info;
const IsoDirectory* dir = this;
ScopedPtr<IsoDirectory> deleteme;
std::unique_ptr<IsoDirectory> deleteme;
// walk through path ("." and ".." entries are in the directories themselves, so even if the
// path included . and/or .., it still works)
@ -182,7 +183,8 @@ IsoFileDescriptor IsoDirectory::FindFile(const wxString& filePath) const
info = dir->GetEntry(parts.GetDirs()[i]);
if(info.IsFile()) throw Exception::FileNotFound( filePath );
dir = deleteme = new IsoDirectory(internalReader, info);
deleteme.reset(new IsoDirectory(internalReader, info));
dir = deleteme.get();
}
if( !parts.GetFullName().IsEmpty() )

View File

@ -117,7 +117,7 @@ protected:
std::unique_ptr<u32[]> m_dtable;
int m_dtablesize;
ScopedPtr<wxFileOutputStream> m_outstream;
std::unique_ptr<wxFileOutputStream> m_outstream;
public:
OutputIsoFile();

View File

@ -62,7 +62,7 @@ void OutputIsoFile::Create(const wxString& filename, int version)
m_blockofs = 24;
m_blocksize = 2048;
m_outstream = new wxFileOutputStream( m_filename );
m_outstream = std::unique_ptr<wxFileOutputStream>(new wxFileOutputStream(m_filename));
pxStream_OpenCheck( *m_outstream, m_filename, L"writing" );
Console.WriteLn("isoFile create ok: %s ", WX_STR(m_filename));

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include <list>
#include <memory>
#include "GS.h"
@ -24,7 +25,7 @@
// GS Playback
int g_SaveGSStream = 0; // save GS stream; 1 - prepare, 2 - save
int g_nLeftGSFrames = 0; // when saving, number of frames left
static ScopedPtr<memSavingState> g_fGSSave;
static std::unique_ptr<memSavingState> g_fGSSave;
// fixme - need to take this concept and make it MTGS friendly.
#ifdef _STGS_GSSTATE_CODE
@ -77,7 +78,7 @@ __fi void GSVSYNC(void) {
Console.WriteLn( L"\t%s", file.c_str() );
SafeArray<u8> buf;
g_fGSSave = new memSavingState( buf );
g_fGSSave = std::unique_ptr<memSavingState>(new memSavingState( buf ));
g_SaveGSStream = 1;
g_nLeftGSFrames = 2;

View File

@ -18,12 +18,12 @@
#include <wx/dir.h>
#include <wx/file.h>
#include <memory>
#include "GS.h"
#include "Gif.h"
#include "CDVD/CDVDisoReader.h"
#include "Utilities/ScopedPtr.h"
#include "Utilities/pxStreams.h"
#include "svnrev.h"
@ -991,7 +991,7 @@ void SysCorePlugins::Load( PluginsEnum_t pid, const wxString& srcfile )
ScopedLock lock( m_mtx_PluginStatus );
pxAssert( (uint)pid < PluginId_Count );
Console.Indent().WriteLn( L"Binding %4s: %s ", WX_STR(tbl_PluginInfo[pid].GetShortname()), WX_STR(srcfile) );
m_info[pid] = new PluginStatus_t( pid, srcfile );
m_info[pid] = std::unique_ptr<PluginStatus_t>(new PluginStatus_t(pid, srcfile));
}
void SysCorePlugins::Load( const wxString (&folders)[PluginId_Count] )
@ -1056,7 +1056,7 @@ void SysCorePlugins::Unload(PluginsEnum_t pid)
{
ScopedLock lock( m_mtx_PluginStatus );
pxAssert( (uint)pid < PluginId_Count );
m_info[pid].Delete();
m_info[pid] = nullptr;
}
void SysCorePlugins::Unload()

View File

@ -298,7 +298,7 @@ protected:
volatile u32 m_mcdOpen;
public: // hack until we unsuck plugins...
ScopedPtr<PluginStatus_t> m_info[PluginId_AllocCount];
std::unique_ptr<PluginStatus_t> m_info[PluginId_AllocCount];
public:
SysCorePlugins();

View File

@ -74,7 +74,6 @@ typedef int BOOL;
#include "Utilities/FixedPointTypes.h"
#include "Utilities/wxBaseTools.h"
#include "Utilities/ScopedPtr.h"
#include "Utilities/Path.h"
#include "Utilities/Console.h"
#include "Utilities/MemcpyFast.h"

View File

@ -291,8 +291,8 @@ template< typename CpuType >
class CpuInitializer
{
public:
ScopedPtr<CpuType> MyCpu;
ScopedExcept ExThrown;
std::unique_ptr<CpuType> MyCpu;
ScopedExcept ExThrown;
CpuInitializer();
virtual ~CpuInitializer() throw();
@ -302,8 +302,8 @@ public:
return !!MyCpu;
}
CpuType* GetPtr() { return MyCpu.GetPtr(); }
const CpuType* GetPtr() const { return MyCpu.GetPtr(); }
CpuType* GetPtr() { return MyCpu.get(); }
const CpuType* GetPtr() const { return MyCpu.get(); }
operator CpuType*() { return GetPtr(); }
operator const CpuType*() const { return GetPtr(); }
@ -318,20 +318,20 @@ template< typename CpuType >
CpuInitializer< CpuType >::CpuInitializer()
{
try {
MyCpu = new CpuType();
MyCpu = std::unique_ptr<CpuType>(new CpuType());
MyCpu->Reserve();
}
catch( Exception::RuntimeError& ex )
{
Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() );
MyCpu = NULL;
ExThrown = ex.Clone();
MyCpu = nullptr;
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);
MyCpu = nullptr;
ExThrown = ScopedExcept(new Exception::RuntimeError(ex));
}
}
@ -485,14 +485,14 @@ SysCpuProviderPack::SysCpuProviderPack()
Console.WriteLn( Color_StrongBlue, "Reserving memory for recompilers..." );
ConsoleIndentScope indent(1);
CpuProviders = new CpuInitializerSet();
CpuProviders = std::unique_ptr<CpuInitializerSet>(new CpuInitializerSet());
try {
recCpu.Reserve();
}
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

@ -135,7 +135,7 @@ protected:
ScopedExcept m_RecExceptionIOP;
public:
ScopedPtr<CpuInitializerSet> CpuProviders;
std::unique_ptr<CpuInitializerSet> CpuProviders;
SysCpuProviderPack();
virtual ~SysCpuProviderPack() throw();
@ -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

@ -79,8 +79,8 @@ class ArchiveEntryList
DeclareNoncopyableObject( ArchiveEntryList );
protected:
std::vector<ArchiveEntry> m_list;
ScopedPtr<ArchiveDataBuffer> m_data;
std::vector<ArchiveEntry> m_list;
std::unique_ptr<ArchiveDataBuffer> m_data;
public:
virtual ~ArchiveEntryList() throw() {}
@ -89,22 +89,21 @@ public:
ArchiveEntryList( ArchiveDataBuffer* data )
{
m_data = data;
}
ArchiveEntryList( ArchiveDataBuffer& data )
: m_data(&data)
{
m_data = &data;
}
const VmStateBuffer* GetBuffer() const
{
return m_data;
return m_data.get();
}
VmStateBuffer* GetBuffer()
{
return m_data;
return m_data.get();
}
u8* GetPtr( uint idx )

View File

@ -19,6 +19,7 @@
#include <wx/fileconf.h>
#include <wx/apptrait.h>
#include <memory>
#include "pxEventThread.h"
@ -241,12 +242,12 @@ class pxAppResources
public:
AppImageIds ImageId;
ScopedPtr<wxImageList> ConfigImages;
ScopedPtr<wxImageList> ToolbarImages;
ScopedPtr<wxIconBundle> IconBundle;
ScopedPtr<wxBitmap> Bitmap_Logo;
ScopedPtr<wxBitmap> ScreenshotBitmap;
ScopedPtr<AppGameDatabase> GameDB;
std::unique_ptr<wxImageList> ConfigImages;
std::unique_ptr<wxImageList> ToolbarImages;
std::unique_ptr<wxIconBundle> IconBundle;
std::unique_ptr<wxBitmap> Bitmap_Logo;
std::unique_ptr<wxBitmap> ScreenshotBitmap;
std::unique_ptr<AppGameDatabase> GameDB;
pxAppResources();
virtual ~pxAppResources() throw();
@ -469,28 +470,28 @@ protected:
public:
FramerateManager FpsManager;
ScopedPtr<CommandDictionary> GlobalCommands;
ScopedPtr<AcceleratorDictionary> GlobalAccels;
std::unique_ptr<CommandDictionary> GlobalCommands;
std::unique_ptr<AcceleratorDictionary> GlobalAccels;
StartupOptions Startup;
CommandlineOverrides Overrides;
ScopedPtr<wxTimer> m_timer_Termination;
std::unique_ptr<wxTimer> m_timer_Termination;
protected:
ScopedPtr<PipeRedirectionBase> m_StdoutRedirHandle;
ScopedPtr<PipeRedirectionBase> m_StderrRedirHandle;
std::unique_ptr<PipeRedirectionBase> m_StdoutRedirHandle;
std::unique_ptr<PipeRedirectionBase> m_StderrRedirHandle;
ScopedPtr<RecentIsoList> m_RecentIsoList;
ScopedPtr<pxAppResources> m_Resources;
std::unique_ptr<RecentIsoList> m_RecentIsoList;
std::unique_ptr<pxAppResources> m_Resources;
public:
// Executor Thread for complex VM/System tasks. This thread is used to execute such tasks
// in parallel to the main message pump, to allow the main pump to run without fear of
// blocked threads stalling the GUI.
ExecutorThread SysExecutorThread;
ScopedPtr<SysCpuProviderPack> m_CpuProviders;
ScopedPtr<SysMainMemory> m_VmReserve;
std::unique_ptr<SysCpuProviderPack> m_CpuProviders;
std::unique_ptr<SysMainMemory> m_VmReserve;
protected:
wxWindowID m_id_MainFrame;

View File

@ -24,6 +24,7 @@
#include <wx/stdpaths.h>
#include "DebugTools/Debug.h"
#include <memory>
//////////////////////////////////////////////////////////////////////////////////////////
// PathDefs Namespace -- contains default values for various pcsx2 path names and locations.
@ -1242,7 +1243,7 @@ static void LoadUiSettings()
ConLog_LoadSaveSettings( loader );
SysTraceLog_LoadSaveSettings( loader );
g_Conf = new AppConfig();
g_Conf = std::unique_ptr<AppConfig>(new AppConfig());
g_Conf->LoadSave( loader );
if( !wxFile::Exists( g_Conf->CurrentIso ) )
@ -1256,8 +1257,8 @@ static void LoadVmSettings()
// Load virtual machine options and apply some defaults overtop saved items, which
// are regulated by the PCSX2 UI.
ScopedPtr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniLoader vmloader( vmini );
std::unique_ptr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniLoader vmloader( vmini.get() );
g_Conf->EmuOptions.LoadSave( vmloader );
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->Framerate.NominalScalar;
@ -1293,8 +1294,8 @@ static void SaveUiSettings()
static void SaveVmSettings()
{
ScopedPtr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniSaver vmsaver( vmini );
std::unique_ptr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniSaver vmsaver( vmini.get() );
g_Conf->EmuOptions.LoadSave( vmsaver );
sApp.DispatchVmSettingsEvent( vmsaver );
@ -1302,15 +1303,15 @@ static void SaveVmSettings()
static void SaveRegSettings()
{
ScopedPtr<wxConfigBase> conf_install;
std::unique_ptr<wxConfigBase> conf_install;
if (InstallationMode == InstallMode_Portable) return;
// sApp. macro cannot be use because you need the return value of OpenInstallSettingsFile method
if( Pcsx2App* __app_ = (Pcsx2App*)wxApp::GetInstance() ) conf_install = (*__app_).OpenInstallSettingsFile();
if( Pcsx2App* __app_ = (Pcsx2App*)wxApp::GetInstance() ) conf_install = std::unique_ptr<wxConfigBase>((*__app_).OpenInstallSettingsFile());
conf_install->SetRecordDefaults(false);
App_SaveInstallSettings( conf_install );
App_SaveInstallSettings( conf_install.get() );
}
void AppSaveSettings()

View File

@ -18,6 +18,7 @@
#include "AppForwardDefs.h"
#include "PathDefs.h"
#include "CDVD/CDVDaccess.h"
#include <memory>
enum DocsModeType
{
@ -383,4 +384,4 @@ extern void RelocateLogfile();
extern void AppConfig_OnChangedSettingsFolder( bool overwrite = false );
extern wxConfigBase* GetAppConfig();
extern ScopedPtr<AppConfig> g_Conf;
extern std::unique_ptr<AppConfig> g_Conf;

View File

@ -416,14 +416,17 @@ protected:
// Public API / Interface
// --------------------------------------------------------------------------------------
int EnumeratePluginsInFolder( const wxDirName& searchpath, wxArrayString* dest )
int EnumeratePluginsInFolder(const wxDirName& searchpath, wxArrayString* dest)
{
if (!searchpath.Exists()) return 0;
ScopedPtr<wxArrayString> placebo;
std::unique_ptr<wxArrayString> placebo;
wxArrayString* realdest = dest;
if( realdest == NULL )
placebo = realdest = new wxArrayString(); // placebo is our /dev/null -- gets deleted when done
if (realdest == NULL)
{
placebo = std::unique_ptr<wxArrayString>(new wxArrayString());
realdest = placebo.get();
}
#ifdef __WXMSW__
// Windows pretty well has a strict "must end in .dll" rule.
@ -558,12 +561,13 @@ void SysExecEvent_SaveSinglePlugin::InvokeEvent()
if( CorePlugins.AreLoaded() )
{
ScopedPtr<VmStateBuffer> plugstore;
std::unique_ptr<VmStateBuffer> plugstore;
if( CoreThread.HasActiveMachine() )
{
Console.WriteLn( Color_Green, L"Suspending single plugin: " + tbl_PluginInfo[m_pid].GetShortname() );
memSavingState save( plugstore=new VmStateBuffer(L"StateCopy_SinglePlugin") );
plugstore = std::unique_ptr<VmStateBuffer>(new VmStateBuffer(L"StateCopy_SinglePlugin"));
memSavingState save( plugstore.get() );
GetCorePlugins().Freeze( m_pid, save );
}
@ -573,7 +577,7 @@ void SysExecEvent_SaveSinglePlugin::InvokeEvent()
if( plugstore )
{
Console.WriteLn( Color_Green, L"Recovering single plugin: " + tbl_PluginInfo[m_pid].GetShortname() );
memLoadingState load( plugstore );
memLoadingState load( plugstore.get() );
GetCorePlugins().Freeze( m_pid, load );
// GS plugin suspend / resume hack. Removed in r4363, hopefully never to return :p
//GetCorePlugins().Close( m_pid ); // hack for stupid GS plugins.

View File

@ -702,13 +702,13 @@ void BaseScopedCoreThread::DoResume()
// handle the code directly).
bool BaseScopedCoreThread::PostToSysExec( BaseSysExecEvent_ScopedCore* msg )
{
ScopedPtr<BaseSysExecEvent_ScopedCore> smsg( msg );
std::unique_ptr<BaseSysExecEvent_ScopedCore> smsg( msg );
if( !smsg || GetSysExecutorThread().IsSelf()) return false;
msg->SetSyncState(m_sync);
msg->SetResumeStates(m_sync_resume, m_mtx_resume);
GetSysExecutorThread().PostEvent( smsg.DetachPtr() );
GetSysExecutorThread().PostEvent( smsg.release() );
m_sync.WaitForResult();
m_sync.RethrowException();
@ -781,9 +781,9 @@ ScopedCoreThreadPopup::ScopedCoreThreadPopup()
// is maximized or fullscreen.
if( !GSopen2 )
m_scoped_core = new ScopedCoreThreadClose();
m_scoped_core = std::unique_ptr<BaseScopedCoreThread>(new ScopedCoreThreadClose());
else
m_scoped_core = new ScopedCoreThreadPause();
m_scoped_core = std::unique_ptr<BaseScopedCoreThread>(new ScopedCoreThreadPause());
};
void ScopedCoreThreadPopup::AllowResume()

View File

@ -237,7 +237,7 @@ public:
struct ScopedCoreThreadPopup : public IScopedCoreThread
{
protected:
ScopedPtr<BaseScopedCoreThread> m_scoped_core;
std::unique_ptr<BaseScopedCoreThread> m_scoped_core;
public:
ScopedCoreThreadPopup();

View File

@ -229,10 +229,10 @@ AppGameDatabase* Pcsx2App::GetGameDatabase()
ScopedLock lock( m_mtx_LoadingGameDB );
if( !res.GameDB )
{
res.GameDB = new AppGameDatabase();
res.GameDB = std::unique_ptr<AppGameDatabase>(new AppGameDatabase());
res.GameDB->LoadFromFile();
}
return res.GameDB;
return res.GameDB.get();
}
IGameDatabase* AppHost_GetGameDatabase()

View File

@ -29,6 +29,7 @@
#include <wx/cmdline.h>
#include <wx/intl.h>
#include <wx/stdpaths.h>
#include <memory>
using namespace pxSizerFlags;
@ -128,7 +129,7 @@ void Pcsx2App::AllocateCoreStuffs()
// FIXME : Some or all of SysCpuProviderPack should be run from the SysExecutor thread,
// so that the thread is safely blocked from being able to start emulation.
m_CpuProviders = new SysCpuProviderPack();
m_CpuProviders = std::unique_ptr<SysCpuProviderPack>(new SysCpuProviderPack());
if( m_CpuProviders->HadSomeFailures( g_Conf->EmuOptions.Cpu.Recompiler ) )
{
@ -422,7 +423,7 @@ bool Pcsx2App::OnInit()
pxDoAssert = AppDoAssert;
pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse;
g_Conf = new AppConfig();
g_Conf = std::unique_ptr<AppConfig>(new AppConfig());
wxInitAllImageHandlers();
Console.WriteLn("Applying operating system default language...");
@ -472,7 +473,7 @@ bool Pcsx2App::OnInit()
// PCSX2 has a lot of event handling logistics, so we *cannot* depend on wxWidgets automatic event
// loop termination code. We have a much safer system in place that continues to process messages
// until all "important" threads are closed out -- not just until the main frame is closed(-ish).
m_timer_Termination = new wxTimer( this, wxID_ANY );
m_timer_Termination = std::unique_ptr<wxTimer>(new wxTimer( this, wxID_ANY ));
Connect( m_timer_Termination->GetId(), wxEVT_TIMER, wxTimerEventHandler(Pcsx2App::OnScheduledTermination) );
SetExitOnFrameDelete( false );

View File

@ -71,7 +71,7 @@ DEFINE_EVENT_TYPE( pxEvt_LogicalVsync );
DEFINE_EVENT_TYPE( pxEvt_ThreadTaskTimeout_SysExec );
ScopedPtr<AppConfig> g_Conf;
std::unique_ptr<AppConfig> g_Conf;
static bool HandlePluginError( BaseException& ex )
{
@ -904,7 +904,7 @@ void Pcsx2App::PostIdleAppMethod( FnPtr_Pcsx2App method )
SysMainMemory& Pcsx2App::GetVmReserve()
{
if (!m_VmReserve) m_VmReserve = new SysMainMemory();
if (!m_VmReserve) m_VmReserve = std::unique_ptr<SysMainMemory>(new SysMainMemory());
return *m_VmReserve;
}

View File

@ -20,6 +20,7 @@
#include <wx/zipstrm.h>
#include <wx/wfstream.h>
#include <wx/imaglist.h>
#include <memory>
#include "MSWstuff.h"
@ -61,9 +62,9 @@ const wxImage& LoadImageAny(
RecentIsoList::RecentIsoList(int firstIdForMenuItems_or_wxID_ANY)
{
Menu = new wxMenu();
Menu = std::unique_ptr<wxMenu>(new wxMenu());
Menu->Append( MenuId_IsoBrowse, _("Browse..."), _("Browse for an Iso that is not in your recent history.") );
Manager = new RecentIsoManager( Menu, firstIdForMenuItems_or_wxID_ANY );
Manager = std::unique_ptr<RecentIsoManager>(new RecentIsoManager( Menu.get(), firstIdForMenuItems_or_wxID_ANY ));
}
pxAppResources::pxAppResources()
@ -74,13 +75,13 @@ pxAppResources::~pxAppResources() throw() {}
wxMenu& Pcsx2App::GetRecentIsoMenu()
{
if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList( MenuId_RecentIsos_reservedStart );
if (!m_RecentIsoList) m_RecentIsoList = std::unique_ptr<RecentIsoList>(new RecentIsoList( MenuId_RecentIsos_reservedStart ));
return *m_RecentIsoList->Menu;
}
RecentIsoManager& Pcsx2App::GetRecentIsoManager()
{
if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList( MenuId_RecentIsos_reservedStart );
if (!m_RecentIsoList) m_RecentIsoList = std::unique_ptr<RecentIsoList>(new RecentIsoList( MenuId_RecentIsos_reservedStart ));
return *m_RecentIsoList->Manager;
}
@ -88,17 +89,17 @@ pxAppResources& Pcsx2App::GetResourceCache()
{
ScopedLock lock( m_mtx_Resources );
if( !m_Resources )
m_Resources = new pxAppResources();
m_Resources = std::unique_ptr<pxAppResources>(new pxAppResources());
return *m_Resources;
}
const wxIconBundle& Pcsx2App::GetIconBundle()
{
ScopedPtr<wxIconBundle>& bundle( GetResourceCache().IconBundle );
std::unique_ptr<wxIconBundle>& bundle( GetResourceCache().IconBundle );
if( !bundle )
{
bundle = new wxIconBundle();
bundle = std::unique_ptr<wxIconBundle>(new wxIconBundle());
bundle->AddIcon( EmbeddedImage<res_AppIcon32>().GetIcon() );
bundle->AddIcon( EmbeddedImage<res_AppIcon64>().GetIcon() );
bundle->AddIcon( EmbeddedImage<res_AppIcon16>().GetIcon() );
@ -109,7 +110,7 @@ const wxIconBundle& Pcsx2App::GetIconBundle()
const wxBitmap& Pcsx2App::GetLogoBitmap()
{
ScopedPtr<wxBitmap>& logo( GetResourceCache().Bitmap_Logo );
std::unique_ptr <wxBitmap>& logo(GetResourceCache().Bitmap_Logo);
if( logo ) return *logo;
wxFileName themeDirectory;
@ -137,14 +138,14 @@ const wxBitmap& Pcsx2App::GetLogoBitmap()
EmbeddedImage<res_BackgroundLogo> temp; // because gcc can't allow non-const temporaries.
LoadImageAny(img, useTheme, themeDirectory, L"BackgroundLogo", temp);
float scale = MSW_GetDPIScale(); // 1.0 for non-Windows
logo = new wxBitmap(img.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_HIGH));
logo = std::unique_ptr<wxBitmap>(new wxBitmap(img.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_HIGH)));
return *logo;
}
const wxBitmap& Pcsx2App::GetScreenshotBitmap()
{
ScopedPtr<wxBitmap>& screenshot(GetResourceCache().ScreenshotBitmap);
std::unique_ptr<wxBitmap>& screenshot(GetResourceCache().ScreenshotBitmap);
if (screenshot) return *screenshot;
wxFileName themeDirectory;
@ -159,18 +160,18 @@ const wxBitmap& Pcsx2App::GetScreenshotBitmap()
EmbeddedImage<res_ButtonIcon_Camera> temp; // because gcc can't allow non-const temporaries.
LoadImageAny(img, useTheme, themeDirectory, L"ButtonIcon_Camera", temp);
float scale = MSW_GetDPIScale(); // 1.0 for non-Windows
screenshot = new wxBitmap(img.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_HIGH));
screenshot = std::unique_ptr<wxBitmap>(new wxBitmap(img.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_HIGH)));
return *screenshot;
}
wxImageList& Pcsx2App::GetImgList_Config()
{
ScopedPtr<wxImageList>& images( GetResourceCache().ConfigImages );
std::unique_ptr<wxImageList>& images( GetResourceCache().ConfigImages );
if( !images )
{
int image_size = MSW_GetDPIScale() * g_Conf->Listbook_ImageSize;
images = new wxImageList(image_size, image_size);
images = std::unique_ptr<wxImageList>(new wxImageList(image_size, image_size));
wxFileName themeDirectory;
bool useTheme = (g_Conf->DeskTheme != L"default");
@ -213,12 +214,12 @@ wxImageList& Pcsx2App::GetImgList_Config()
// This stuff seems unused?
wxImageList& Pcsx2App::GetImgList_Toolbars()
{
ScopedPtr<wxImageList>& images( GetResourceCache().ToolbarImages );
std::unique_ptr<wxImageList>& images( GetResourceCache().ToolbarImages );
if( !images )
{
const int imgSize = g_Conf->Toolbar_ImageSize ? 64 : 32;
images = new wxImageList( imgSize, imgSize );
images = std::unique_ptr<wxImageList>(new wxImageList(imgSize, imgSize));
wxFileName mess;
bool useTheme = (g_Conf->DeskTheme != L"default");

View File

@ -129,7 +129,7 @@ wxConfigBase* Pcsx2App::TestForPortableInstall()
// mode. In order to determine our read/write permissions to the PCSX2, we must try to
// modify the configured documents folder, and catch any ensuing error.
ScopedPtr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
std::unique_ptr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
conf_portable->SetRecordDefaults(false);
while( true )
@ -187,7 +187,7 @@ wxConfigBase* Pcsx2App::TestForPortableInstall()
InstallationMode = InstallMode_Portable;
DocsFolderMode = DocsFolder_Custom;
CustomDocumentsFolder = portableDocsFolder;
return conf_portable.DetachPtr();
return conf_portable.release();
}
return NULL;
@ -200,13 +200,13 @@ void Pcsx2App::WipeUserModeSettings()
{
// Remove the portable.ini entry "RunWizard" conforming to this instance of PCSX2.
wxFileName portableIniFile( GetPortableIniPath() );
ScopedPtr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
std::unique_ptr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
conf_portable->DeleteEntry(L"RunWizard");
}
else
{
// Remove the registry entry "RunWizard" conforming to this instance of PCSX2.
ScopedPtr<wxConfigBase> conf_install( OpenInstallSettingsFile() );
std::unique_ptr<wxConfigBase> conf_install( OpenInstallSettingsFile() );
conf_install->DeleteEntry(L"RunWizard");
}
}
@ -237,10 +237,10 @@ wxConfigBase* Pcsx2App::OpenInstallSettingsFile()
// the old system (CWD-based ini file mess) in favor of a system that simply stores
// most core application-level settings in the registry.
ScopedPtr<wxConfigBase> conf_install;
std::unique_ptr<wxConfigBase> conf_install;
#ifdef __WXMSW__
conf_install = new wxRegConfig();
conf_install = std::unique_ptr<wxConfigBase>(new wxRegConfig());
#else
// FIXME!! Linux / Mac
// Where the heck should this information be stored?
@ -255,31 +255,31 @@ wxConfigBase* Pcsx2App::OpenInstallSettingsFile()
wxFileName usermodefile( GetAppName() + L"-reg.ini" );
usermodefile.SetPath( usrlocaldir.ToString() );
conf_install = OpenFileConfig( usermodefile.GetFullPath() );
conf_install = std::unique_ptr<wxConfigBase>(OpenFileConfig( usermodefile.GetFullPath() ));
#endif
return conf_install.DetachPtr();
return conf_install.release();
}
void Pcsx2App::ForceFirstTimeWizardOnNextRun()
{
ScopedPtr<wxConfigBase> conf_install;
std::unique_ptr<wxConfigBase> conf_install;
conf_install = TestForPortableInstall();
conf_install = std::unique_ptr<wxConfigBase>(TestForPortableInstall());
if (!conf_install)
conf_install = OpenInstallSettingsFile();
conf_install = std::unique_ptr<wxConfigBase>(OpenInstallSettingsFile());
conf_install->Write( L"RunWizard", true );
}
void Pcsx2App::EstablishAppUserMode()
{
ScopedPtr<wxConfigBase> conf_install;
std::unique_ptr<wxConfigBase> conf_install;
conf_install = TestForPortableInstall();
conf_install = std::unique_ptr<wxConfigBase>(TestForPortableInstall());
if (!conf_install)
conf_install = OpenInstallSettingsFile();
conf_install = std::unique_ptr<wxConfigBase>(OpenInstallSettingsFile());
conf_install->SetRecordDefaults(false);
@ -292,7 +292,7 @@ void Pcsx2App::EstablishAppUserMode()
bool runWiz;
conf_install->Read( L"RunWizard", &runWiz, true );
App_LoadInstallSettings( conf_install );
App_LoadInstallSettings( conf_install.get() );
if( !Startup.ForceWizard && !runWiz )
{
@ -303,7 +303,7 @@ void Pcsx2App::EstablishAppUserMode()
DoFirstTimeWizard();
// Save user's new settings
App_SaveInstallSettings( conf_install );
App_SaveInstallSettings( conf_install.get() );
AppConfig_OnChangedSettingsFolder( true );
AppSaveSettings();

View File

@ -1174,16 +1174,16 @@ void Pcsx2App::EnableAllLogging()
if( emuLog )
{
if( !m_StdoutRedirHandle ) m_StdoutRedirHandle = NewPipeRedir(stdout);
if( !m_StderrRedirHandle ) m_StderrRedirHandle = NewPipeRedir(stderr);
if( !m_StdoutRedirHandle ) m_StdoutRedirHandle = std::unique_ptr<PipeRedirectionBase>(NewPipeRedir(stdout));
if( !m_StderrRedirHandle ) m_StderrRedirHandle = std::unique_ptr<PipeRedirectionBase>(NewPipeRedir(stderr));
newHandler = logBoxOpen ? (IConsoleWriter*)&ConsoleWriter_WindowAndFile : (IConsoleWriter*)&ConsoleWriter_File;
}
else
{
if( logBoxOpen )
{
if( !m_StdoutRedirHandle ) m_StdoutRedirHandle = NewPipeRedir(stdout);
if( !m_StderrRedirHandle ) m_StderrRedirHandle = NewPipeRedir(stderr);
if (!m_StdoutRedirHandle) m_StdoutRedirHandle = std::unique_ptr<PipeRedirectionBase>(NewPipeRedir(stdout));
if (!m_StderrRedirHandle) m_StderrRedirHandle = std::unique_ptr<PipeRedirectionBase>(NewPipeRedir(stderr));
newHandler = &ConsoleWriter_Window;
}
else

View File

@ -100,7 +100,7 @@ class pxLogTextCtrl : public wxTextCtrl,
public EventListener_Plugins
{
protected:
ScopedPtr<ScopedCoreThreadPause> m_IsPaused;
std::unique_ptr<ScopedCoreThreadPause> m_IsPaused;
bool m_FreezeWrites;
public:
@ -213,7 +213,7 @@ protected:
// Threaded log spammer, useful for testing console logging performance.
// (alternatively you can enable Disasm logging in any recompiler and achieve
// a similar effect)
ScopedPtr<ConsoleTestThread> m_threadlogger;
std::unique_ptr<ConsoleTestThread> m_threadlogger;
public:
// ctor & dtor

View File

@ -16,6 +16,7 @@
#pragma once
#include "AppEventListeners.h"
#include <memory>
class BaseCpuUsageProvider
{
@ -35,7 +36,7 @@ public:
class CpuUsageProvider : public BaseCpuUsageProvider
{
protected:
ScopedPtr<BaseCpuUsageProvider> m_Implementation;
std::unique_ptr<BaseCpuUsageProvider> m_Implementation;
public:
CpuUsageProvider();

View File

@ -15,6 +15,7 @@
#include "PrecompiledHeader.h"
#include "App.h"
#include <memory>
using namespace pxSizerFlags;
@ -197,7 +198,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
pxEvtList::iterator node;
while( node = list.begin(), node != list.end() )
{
ScopedPtr<SysExecEvent> deleteMe(*node);
std::unique_ptr<SysExecEvent> deleteMe(*node);
list.erase( node );
if( !m_Quitting || deleteMe->IsCriticalEvent() )
@ -210,7 +211,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
synclock.Release();
pxEvtLog.Write( this, deleteMe, wxsFormat(L"Executing... [%s]%s",
pxEvtLog.Write( this, deleteMe.get(), wxsFormat(L"Executing... [%s]%s",
deleteMe->AllowCancelOnExit() ? L"Cancelable" : L"Noncancelable", isIdle ? L"(Idle)" : wxEmptyString).wc_str()
);
@ -223,7 +224,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
}
u64 qpc_end = GetCPUTicks();
pxEvtLog.Write( this, deleteMe, wxsFormat(L"Event completed in %ums",
pxEvtLog.Write( this, deleteMe.get(), wxsFormat(L"Event completed in %ums",
(u32)(((qpc_end-m_qpc_Start)*1000) / GetTickFrequency())).wc_str()
);
@ -232,7 +233,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
}
else
{
pxEvtLog.Write( this, deleteMe, L"Skipping Event: %s" );
pxEvtLog.Write( this, deleteMe.get(), L"Skipping Event: %s" );
deleteMe->PostResult();
}
}
@ -263,7 +264,7 @@ void pxEvtQueue::AddPendingEvent( SysExecEvent& evt )
//
void pxEvtQueue::PostEvent( SysExecEvent* evt )
{
ScopedPtr<SysExecEvent> sevt( evt );
std::unique_ptr<SysExecEvent> sevt(evt);
if( !sevt ) return;
if( m_Quitting )
@ -276,7 +277,7 @@ void pxEvtQueue::PostEvent( SysExecEvent* evt )
pxEvtLog.Write( this, evt, pxsFmt(L"Posting event! (pending=%d, idle=%d)", m_pendingEvents.size(), m_idleEvents.size()) );
m_pendingEvents.push_back( sevt.DetachPtr() );
m_pendingEvents.push_back( sevt.release() );
if( m_pendingEvents.size() == 1)
m_wakeup.Post();
}
@ -340,7 +341,7 @@ void pxEvtQueue::ProcessEvent( SysExecEvent* evt )
}
else
{
ScopedPtr<SysExecEvent> deleteMe( evt );
std::unique_ptr<SysExecEvent> deleteMe(evt);
deleteMe->_DoInvokeEvent();
}
}
@ -452,9 +453,9 @@ void WaitingForThreadedTaskDialog::OnTerminateApp_Clicked( wxCommandEvent& evt )
// --------------------------------------------------------------------------------------
// ExecutorThread Implementations
// --------------------------------------------------------------------------------------
ExecutorThread::ExecutorThread( pxEvtQueue* evthandler )
ExecutorThread::ExecutorThread(pxEvtQueue* evthandler)
: m_EvtHandler(evthandler)
{
m_EvtHandler = evthandler;
}
bool ExecutorThread::IsRunning() const
@ -507,7 +508,7 @@ void ExecutorThread::ProcessEvent( SysExecEvent* evt )
m_EvtHandler->ProcessEvent( evt );
else
{
ScopedPtr<SysExecEvent> deleteMe( evt );
std::unique_ptr<SysExecEvent> deleteMe(evt);
deleteMe->_DoInvokeEvent();
}
}

View File

@ -23,6 +23,7 @@
#include "MSWstuff.h"
#include <wx/utils.h>
#include <memory>
static const KeyAcceleratorCode FULLSCREEN_TOGGLE_ACCELERATOR_GSPANEL=KeyAcceleratorCode( WXK_RETURN ).Alt();
@ -37,7 +38,7 @@ void GSPanel::InitDefaultAccelerators()
typedef KeyAcceleratorCode AAC;
if( !m_Accels ) m_Accels = new AcceleratorDictionary;
if (!m_Accels) m_Accels = std::unique_ptr<AcceleratorDictionary>(new AcceleratorDictionary);
m_Accels->Map( AAC( WXK_F1 ), "States_FreezeCurrentSlot" );
m_Accels->Map( AAC( WXK_F3 ), "States_DefrostCurrentSlot");

View File

@ -18,6 +18,7 @@
#include "AppCommon.h"
#include "CpuUsageProvider.h"
#include <memory>
enum LimiterModeType
@ -39,7 +40,7 @@ class GSPanel : public wxWindow
typedef wxWindow _parent;
protected:
ScopedPtr<AcceleratorDictionary> m_Accels;
std::unique_ptr<AcceleratorDictionary> m_Accels;
wxTimer m_HideMouseTimer;
bool m_CursorShown;

View File

@ -711,7 +711,7 @@ void AcceleratorDictionary::Map( const KeyAcceleratorCode& _acode, const char *s
void Pcsx2App::BuildCommandHash()
{
if( !GlobalCommands ) GlobalCommands = new CommandDictionary;
if( !GlobalCommands ) GlobalCommands = std::unique_ptr<CommandDictionary>(new CommandDictionary);
const GlobalCommandDescriptor* curcmd = CommandDeclarations;
while( curcmd->Invoke != NULL )
@ -725,7 +725,7 @@ void Pcsx2App::InitDefaultGlobalAccelerators()
{
typedef KeyAcceleratorCode AAC;
if( !GlobalAccels ) GlobalAccels = new AcceleratorDictionary;
if( !GlobalAccels ) GlobalAccels = std::unique_ptr<AcceleratorDictionary>(new AcceleratorDictionary);
// Why do we even have those here? all of them seem to be overridden
// by GSPanel::m_Accels ( GSPanel::InitDefaultAccelerators() )

View File

@ -93,7 +93,7 @@ static void WipeSettings()
//wxRmdir( GetSettingsFolder().ToString() );
wxGetApp().GetRecentIsoManager().Clear();
g_Conf = new AppConfig();
g_Conf = std::unique_ptr<AppConfig>(new AppConfig());
sMainFrame.RemoveCdvdMenu();
sApp.WipeUserModeSettings();

View File

@ -22,6 +22,7 @@
#include <wx/dir.h>
#include <wx/filepicker.h>
#include <wx/listbox.h>
#include <memory>
using namespace pxSizerFlags;
@ -150,17 +151,17 @@ bool Panels::BiosSelectorPanel::ValidateEnumerationStatus()
{
bool validated = true;
// Impl Note: ScopedPtr used so that resources get cleaned up if an exception
// Impl Note: unique_ptr used so that resources get cleaned up if an exception
// occurs during file enumeration.
ScopedPtr<wxArrayString> bioslist( new wxArrayString() );
std::unique_ptr<wxArrayString> bioslist(new wxArrayString());
if( m_FolderPicker->GetPath().Exists() )
wxDir::GetAllFiles( m_FolderPicker->GetPath().ToString(), bioslist, L"*.*", wxDIR_FILES );
wxDir::GetAllFiles(m_FolderPicker->GetPath().ToString(), bioslist.get(), L"*.*", wxDIR_FILES);
if( !m_BiosList || (*bioslist != *m_BiosList) )
validated = false;
m_BiosList.SwapPtr( bioslist );
m_BiosList.swap(bioslist);
return validated;
}

View File

@ -23,6 +23,7 @@
#include <wx/statline.h>
#include <wx/dnd.h>
#include <memory>
#include "AppCommon.h"
#include "ApplyState.h"
@ -492,9 +493,9 @@ namespace Panels
typedef BaseSelectorPanel _parent;
protected:
ScopedPtr<wxArrayString> m_ThemeList;
wxListBox* m_ComboBox;
DirPickerPanel* m_FolderPicker;
std::unique_ptr<wxArrayString> m_ThemeList;
wxListBox* m_ComboBox;
DirPickerPanel* m_FolderPicker;
public:
virtual ~ThemeSelectorPanel() throw();
@ -513,9 +514,9 @@ namespace Panels
class BiosSelectorPanel : public BaseSelectorPanel
{
protected:
ScopedPtr<wxArrayString> m_BiosList;
wxListBox* m_ComboBox;
DirPickerPanel* m_FolderPicker;
std::unique_ptr<wxArrayString> m_BiosList;
wxListBox* m_ComboBox;
DirPickerPanel* m_FolderPicker;
public:
BiosSelectorPanel( wxWindow* parent );
@ -620,8 +621,8 @@ namespace Panels
ComboBoxPanel* m_ComponentBoxes;
bool m_Canceled;
ScopedPtr<wxArrayString> m_FileList; // list of potential plugin files
ScopedPtr<EnumThread> m_EnumeratorThread;
std::unique_ptr<wxArrayString> m_FileList; // list of potential plugin files
std::unique_ptr<EnumThread> m_EnumeratorThread;
public:
virtual ~PluginSelectorPanel() throw();

View File

@ -147,7 +147,7 @@ void Panels::GameFixesPanel::Apply()
void Panels::GameFixesPanel::EnableStuff( AppConfig* configToUse )
{
if( !configToUse ) configToUse = g_Conf;
if (!configToUse) configToUse = g_Conf.get();
for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i)
m_checkbox[i]->Enable(m_check_Enable->GetValue() && !configToUse->EnablePresets);

View File

@ -17,6 +17,7 @@
#include <wx/dynlib.h>
#include <wx/dir.h>
#include <memory>
#include "App.h"
#include "AppSaveStates.h"
@ -256,7 +257,7 @@ void SysExecEvent_ApplyPlugins::InvokeEvent()
{
ScopedCoreThreadPause paused_core;
ScopedPtr< VmStateBuffer > buffer;
std::unique_ptr<VmStateBuffer> buffer;
if( SysHasValidState() )
{
@ -268,7 +269,8 @@ void SysExecEvent_ApplyPlugins::InvokeEvent()
// FIXME : We only actually have to save plugins here, except the recovery code
// in SysCoreThread isn't quite set up yet to handle that (I think...) --air
memSavingState saveme( *(buffer.Reassign(new VmStateBuffer(L"StateBuffer_ApplyNewPlugins"))) );
buffer.reset(new VmStateBuffer(L"StateBuffer_ApplyNewPlugins"));
memSavingState saveme(buffer.get());
saveme.FreezeAll();
}
@ -546,7 +548,7 @@ void Panels::PluginSelectorPanel::DoRefresh()
wxCommandEvent evt( pxEVT_ShowStatusBar );
GetEventHandler()->AddPendingEvent( evt );
m_EnumeratorThread.Reassign(new EnumThread( *this ));
m_EnumeratorThread.reset(new EnumThread(*this));
if( DisableThreading )
m_EnumeratorThread->DoNextPlugin( 0 );
@ -563,11 +565,11 @@ bool Panels::PluginSelectorPanel::ValidateEnumerationStatus()
// re-enumerate plugins, and if anything changed then we need to wipe
// the contents of the combo boxes and re-enumerate everything.
// Impl Note: ScopedPtr used so that resources get cleaned up if an exception
// Impl Note: unique_ptr used so that resources get cleaned up if an exception
// occurs during file enumeration.
ScopedPtr<wxArrayString> pluginlist( new wxArrayString() );
std::unique_ptr<wxArrayString> pluginlist(new wxArrayString());
int pluggers = EnumeratePluginsInFolder( m_ComponentBoxes->GetPluginsPath(), pluginlist );
int pluggers = EnumeratePluginsInFolder(m_ComponentBoxes->GetPluginsPath(), pluginlist.get());
if( !m_FileList || (*pluginlist != *m_FileList) )
validated = false;
@ -578,7 +580,7 @@ bool Panels::PluginSelectorPanel::ValidateEnumerationStatus()
return validated;
}
m_FileList.SwapPtr( pluginlist );
m_FileList.swap(pluginlist);
// set the gague length a little shorter than the plugin count. 2 reasons:
// * some of the plugins might be duds.
@ -699,7 +701,7 @@ void Panels::PluginSelectorPanel::OnProgress( wxCommandEvent& evt )
// The thread can get canceled and replaced with a new thread, which means all
// pending messages should be ignored.
if( m_EnumeratorThread != (EnumThread*)evt.GetClientData() ) return;
if (m_EnumeratorThread.get() != (EnumThread*)evt.GetClientData()) return;
const size_t evtidx = evt.GetExtraLong();

View File

@ -251,7 +251,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
// Doesn't modify values - only locks(gray out)/unlocks as necessary.
void Panels::SpeedHacksPanel::EnableStuff( AppConfig* configToUse )
{
if( !configToUse ) configToUse = g_Conf;
if (!configToUse) configToUse = g_Conf.get();
bool hasPreset = configToUse->EnablePresets;
bool hacksEnabled = configToUse->EnableSpeedHacks;

View File

@ -21,6 +21,7 @@
#include <wx/filepicker.h>
#include <wx/listbox.h>
#include <wx/zipstrm.h>
#include <memory>
using namespace pxSizerFlags;
@ -73,20 +74,20 @@ bool Panels::ThemeSelectorPanel::ValidateEnumerationStatus()
{
bool validated = true;
// Impl Note: ScopedPtr used so that resources get cleaned up if an exception
// Impl Note: unique_ptr used so that resources get cleaned up if an exception
// occurs during file enumeration.
ScopedPtr<wxArrayString> themelist( new wxArrayString() );
std::unique_ptr<wxArrayString> themelist(new wxArrayString());
if( m_FolderPicker->GetPath().Exists() )
{
wxDir::GetAllFiles( m_FolderPicker->GetPath().ToString(), themelist, L"*.zip;*.p2ui", wxDIR_FILES );
wxDir::GetAllFiles( m_FolderPicker->GetPath().ToString(), themelist, L"*.*", wxDIR_DIRS );
wxDir::GetAllFiles(m_FolderPicker->GetPath().ToString(), themelist.get(), L"*.zip;*.p2ui", wxDIR_FILES);
wxDir::GetAllFiles(m_FolderPicker->GetPath().ToString(), themelist.get(), L"*.*", wxDIR_DIRS);
}
if( !m_ThemeList || (*themelist != *m_ThemeList) )
validated = false;
m_ThemeList.SwapPtr( themelist );
m_ThemeList.swap(themelist);
return validated;
}

View File

@ -72,8 +72,8 @@ protected:
// --------------------------------------------------------------------------------------
struct RecentIsoList
{
ScopedPtr<RecentIsoManager> Manager;
ScopedPtr<wxMenu> Menu;
std::unique_ptr<RecentIsoManager> Manager;
std::unique_ptr<wxMenu> Menu;
RecentIsoList(int firstIdForMenuItems_or_wxID_ANY);
virtual ~RecentIsoList() throw() { }

View File

@ -25,6 +25,7 @@
#include "Utilities/pxStreams.h"
#include <wx/wfstream.h>
#include <memory>
// Used to hold the current state backup (fullcopy of PS2 memory and plugin states).
//static VmStateBuffer state_buffer( L"Public Savestate Buffer" );
@ -422,7 +423,7 @@ protected:
void InvokeEvent()
{
// Provisionals for scoped cleanup, in case of exception:
ScopedPtr<ArchiveEntryList> elist( m_src_list );
std::unique_ptr<ArchiveEntryList> elist(m_src_list);
wxString tempfile( m_filename + L".tmp" );
@ -437,7 +438,7 @@ protected:
pxYield(4);
// Write the version and screenshot:
ScopedPtr<pxOutputStream> out( new pxOutputStream(tempfile, new wxZipOutputStream(woot)) );
std::unique_ptr<pxOutputStream> out(new pxOutputStream(tempfile, new wxZipOutputStream(woot)));
wxZipOutputStream* gzfp = (wxZipOutputStream*)out->GetWxStreamBase();
{
@ -448,7 +449,7 @@ protected:
gzfp->CloseEntry();
}
ScopedPtr<wxImage> m_screenshot;
std::unique_ptr<wxImage> m_screenshot;
if (m_screenshot)
{
@ -460,14 +461,14 @@ protected:
}
(*new VmStateCompressThread())
.SetSource(elist)
.SetOutStream(out)
.SetSource(elist.get())
.SetOutStream(out.get())
.SetFinishedPath(m_filename)
.Start();
// No errors? Release cleanup handlers:
elist.DetachPtr();
out.DetachPtr();
elist.release();
out.release();
}
void CleanupEvent()
@ -506,12 +507,12 @@ protected:
// Ugh. Exception handling made crappy because wxWidgets classes don't support scoped pointers yet.
ScopedPtr<wxFFileInputStream> woot( new wxFFileInputStream(m_filename) );
std::unique_ptr<wxFFileInputStream> woot(new wxFFileInputStream(m_filename));
if (!woot->IsOk())
throw Exception::CannotCreateStream( m_filename ).SetDiagMsg(L"Cannot open file for reading.");
ScopedPtr<pxInputStream> reader( new pxInputStream(m_filename, new wxZipInputStream(woot)) );
woot.DetachPtr();
std::unique_ptr<pxInputStream> reader(new pxInputStream(m_filename, new wxZipInputStream(woot.get())));
woot.release();
if (!reader->IsOk())
{
@ -528,14 +529,14 @@ protected:
//bool foundScreenshot = false;
//bool foundEntry[numSavestateEntries] = false;
ScopedPtr<wxZipEntry> foundInternal;
ScopedPtr<wxZipEntry> foundEntry[NumSavestateEntries];
std::unique_ptr<wxZipEntry> foundInternal;
std::unique_ptr<wxZipEntry> foundEntry[NumSavestateEntries];
while(true)
{
Threading::pxTestCancel();
ScopedPtr<wxZipEntry> entry( gzreader->GetNextEntry() );
std::unique_ptr<wxZipEntry> entry(gzreader->GetNextEntry());
if (!entry) break;
if (entry->GetName().CmpNoCase(EntryFilename_StateVersion) == 0)
@ -549,7 +550,7 @@ protected:
if (entry->GetName().CmpNoCase(EntryFilename_InternalStructures) == 0)
{
DevCon.WriteLn( Color_Green, L" ... found '%s'", EntryFilename_InternalStructures);
foundInternal = entry.DetachPtr();
foundInternal = std::move(entry);
continue;
}
@ -565,7 +566,7 @@ protected:
if (entry->GetName().CmpNoCase(SavestateEntries[i]->GetFilename()) == 0)
{
DevCon.WriteLn( Color_Green, L" ... found '%s'", WX_STR(SavestateEntries[i]->GetFilename()) );
foundEntry[i] = entry.DetachPtr();
foundEntry[i] = std::move(entry);
break;
}
}
@ -633,12 +634,12 @@ void StateCopy_SaveToFile( const wxString& file )
{
UI_DisableStateActions();
ScopedPtr<ArchiveEntryList> ziplist (new ArchiveEntryList( new VmStateBuffer( L"Zippable Savestate" ) ));
std::unique_ptr<ArchiveEntryList> ziplist(new ArchiveEntryList(new VmStateBuffer(L"Zippable Savestate")));
GetSysExecutorThread().PostEvent(new SysExecEvent_DownloadState ( ziplist ));
GetSysExecutorThread().PostEvent(new SysExecEvent_ZipToDisk ( ziplist, file ));
GetSysExecutorThread().PostEvent(new SysExecEvent_DownloadState(ziplist.get()));
GetSysExecutorThread().PostEvent(new SysExecEvent_ZipToDisk(ziplist.get(), file));
ziplist.DetachPtr();
ziplist.release();
}
void StateCopy_LoadFromFile( const wxString& file )

View File

@ -16,8 +16,8 @@
#include "PrecompiledHeader.h"
#include "i18n.h"
#include "AppConfig.h"
#include "Utilities/SafeArray.h"
#include <memory>
// Some of the codes provided by wxWidgets are 'obsolete' -- effectively replaced by more specific
// region-qualified language codes. This function can be used to filter them out.
@ -80,9 +80,9 @@ static void i18n_DoPackageCheck( wxLanguage wxLangId, LangPackList& langs, bool&
// note: wx preserves the current locale for us, so creating a new locale and deleting
// will not affect program status.
#if wxMAJOR_VERSION < 3
ScopedPtr<wxLocale> locale( new wxLocale( wxLangId, wxLOCALE_CONV_ENCODING ) );
std::unique_ptr<wxLocale> locale(new wxLocale(wxLangId, wxLOCALE_CONV_ENCODING));
#else
ScopedPtr<wxLocale> locale( new wxLocale( wxLangId, 0 ) );
std::unique_ptr<wxLocale> locale(new wxLocale(wxLangId, 0));
#endif
// Force the msgIdLanguage param to wxLANGUAGE_UNKNOWN to disable wx's automatic english
@ -304,7 +304,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode )
if (!info) return false;
if (wxGetLocale() && (info->Language == wxGetLocale()->GetLanguage())) return true;
ScopedPtr<wxLocale> locale( new wxLocale(info->Language) );
std::unique_ptr<wxLocale> locale(new wxLocale(info->Language));
if( !locale->IsOk() )
{
@ -325,7 +325,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode )
// English/US is built in, so no need to load MO/PO files.
if( pxIsEnglish(wxLangId) )
{
locale.DetachPtr();
locale.release();
return true;
}
@ -356,7 +356,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode )
return false;
}
locale.DetachPtr();
locale.release();
return true;
}

View File

@ -17,7 +17,7 @@
#include "Utilities/PersistentThread.h"
#include "Utilities/pxEvents.h"
#include <memory>
// TODO!! Make the system defined in this header system a bit more generic, and then move
// it to the Utilities library.
@ -266,8 +266,8 @@ class ExecutorThread : public Threading::pxThread
typedef Threading::pxThread _parent;
protected:
ScopedPtr<wxTimer> m_ExecutorTimer;
ScopedPtr<pxEvtQueue> m_EvtHandler;
std::unique_ptr<wxTimer> m_ExecutorTimer;
std::unique_ptr<pxEvtQueue> m_EvtHandler;
public:
ExecutorThread( pxEvtQueue* evtandler = NULL );

View File

@ -20,6 +20,7 @@
#ifdef __WXMSW__
# include <wx/msw/wrapwin.h> // needed for windows-specific rich text messages to make scrolling not lame
#endif
#include <memory>
void pxLogTextCtrl::DispatchEvent( const CoreThreadStatus& status )
{
@ -65,7 +66,7 @@ void pxLogTextCtrl::OnThumbTrack(wxScrollWinEvent& evt)
//Console.Warning( "Thumb Tracking!!!" );
m_FreezeWrites = true;
if( !m_IsPaused )
m_IsPaused = new ScopedCoreThreadPause();
m_IsPaused = std::unique_ptr<ScopedCoreThreadPause>(new ScopedCoreThreadPause());
evt.Skip();
}
@ -77,7 +78,7 @@ void pxLogTextCtrl::OnThumbRelease(wxScrollWinEvent& evt)
if( m_IsPaused )
{
m_IsPaused->AllowResume();
m_IsPaused.Delete();
m_IsPaused = nullptr;
}
evt.Skip();
}

View File

@ -641,9 +641,9 @@ void recStep()
#if !PCSX2_SEH
# define SETJMP_CODE(x) x
static jmp_buf m_SetJmp_StateCheck;
static ScopedPtr<BaseR5900Exception> m_cpuException;
static ScopedExcept m_Exception;
static jmp_buf m_SetJmp_StateCheck;
static std::unique_ptr<BaseR5900Exception> 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<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
}

View File

@ -67,7 +67,7 @@ void mVUinit(microVU& mVU, uint vuIndex) {
if (!mVU.dispCache) throw Exception::OutOfMemory (mVU.index ? L"Micro VU1 Dispatcher" : L"Micro VU0 Dispatcher");
memset(mVU.dispCache, 0xcc, mVUdispCacheSize);
mVU.regAlloc = new microRegAlloc(mVU.index);
mVU.regAlloc.reset(new microRegAlloc(mVU.index));
}
// Resets Rec Data

View File

@ -22,6 +22,7 @@ using namespace x86Emitter;
#include <deque>
#include <algorithm>
#include <memory>
#include "Common.h"
#include "VU.h"
#include "MTVU.h"
@ -192,10 +193,10 @@ struct microVU {
u32 progMemMask; // VU Micro Memory Size (in u32's)
u32 cacheSize; // VU Cache Size
microProgManager prog; // Micro Program Data
microProfiler profiler; // Opcode Profiler
ScopedPtr<microRegAlloc> regAlloc; // Reg Alloc Class
ScopedPtr<AsciiFile> logFile; // Log File Pointer
microProgManager prog; // Micro Program Data
microProfiler profiler; // Opcode Profiler
std::unique_ptr<microRegAlloc> regAlloc; // Reg Alloc Class
std::unique_ptr<AsciiFile> logFile; // Log File Pointer
RecompiledCodeReserve* cache_reserve;
u8* cache; // Dynarec Cache Start (where we will start writing the recompiled code to)

View File

@ -48,7 +48,7 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) {
mVUbranch = 0;
const wxString logname(wxsFormat(L"microVU%d prog - %02d.html", mVU.index, prog.idx));
mVU.logFile = new AsciiFile(Path::Combine(g_Conf->Folders.Logs, logname), L"w");
mVU.logFile = std::unique_ptr<AsciiFile>(new AsciiFile(Path::Combine(g_Conf->Folders.Logs, logname), L"w"));
mVUlog("<html>\n");
mVUlog("<title>microVU%d MicroProgram Log</title>\n", mVU.index);
@ -126,6 +126,6 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) {
iPC = bPC;
setCode();
mVU.logFile.Delete();
mVU.logFile.reset(nullptr);
}