gui: Replace ScopedPtr with unique_ptr

This commit is contained in:
Jonathan Li 2016-01-26 22:08:14 +00:00
parent 92bb849e7c
commit 8889f4fdcc
30 changed files with 175 additions and 155 deletions

View File

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

View File

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

View File

@ -18,6 +18,7 @@
#include "AppForwardDefs.h" #include "AppForwardDefs.h"
#include "PathDefs.h" #include "PathDefs.h"
#include "CDVD/CDVDaccess.h" #include "CDVD/CDVDaccess.h"
#include <memory>
enum DocsModeType enum DocsModeType
{ {
@ -383,4 +384,4 @@ extern void RelocateLogfile();
extern void AppConfig_OnChangedSettingsFolder( bool overwrite = false ); extern void AppConfig_OnChangedSettingsFolder( bool overwrite = false );
extern wxConfigBase* GetAppConfig(); 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 // Public API / Interface
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
int EnumeratePluginsInFolder( const wxDirName& searchpath, wxArrayString* dest ) int EnumeratePluginsInFolder(const wxDirName& searchpath, wxArrayString* dest)
{ {
if (!searchpath.Exists()) return 0; if (!searchpath.Exists()) return 0;
ScopedPtr<wxArrayString> placebo; std::unique_ptr<wxArrayString> placebo;
wxArrayString* realdest = dest; wxArrayString* realdest = dest;
if( realdest == NULL ) if (realdest == NULL)
placebo = realdest = new wxArrayString(); // placebo is our /dev/null -- gets deleted when done {
placebo = std::unique_ptr<wxArrayString>(new wxArrayString());
realdest = placebo.get();
}
#ifdef __WXMSW__ #ifdef __WXMSW__
// Windows pretty well has a strict "must end in .dll" rule. // Windows pretty well has a strict "must end in .dll" rule.
@ -558,12 +561,13 @@ void SysExecEvent_SaveSinglePlugin::InvokeEvent()
if( CorePlugins.AreLoaded() ) if( CorePlugins.AreLoaded() )
{ {
ScopedPtr<VmStateBuffer> plugstore; std::unique_ptr<VmStateBuffer> plugstore;
if( CoreThread.HasActiveMachine() ) if( CoreThread.HasActiveMachine() )
{ {
Console.WriteLn( Color_Green, L"Suspending single plugin: " + tbl_PluginInfo[m_pid].GetShortname() ); 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 ); GetCorePlugins().Freeze( m_pid, save );
} }
@ -573,7 +577,7 @@ void SysExecEvent_SaveSinglePlugin::InvokeEvent()
if( plugstore ) if( plugstore )
{ {
Console.WriteLn( Color_Green, L"Recovering single plugin: " + tbl_PluginInfo[m_pid].GetShortname() ); 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 ); GetCorePlugins().Freeze( m_pid, load );
// GS plugin suspend / resume hack. Removed in r4363, hopefully never to return :p // GS plugin suspend / resume hack. Removed in r4363, hopefully never to return :p
//GetCorePlugins().Close( m_pid ); // hack for stupid GS plugins. //GetCorePlugins().Close( m_pid ); // hack for stupid GS plugins.

View File

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

View File

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

View File

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

View File

@ -29,6 +29,7 @@
#include <wx/cmdline.h> #include <wx/cmdline.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <memory>
using namespace pxSizerFlags; using namespace pxSizerFlags;
@ -128,7 +129,7 @@ void Pcsx2App::AllocateCoreStuffs()
// FIXME : Some or all of SysCpuProviderPack should be run from the SysExecutor thread, // 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. // 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 ) ) if( m_CpuProviders->HadSomeFailures( g_Conf->EmuOptions.Cpu.Recompiler ) )
{ {
@ -422,7 +423,7 @@ bool Pcsx2App::OnInit()
pxDoAssert = AppDoAssert; pxDoAssert = AppDoAssert;
pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse; pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse;
g_Conf = new AppConfig(); g_Conf = std::unique_ptr<AppConfig>(new AppConfig());
wxInitAllImageHandlers(); wxInitAllImageHandlers();
Console.WriteLn("Applying operating system default language..."); 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 // 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 // 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). // 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) ); Connect( m_timer_Termination->GetId(), wxEVT_TIMER, wxTimerEventHandler(Pcsx2App::OnScheduledTermination) );
SetExitOnFrameDelete( false ); SetExitOnFrameDelete( false );

View File

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

View File

@ -20,6 +20,7 @@
#include <wx/zipstrm.h> #include <wx/zipstrm.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>
#include <wx/imaglist.h> #include <wx/imaglist.h>
#include <memory>
#include "MSWstuff.h" #include "MSWstuff.h"
@ -61,9 +62,9 @@ const wxImage& LoadImageAny(
RecentIsoList::RecentIsoList(int firstIdForMenuItems_or_wxID_ANY) 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.") ); 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() pxAppResources::pxAppResources()
@ -74,13 +75,13 @@ pxAppResources::~pxAppResources() throw() {}
wxMenu& Pcsx2App::GetRecentIsoMenu() 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; return *m_RecentIsoList->Menu;
} }
RecentIsoManager& Pcsx2App::GetRecentIsoManager() 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; return *m_RecentIsoList->Manager;
} }
@ -88,17 +89,17 @@ pxAppResources& Pcsx2App::GetResourceCache()
{ {
ScopedLock lock( m_mtx_Resources ); ScopedLock lock( m_mtx_Resources );
if( !m_Resources ) if( !m_Resources )
m_Resources = new pxAppResources(); m_Resources = std::unique_ptr<pxAppResources>(new pxAppResources());
return *m_Resources; return *m_Resources;
} }
const wxIconBundle& Pcsx2App::GetIconBundle() const wxIconBundle& Pcsx2App::GetIconBundle()
{ {
ScopedPtr<wxIconBundle>& bundle( GetResourceCache().IconBundle ); std::unique_ptr<wxIconBundle>& bundle( GetResourceCache().IconBundle );
if( !bundle ) if( !bundle )
{ {
bundle = new wxIconBundle(); bundle = std::unique_ptr<wxIconBundle>(new wxIconBundle());
bundle->AddIcon( EmbeddedImage<res_AppIcon32>().GetIcon() ); bundle->AddIcon( EmbeddedImage<res_AppIcon32>().GetIcon() );
bundle->AddIcon( EmbeddedImage<res_AppIcon64>().GetIcon() ); bundle->AddIcon( EmbeddedImage<res_AppIcon64>().GetIcon() );
bundle->AddIcon( EmbeddedImage<res_AppIcon16>().GetIcon() ); bundle->AddIcon( EmbeddedImage<res_AppIcon16>().GetIcon() );
@ -109,7 +110,7 @@ const wxIconBundle& Pcsx2App::GetIconBundle()
const wxBitmap& Pcsx2App::GetLogoBitmap() const wxBitmap& Pcsx2App::GetLogoBitmap()
{ {
ScopedPtr<wxBitmap>& logo( GetResourceCache().Bitmap_Logo ); std::unique_ptr <wxBitmap>& logo(GetResourceCache().Bitmap_Logo);
if( logo ) return *logo; if( logo ) return *logo;
wxFileName themeDirectory; wxFileName themeDirectory;
@ -137,14 +138,14 @@ const wxBitmap& Pcsx2App::GetLogoBitmap()
EmbeddedImage<res_BackgroundLogo> temp; // because gcc can't allow non-const temporaries. EmbeddedImage<res_BackgroundLogo> temp; // because gcc can't allow non-const temporaries.
LoadImageAny(img, useTheme, themeDirectory, L"BackgroundLogo", temp); LoadImageAny(img, useTheme, themeDirectory, L"BackgroundLogo", temp);
float scale = MSW_GetDPIScale(); // 1.0 for non-Windows 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; return *logo;
} }
const wxBitmap& Pcsx2App::GetScreenshotBitmap() const wxBitmap& Pcsx2App::GetScreenshotBitmap()
{ {
ScopedPtr<wxBitmap>& screenshot(GetResourceCache().ScreenshotBitmap); std::unique_ptr<wxBitmap>& screenshot(GetResourceCache().ScreenshotBitmap);
if (screenshot) return *screenshot; if (screenshot) return *screenshot;
wxFileName themeDirectory; wxFileName themeDirectory;
@ -159,18 +160,18 @@ const wxBitmap& Pcsx2App::GetScreenshotBitmap()
EmbeddedImage<res_ButtonIcon_Camera> temp; // because gcc can't allow non-const temporaries. EmbeddedImage<res_ButtonIcon_Camera> temp; // because gcc can't allow non-const temporaries.
LoadImageAny(img, useTheme, themeDirectory, L"ButtonIcon_Camera", temp); LoadImageAny(img, useTheme, themeDirectory, L"ButtonIcon_Camera", temp);
float scale = MSW_GetDPIScale(); // 1.0 for non-Windows 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; return *screenshot;
} }
wxImageList& Pcsx2App::GetImgList_Config() wxImageList& Pcsx2App::GetImgList_Config()
{ {
ScopedPtr<wxImageList>& images( GetResourceCache().ConfigImages ); std::unique_ptr<wxImageList>& images( GetResourceCache().ConfigImages );
if( !images ) if( !images )
{ {
int image_size = MSW_GetDPIScale() * g_Conf->Listbook_ImageSize; 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; wxFileName themeDirectory;
bool useTheme = (g_Conf->DeskTheme != L"default"); bool useTheme = (g_Conf->DeskTheme != L"default");
@ -213,12 +214,12 @@ wxImageList& Pcsx2App::GetImgList_Config()
// This stuff seems unused? // This stuff seems unused?
wxImageList& Pcsx2App::GetImgList_Toolbars() wxImageList& Pcsx2App::GetImgList_Toolbars()
{ {
ScopedPtr<wxImageList>& images( GetResourceCache().ToolbarImages ); std::unique_ptr<wxImageList>& images( GetResourceCache().ToolbarImages );
if( !images ) if( !images )
{ {
const int imgSize = g_Conf->Toolbar_ImageSize ? 64 : 32; 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; wxFileName mess;
bool useTheme = (g_Conf->DeskTheme != L"default"); 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 // 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. // 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); conf_portable->SetRecordDefaults(false);
while( true ) while( true )
@ -187,7 +187,7 @@ wxConfigBase* Pcsx2App::TestForPortableInstall()
InstallationMode = InstallMode_Portable; InstallationMode = InstallMode_Portable;
DocsFolderMode = DocsFolder_Custom; DocsFolderMode = DocsFolder_Custom;
CustomDocumentsFolder = portableDocsFolder; CustomDocumentsFolder = portableDocsFolder;
return conf_portable.DetachPtr(); return conf_portable.release();
} }
return NULL; return NULL;
@ -200,13 +200,13 @@ void Pcsx2App::WipeUserModeSettings()
{ {
// Remove the portable.ini entry "RunWizard" conforming to this instance of PCSX2. // Remove the portable.ini entry "RunWizard" conforming to this instance of PCSX2.
wxFileName portableIniFile( GetPortableIniPath() ); wxFileName portableIniFile( GetPortableIniPath() );
ScopedPtr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) ); std::unique_ptr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
conf_portable->DeleteEntry(L"RunWizard"); conf_portable->DeleteEntry(L"RunWizard");
} }
else else
{ {
// Remove the registry entry "RunWizard" conforming to this instance of PCSX2. // 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"); 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 // the old system (CWD-based ini file mess) in favor of a system that simply stores
// most core application-level settings in the registry. // most core application-level settings in the registry.
ScopedPtr<wxConfigBase> conf_install; std::unique_ptr<wxConfigBase> conf_install;
#ifdef __WXMSW__ #ifdef __WXMSW__
conf_install = new wxRegConfig(); conf_install = std::unique_ptr<wxConfigBase>(new wxRegConfig());
#else #else
// FIXME!! Linux / Mac // FIXME!! Linux / Mac
// Where the heck should this information be stored? // Where the heck should this information be stored?
@ -255,31 +255,31 @@ wxConfigBase* Pcsx2App::OpenInstallSettingsFile()
wxFileName usermodefile( GetAppName() + L"-reg.ini" ); wxFileName usermodefile( GetAppName() + L"-reg.ini" );
usermodefile.SetPath( usrlocaldir.ToString() ); usermodefile.SetPath( usrlocaldir.ToString() );
conf_install = OpenFileConfig( usermodefile.GetFullPath() ); conf_install = std::unique_ptr<wxConfigBase>(OpenFileConfig( usermodefile.GetFullPath() ));
#endif #endif
return conf_install.DetachPtr(); return conf_install.release();
} }
void Pcsx2App::ForceFirstTimeWizardOnNextRun() 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) if (!conf_install)
conf_install = OpenInstallSettingsFile(); conf_install = std::unique_ptr<wxConfigBase>(OpenInstallSettingsFile());
conf_install->Write( L"RunWizard", true ); conf_install->Write( L"RunWizard", true );
} }
void Pcsx2App::EstablishAppUserMode() 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) if (!conf_install)
conf_install = OpenInstallSettingsFile(); conf_install = std::unique_ptr<wxConfigBase>(OpenInstallSettingsFile());
conf_install->SetRecordDefaults(false); conf_install->SetRecordDefaults(false);
@ -292,7 +292,7 @@ void Pcsx2App::EstablishAppUserMode()
bool runWiz; bool runWiz;
conf_install->Read( L"RunWizard", &runWiz, true ); conf_install->Read( L"RunWizard", &runWiz, true );
App_LoadInstallSettings( conf_install ); App_LoadInstallSettings( conf_install.get() );
if( !Startup.ForceWizard && !runWiz ) if( !Startup.ForceWizard && !runWiz )
{ {
@ -303,7 +303,7 @@ void Pcsx2App::EstablishAppUserMode()
DoFirstTimeWizard(); DoFirstTimeWizard();
// Save user's new settings // Save user's new settings
App_SaveInstallSettings( conf_install ); App_SaveInstallSettings( conf_install.get() );
AppConfig_OnChangedSettingsFolder( true ); AppConfig_OnChangedSettingsFolder( true );
AppSaveSettings(); AppSaveSettings();

View File

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

View File

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

View File

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

View File

@ -15,6 +15,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "App.h" #include "App.h"
#include <memory>
using namespace pxSizerFlags; using namespace pxSizerFlags;
@ -197,7 +198,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
pxEvtList::iterator node; pxEvtList::iterator node;
while( node = list.begin(), node != list.end() ) while( node = list.begin(), node != list.end() )
{ {
ScopedPtr<SysExecEvent> deleteMe(*node); std::unique_ptr<SysExecEvent> deleteMe(*node);
list.erase( node ); list.erase( node );
if( !m_Quitting || deleteMe->IsCriticalEvent() ) if( !m_Quitting || deleteMe->IsCriticalEvent() )
@ -210,7 +211,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
synclock.Release(); 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() 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(); 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() (u32)(((qpc_end-m_qpc_Start)*1000) / GetTickFrequency())).wc_str()
); );
@ -232,7 +233,7 @@ void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
} }
else else
{ {
pxEvtLog.Write( this, deleteMe, L"Skipping Event: %s" ); pxEvtLog.Write( this, deleteMe.get(), L"Skipping Event: %s" );
deleteMe->PostResult(); deleteMe->PostResult();
} }
} }
@ -263,7 +264,7 @@ void pxEvtQueue::AddPendingEvent( SysExecEvent& evt )
// //
void pxEvtQueue::PostEvent( SysExecEvent* evt ) void pxEvtQueue::PostEvent( SysExecEvent* evt )
{ {
ScopedPtr<SysExecEvent> sevt( evt ); std::unique_ptr<SysExecEvent> sevt(evt);
if( !sevt ) return; if( !sevt ) return;
if( m_Quitting ) 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()) ); 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) if( m_pendingEvents.size() == 1)
m_wakeup.Post(); m_wakeup.Post();
} }
@ -340,7 +341,7 @@ void pxEvtQueue::ProcessEvent( SysExecEvent* evt )
} }
else else
{ {
ScopedPtr<SysExecEvent> deleteMe( evt ); std::unique_ptr<SysExecEvent> deleteMe(evt);
deleteMe->_DoInvokeEvent(); deleteMe->_DoInvokeEvent();
} }
} }
@ -452,9 +453,9 @@ void WaitingForThreadedTaskDialog::OnTerminateApp_Clicked( wxCommandEvent& evt )
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// ExecutorThread Implementations // ExecutorThread Implementations
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
ExecutorThread::ExecutorThread( pxEvtQueue* evthandler ) ExecutorThread::ExecutorThread(pxEvtQueue* evthandler)
: m_EvtHandler(evthandler)
{ {
m_EvtHandler = evthandler;
} }
bool ExecutorThread::IsRunning() const bool ExecutorThread::IsRunning() const
@ -507,7 +508,7 @@ void ExecutorThread::ProcessEvent( SysExecEvent* evt )
m_EvtHandler->ProcessEvent( evt ); m_EvtHandler->ProcessEvent( evt );
else else
{ {
ScopedPtr<SysExecEvent> deleteMe( evt ); std::unique_ptr<SysExecEvent> deleteMe(evt);
deleteMe->_DoInvokeEvent(); deleteMe->_DoInvokeEvent();
} }
} }

View File

@ -23,6 +23,7 @@
#include "MSWstuff.h" #include "MSWstuff.h"
#include <wx/utils.h> #include <wx/utils.h>
#include <memory>
static const KeyAcceleratorCode FULLSCREEN_TOGGLE_ACCELERATOR_GSPANEL=KeyAcceleratorCode( WXK_RETURN ).Alt(); static const KeyAcceleratorCode FULLSCREEN_TOGGLE_ACCELERATOR_GSPANEL=KeyAcceleratorCode( WXK_RETURN ).Alt();
@ -37,7 +38,7 @@ void GSPanel::InitDefaultAccelerators()
typedef KeyAcceleratorCode AAC; 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_F1 ), "States_FreezeCurrentSlot" );
m_Accels->Map( AAC( WXK_F3 ), "States_DefrostCurrentSlot"); m_Accels->Map( AAC( WXK_F3 ), "States_DefrostCurrentSlot");

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/filepicker.h> #include <wx/filepicker.h>
#include <wx/listbox.h> #include <wx/listbox.h>
#include <memory>
using namespace pxSizerFlags; using namespace pxSizerFlags;
@ -150,17 +151,17 @@ bool Panels::BiosSelectorPanel::ValidateEnumerationStatus()
{ {
bool validated = true; 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. // occurs during file enumeration.
ScopedPtr<wxArrayString> bioslist( new wxArrayString() ); std::unique_ptr<wxArrayString> bioslist(new wxArrayString());
if( m_FolderPicker->GetPath().Exists() ) 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) ) if( !m_BiosList || (*bioslist != *m_BiosList) )
validated = false; validated = false;
m_BiosList.SwapPtr( bioslist ); m_BiosList.swap(bioslist);
return validated; return validated;
} }

View File

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

View File

@ -147,7 +147,7 @@ void Panels::GameFixesPanel::Apply()
void Panels::GameFixesPanel::EnableStuff( AppConfig* configToUse ) 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) for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i)
m_checkbox[i]->Enable(m_check_Enable->GetValue() && !configToUse->EnablePresets); m_checkbox[i]->Enable(m_check_Enable->GetValue() && !configToUse->EnablePresets);

View File

@ -17,6 +17,7 @@
#include <wx/dynlib.h> #include <wx/dynlib.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <memory>
#include "App.h" #include "App.h"
#include "AppSaveStates.h" #include "AppSaveStates.h"
@ -256,7 +257,7 @@ void SysExecEvent_ApplyPlugins::InvokeEvent()
{ {
ScopedCoreThreadPause paused_core; ScopedCoreThreadPause paused_core;
ScopedPtr< VmStateBuffer > buffer; std::unique_ptr<VmStateBuffer> buffer;
if( SysHasValidState() ) if( SysHasValidState() )
{ {
@ -268,7 +269,8 @@ void SysExecEvent_ApplyPlugins::InvokeEvent()
// FIXME : We only actually have to save plugins here, except the recovery code // 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 // 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(); saveme.FreezeAll();
} }
@ -546,7 +548,7 @@ void Panels::PluginSelectorPanel::DoRefresh()
wxCommandEvent evt( pxEVT_ShowStatusBar ); wxCommandEvent evt( pxEVT_ShowStatusBar );
GetEventHandler()->AddPendingEvent( evt ); GetEventHandler()->AddPendingEvent( evt );
m_EnumeratorThread.Reassign(new EnumThread( *this )); m_EnumeratorThread.reset(new EnumThread(*this));
if( DisableThreading ) if( DisableThreading )
m_EnumeratorThread->DoNextPlugin( 0 ); m_EnumeratorThread->DoNextPlugin( 0 );
@ -563,11 +565,11 @@ bool Panels::PluginSelectorPanel::ValidateEnumerationStatus()
// re-enumerate plugins, and if anything changed then we need to wipe // re-enumerate plugins, and if anything changed then we need to wipe
// the contents of the combo boxes and re-enumerate everything. // 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. // 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) ) if( !m_FileList || (*pluginlist != *m_FileList) )
validated = false; validated = false;
@ -578,7 +580,7 @@ bool Panels::PluginSelectorPanel::ValidateEnumerationStatus()
return validated; return validated;
} }
m_FileList.SwapPtr( pluginlist ); m_FileList.swap(pluginlist);
// set the gague length a little shorter than the plugin count. 2 reasons: // set the gague length a little shorter than the plugin count. 2 reasons:
// * some of the plugins might be duds. // * 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 // The thread can get canceled and replaced with a new thread, which means all
// pending messages should be ignored. // 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(); 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. // Doesn't modify values - only locks(gray out)/unlocks as necessary.
void Panels::SpeedHacksPanel::EnableStuff( AppConfig* configToUse ) void Panels::SpeedHacksPanel::EnableStuff( AppConfig* configToUse )
{ {
if( !configToUse ) configToUse = g_Conf; if (!configToUse) configToUse = g_Conf.get();
bool hasPreset = configToUse->EnablePresets; bool hasPreset = configToUse->EnablePresets;
bool hacksEnabled = configToUse->EnableSpeedHacks; bool hacksEnabled = configToUse->EnableSpeedHacks;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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