From abb9859b8928ea9be4939beee10ae17c0bb60e12 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 6 Mar 2023 23:37:53 +0100 Subject: [PATCH] Replace wxScopedPtr with std::unique_ptr in the samples too No real changes, just use the standard class instead of the wx one. --- samples/archive/archive.cpp | 13 +++++++------ samples/exec/exec.cpp | 5 +++-- samples/image/image.cpp | 7 ++++--- samples/preferences/preferences.cpp | 5 +++-- samples/printing/printing.cpp | 5 +++-- samples/shaped/shaped.cpp | 5 +++-- samples/sockets/client.cpp | 5 +++-- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/samples/archive/archive.cpp b/samples/archive/archive.cpp index 312f942a1c..1d61b59da2 100644 --- a/samples/archive/archive.cpp +++ b/samples/archive/archive.cpp @@ -18,11 +18,12 @@ #include "wx/app.h" #include "wx/cmdline.h" #include "wx/filename.h" -#include "wx/scopedptr.h" #include "wx/vector.h" #include "wx/wfstream.h" #include "wx/zipstrm.h" +#include + class ArchiveApp: public wxAppConsole { public: @@ -198,7 +199,7 @@ int ArchiveApp::DoCreate() wxTempFileOutputStream fileOutputStream(m_archiveFileName); if (m_archiveClassFactory) { - wxScopedPtr archiveOutputStream(m_archiveClassFactory->NewStream(fileOutputStream)); + std::unique_ptr archiveOutputStream(m_archiveClassFactory->NewStream(fileOutputStream)); if (m_archiveClassFactory->GetProtocol().IsSameAs("zip", false) && m_forceZip64) reinterpret_cast(archiveOutputStream.get())->SetFormat(wxZIP_FORMAT_ZIP64); @@ -229,7 +230,7 @@ int ArchiveApp::DoCreate() return -1; } - wxScopedPtr filterOutputStream(m_filterClassFactory->NewStream(fileOutputStream)); + std::unique_ptr filterOutputStream(m_filterClassFactory->NewStream(fileOutputStream)); wxFileInputStream inputFileStream(*m_fileNames.begin()); if (!inputFileStream.IsOk()) { @@ -253,7 +254,7 @@ int ArchiveApp::DoList() if (m_archiveClassFactory) { - wxScopedPtr archiveStream(m_archiveClassFactory->NewStream(fileInputStream)); + std::unique_ptr archiveStream(m_archiveClassFactory->NewStream(fileInputStream)); wxPrintf("Archive: %s\n", m_archiveFileName); wxPrintf("Length Date Time Name\n"); wxPrintf("---------- ---------- -------- ----\n"); @@ -291,7 +292,7 @@ int ArchiveApp::DoExtract() if (m_archiveClassFactory) { - wxScopedPtr archiveStream(m_archiveClassFactory->NewStream(fileInputStream)); + std::unique_ptr archiveStream(m_archiveClassFactory->NewStream(fileInputStream)); wxPrintf("Extracting from: %s\n", m_archiveFileName); for (wxArchiveEntry* entry = archiveStream->GetNextEntry(); entry; entry = archiveStream->GetNextEntry()) @@ -306,7 +307,7 @@ int ArchiveApp::DoExtract() } else { - wxScopedPtr filterStream(m_filterClassFactory->NewStream(fileInputStream)); + std::unique_ptr filterStream(m_filterClassFactory->NewStream(fileInputStream)); wxPrintf("Extracting single file from: %s\n", m_archiveFileName); wxTempFileOutputStream outputFileStream(wxFileName(m_archiveFileName).GetName()); if (!CopyStreamData(*filterStream, outputFileStream, -1)) diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index b2e9b9071e..a3437a5a79 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -52,7 +52,6 @@ #include "wx/numdlg.h" #include "wx/textdlg.h" #include "wx/ffile.h" -#include "wx/scopedptr.h" #include "wx/stopwatch.h" #include "wx/process.h" @@ -63,6 +62,8 @@ #include "wx/dde.h" #endif // __WINDOWS__ +#include + #ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif @@ -1121,7 +1122,7 @@ void MyFrame::OnShowCommandForExt(wxCommandEvent& WXUNUSED(event)) s_ext = ext; - wxScopedPtr + std::unique_ptr ft(wxTheMimeTypesManager->GetFileTypeFromExtension(ext)); if ( !ft ) { diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 559ea2c868..98b20b8190 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -24,7 +24,6 @@ #include "wx/mstream.h" #include "wx/wfstream.h" #include "wx/quantize.h" -#include "wx/scopedptr.h" #include "wx/stopwatch.h" #include "wx/versioninfo.h" #include "wx/artprov.h" @@ -48,6 +47,8 @@ #include "canvas.h" +#include + #ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif @@ -1270,7 +1271,7 @@ private: // Use wxGraphicsContext if available for alpha support. #if wxUSE_GRAPHICS_CONTEXT - wxScopedPtr const + std::unique_ptr const gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc)); gc->DrawBitmap(m_bitmap, 0, 0, sizeWin.x, sizeWin.y); @@ -1409,7 +1410,7 @@ private: void OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); - wxScopedPtr gc(wxGraphicsContext::Create(dc)); + std::unique_ptr gc(wxGraphicsContext::Create(dc)); wxGraphicsBitmap gb(gc->CreateBitmapFromImage(m_image)); gc->SetFont(*wxNORMAL_FONT, *wxBLACK); diff --git a/samples/preferences/preferences.cpp b/samples/preferences/preferences.cpp index 86367aabde..c3b736ae4b 100644 --- a/samples/preferences/preferences.cpp +++ b/samples/preferences/preferences.cpp @@ -16,7 +16,6 @@ #include "wx/app.h" #include "wx/config.h" #include "wx/panel.h" -#include "wx/scopedptr.h" #include "wx/menu.h" #include "wx/checkbox.h" #include "wx/listbox.h" @@ -25,6 +24,8 @@ #include "wx/artprov.h" #include "wx/frame.h" +#include + // This struct combines the settings edited in the preferences dialog. struct MySettings { @@ -57,7 +58,7 @@ public: private: class MyFrame* m_frame; - wxScopedPtr m_prefEditor; + std::unique_ptr m_prefEditor; MySettings m_settings; }; diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 93fd462338..8222104288 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -35,7 +35,8 @@ #if wxUSE_GRAPHICS_CONTEXT #include "wx/graphics.h" - #include "wx/scopedptr.h" + + #include #endif #ifdef __WXMAC__ @@ -212,7 +213,7 @@ void MyApp::Draw(wxDC&dc) dc.DrawBitmap( m_bitmap, dc.FromDIP(10), dc.FromDIP(10) ); #if wxUSE_GRAPHICS_CONTEXT - wxScopedPtr gc(wxGraphicsContext::CreateFromUnknownDC(dc)); + std::unique_ptr gc(wxGraphicsContext::CreateFromUnknownDC(dc)); if (gc) { diff --git a/samples/shaped/shaped.cpp b/samples/shaped/shaped.cpp index 5e0809f450..d15db83548 100644 --- a/samples/shaped/shaped.cpp +++ b/samples/shaped/shaped.cpp @@ -36,10 +36,11 @@ #include "wx/dcclient.h" #include "wx/graphics.h" #include "wx/image.h" -#include "wx/scopedptr.h" #include "wx/sizer.h" #include "wx/slider.h" +#include + #ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif @@ -539,7 +540,7 @@ SeeThroughFrame::Create(wxWindow* parent) void SeeThroughFrame::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxPaintDC dc(this); - wxScopedPtr gc(wxGraphicsContext::Create(dc)); + std::unique_ptr gc(wxGraphicsContext::Create(dc)); // Draw 3 bands: one opaque, one semi-transparent and one transparent. const wxSize size = GetClientSize(); diff --git a/samples/sockets/client.cpp b/samples/sockets/client.cpp index f3786fb3b9..1556a4afda 100644 --- a/samples/sockets/client.cpp +++ b/samples/sockets/client.cpp @@ -28,7 +28,8 @@ #include "wx/url.h" #include "wx/sstream.h" #include "wx/thread.h" -#include "wx/scopedptr.h" + +#include // -------------------------------------------------------------------------- // resources @@ -590,7 +591,7 @@ void DoDownload(const wxString& urlname) // Try to get the input stream (connects to the given URL) wxLogMessage("Establishing connection to \"%s\"...", urlname); - const wxScopedPtr data(url.GetInputStream()); + const std::unique_ptr data(url.GetInputStream()); if ( !data.get() ) { wxLogError("Failed to retrieve URL \"%s\"", urlname);