Direct replacement of auto_ptr, equivalent to parts of upstream commits: https://github.com/wxWidgets/wxWidgets/commit/b8c9cd35288a5c94f88ea83bf8c9ee644f99ece1 https://github.com/wxWidgets/wxWidgets/commit/11a5728b327d5f16ef284d737f6329d38ae4d4b1 made by diffing new-er upstream version with fixes included and current file diff --git a/tests/archive/archivetest.cpp b/tests/archive/archivetest.cpp index fa122d1..845ee0b 100644 --- a/tests/archive/archivetest.cpp +++ b/tests/archive/archivetest.cpp @@ -32,7 +32,6 @@ #include using std::string; -using std::auto_ptr; // Check whether member templates can be used @@ -559,7 +558,7 @@ TestEntry& ArchiveTestCase::Add(const char *name, template void ArchiveTestCase::CreateArchive(wxOutputStream& out) { - auto_ptr arc(m_factory->NewStream(out)); + wxScopedPtr arc(m_factory->NewStream(out)); TestEntries::iterator it; OnCreateArchive(*arc); @@ -587,7 +586,7 @@ void ArchiveTestCase::CreateArchive(wxOutputStream& out) if ((choices & 2) || testEntry.IsText()) { // try PutNextEntry(EntryT *pEntry) - auto_ptr entry(m_factory->NewEntry()); + wxScopedPtr entry(m_factory->NewEntry()); entry->SetName(name, wxPATH_UNIX); if (setIsDir) entry->SetIsDir(); @@ -701,8 +700,8 @@ template void ArchiveTestCase::ModifyArchive(wxInputStream& in, wxOutputStream& out) { - auto_ptr arcIn(m_factory->NewStream(in)); - auto_ptr arcOut(m_factory->NewStream(out)); + wxScopedPtr arcIn(m_factory->NewStream(in)); + wxScopedPtr arcOut(m_factory->NewStream(out)); EntryT *pEntry; const wxString deleteName = wxT("bin/bin1000"); @@ -714,7 +713,7 @@ void ArchiveTestCase::ModifyArchive(wxInputStream& in, arcOut->CopyArchiveMetaData(*arcIn); while ((pEntry = arcIn->GetNextEntry()) != NULL) { - auto_ptr entry(pEntry); + wxScopedPtr entry(pEntry); OnSetNotifier(*entry); wxString name = entry->GetName(wxPATH_UNIX); @@ -759,7 +758,7 @@ void ArchiveTestCase::ModifyArchive(wxInputStream& in, // try adding a new entry TestEntry& testEntry = Add(newName.mb_str(), newData); - auto_ptr newentry(m_factory->NewEntry()); + wxScopedPtr newentry(m_factory->NewEntry()); newentry->SetName(newName); newentry->SetDateTime(testEntry.GetDateTime()); newentry->SetSize(testEntry.GetLength()); @@ -782,7 +781,7 @@ void ArchiveTestCase::ExtractArchive(wxInputStream& in) typedef std::list Entries; typedef typename Entries::iterator EntryIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); int expectedTotal = m_testEntries.size(); EntryPtr entry; Entries entries; @@ -991,7 +990,7 @@ void ArchiveTestCase::TestIterator(wxInputStream& in) typedef std::list ArchiveCatalog; typedef typename ArchiveCatalog::iterator CatalogIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); size_t count = 0; #ifdef WXARC_MEMBER_TEMPLATES @@ -1003,7 +1002,7 @@ void ArchiveTestCase::TestIterator(wxInputStream& in) #endif for (CatalogIter it = cat.begin(); it != cat.end(); ++it) { - auto_ptr entry(*it); + wxScopedPtr entry(*it); count += m_testEntries.count(entry->GetName(wxPATH_UNIX)); } @@ -1020,7 +1019,7 @@ void ArchiveTestCase::TestPairIterator(wxInputStream& in) typedef std::map ArchiveCatalog; typedef typename ArchiveCatalog::iterator CatalogIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); size_t count = 0; #ifdef WXARC_MEMBER_TEMPLATES @@ -1032,7 +1031,7 @@ void ArchiveTestCase::TestPairIterator(wxInputStream& in) #endif for (CatalogIter it = cat.begin(); it != cat.end(); ++it) { - auto_ptr entry(it->second); + wxScopedPtr entry(it->second); count += m_testEntries.count(entry->GetName(wxPATH_UNIX)); } @@ -1049,7 +1048,7 @@ void ArchiveTestCase::TestSmartIterator(wxInputStream& in) typedef typename ArchiveCatalog::iterator CatalogIter; typedef wxArchiveIterator > Iter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); #ifdef WXARC_MEMBER_TEMPLATES ArchiveCatalog cat((Iter)*arc, Iter()); @@ -1080,7 +1079,7 @@ void ArchiveTestCase::TestSmartPairIterator(wxInputStream& in) typedef wxArchiveIterator > > PairIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); #ifdef WXARC_MEMBER_TEMPLATES ArchiveCatalog cat((PairIter)*arc, PairIter()); @@ -1108,8 +1107,8 @@ void ArchiveTestCase::ReadSimultaneous(TestInputStream& in) // create two archive input streams TestInputStream in2(in); - auto_ptr arc(m_factory->NewStream(in)); - auto_ptr arc2(m_factory->NewStream(in2)); + wxScopedPtr arc(m_factory->NewStream(in)); + wxScopedPtr arc2(m_factory->NewStream(in2)); // load the catalog #ifdef WXARC_MEMBER_TEMPLATES @@ -1201,7 +1200,7 @@ protected: void CreateArchive(wxOutputStream& out); void ExtractArchive(wxInputStream& in); - auto_ptr m_factory; // factory to make classes + wxScopedPtr m_factory; // factory to make classes int m_options; // test options }; @@ -1241,7 +1240,7 @@ void CorruptionTestCase::runTest() void CorruptionTestCase::CreateArchive(wxOutputStream& out) { - auto_ptr arc(m_factory->NewStream(out)); + wxScopedPtr arc(m_factory->NewStream(out)); arc->PutNextDirEntry(wxT("dir")); arc->PutNextEntry(wxT("file")); @@ -1250,8 +1249,8 @@ void CorruptionTestCase::CreateArchive(wxOutputStream& out) void CorruptionTestCase::ExtractArchive(wxInputStream& in) { - auto_ptr arc(m_factory->NewStream(in)); - auto_ptr entry(arc->GetNextEntry()); + wxScopedPtr arc(m_factory->NewStream(in)); + wxScopedPtr entry(arc->GetNextEntry()); while (entry.get() != NULL) { char buf[1024]; @@ -1259,7 +1258,6 @@ void CorruptionTestCase::ExtractArchive(wxInputStream& in) while (arc->IsOk()) arc->Read(buf, sizeof(buf)); - auto_ptr next(arc->GetNextEntry()); - entry = next; + entry.reset(arc->GetNextEntry()); } } diff --git a/tests/archive/archivetest.h b/tests/archive/archivetest.h index 7a1a306..37a083c 100644 --- a/tests/archive/archivetest.h +++ b/tests/archive/archivetest.h @@ -13,7 +13,7 @@ #include "wx/archive.h" #include "wx/wfstream.h" - +#include "wx/scopedptr.h" /////////////////////////////////////////////////////////////////////////////// // Bit flags for options for the tests @@ -213,7 +213,7 @@ protected: typedef std::map TestEntries; TestEntries m_testEntries; // test data - std::auto_ptr m_factory; // factory to make classes + wxScopedPtr m_factory; // factory to make classes int m_options; // test options wxDateTime m_timeStamp; // timestamp to give test entries int m_id; // select between the possibilites diff --git a/tests/archive/ziptest.cpp b/tests/archive/ziptest.cpp index 3e9cff3..dc3fef5 100644 --- a/tests/archive/ziptest.cpp +++ b/tests/archive/ziptest.cpp @@ -22,7 +22,6 @@ #include "wx/zipstrm.h" using std::string; -using std::auto_ptr; /////////////////////////////////////////////////////////////////////////////// @@ -186,7 +185,7 @@ void ZipPipeTestCase::runTest() TestInputStream in(out, m_id % ((m_options & PipeIn) ? 4 : 3)); wxZipInputStream zip(in); - auto_ptr entry(zip.GetNextEntry()); + wxScopedPtr entry(zip.GetNextEntry()); CPPUNIT_ASSERT(entry.get() != NULL); if ((m_options & PipeIn) == 0) diff --git a/tests/net/socket.cpp b/tests/net/socket.cpp index acd91ae..7e27fc4 100644 --- a/tests/net/socket.cpp +++ b/tests/net/socket.cpp @@ -28,10 +28,11 @@ #include "wx/url.h" #include "wx/sstream.h" #include "wx/evtloop.h" +#include "wx/scopedptr.h" #include -typedef std::auto_ptr wxSockAddressPtr; -typedef std::auto_ptr wxSocketClientPtr; +typedef wxScopedPtr wxSockAddressPtr; +typedef wxScopedPtr wxSocketClientPtr; static wxString gs_serverHost(wxGetenv("WX_TEST_SERVER")); @@ -257,7 +258,7 @@ void SocketTestCase::UrlTest() wxURL url("http://" + gs_serverHost); - const std::auto_ptr in(url.GetInputStream()); + const wxScopedPtr in(url.GetInputStream()); CPPUNIT_ASSERT( in.get() ); wxStringOutputStream out; diff --git a/tests/streams/largefile.cpp b/tests/streams/largefile.cpp index 9c6c481..59fca24 100644 --- a/tests/streams/largefile.cpp +++ b/tests/streams/largefile.cpp @@ -33,6 +33,7 @@ #include "wx/filename.h" #include "wx/wfstream.h" +#include "wx/scopedptr.h" #ifdef __WINDOWS__ #include "wx/msw/wrapwin.h" @@ -51,7 +52,6 @@ #define fileno _fileno #endif -using std::auto_ptr; /////////////////////////////////////////////////////////////////////////////// @@ -120,7 +120,7 @@ void LargeFileTest::runTest() // write a large file { - auto_ptr out(MakeOutStream(tmpfile.m_name)); + wxScopedPtr out(MakeOutStream(tmpfile.m_name)); // write 'A's at [ 0x7fffffbf, 0x7fffffff [ pos = 0x7fffffff - size; @@ -154,7 +154,7 @@ void LargeFileTest::runTest() // read the large file back { - auto_ptr in(MakeInStream(tmpfile.m_name)); + wxScopedPtr in(MakeInStream(tmpfile.m_name)); char buf[size]; if (haveLFS) { @@ -218,7 +218,7 @@ protected: wxInputStream *LargeFileTest_wxFile::MakeInStream(const wxString& name) const { - auto_ptr in(new wxFileInputStream(name)); + wxScopedPtr in(new wxFileInputStream(name)); CPPUNIT_ASSERT(in->IsOk()); return in.release(); } @@ -250,7 +250,7 @@ protected: wxInputStream *LargeFileTest_wxFFile::MakeInStream(const wxString& name) const { - auto_ptr in(new wxFFileInputStream(name)); + wxScopedPtr in(new wxFFileInputStream(name)); CPPUNIT_ASSERT(in->IsOk()); return in.release(); } diff --git a/wxWidgets-3.0.5.1/src/stc/scintilla/src/Editor.cxx.old b/wxWidgets-3.0.5.1/src/stc/scintilla/src/Editor.cxx index 2081df2..a8c8572 100644 --- a/src/stc/scintilla/src/Editor.cxx +++ b/src/stc/scintilla/src/Editor.cxx @@ -41,6 +41,7 @@ #include "Selection.h" #include "PositionCache.h" #include "Editor.h" +#include "wx/scopedptr.h" #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -5706,7 +5707,7 @@ long Editor::FindText( Sci_TextToFind *ft = reinterpret_cast(lParam); int lengthFound = istrlen(ft->lpstrText); - std::auto_ptr pcf(CaseFolderForEncoding()); + wxScopedPtr pcf(CaseFolderForEncoding()); int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0,