utilities: Convert ScopedPtr to unique_ptr

This commit is contained in:
Jonathan Li 2016-01-27 17:51:08 +00:00
parent 499fed40f2
commit a74677acf7
7 changed files with 30 additions and 31 deletions

View File

@ -246,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

@ -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

@ -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

@ -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;
}