Replace wxScopedPtr with std::unique_ptr in the samples too

No real changes, just use the standard class instead of the wx one.
This commit is contained in:
Vadim Zeitlin
2023-03-06 23:37:53 +01:00
parent 363f0988cf
commit abb9859b89
7 changed files with 26 additions and 19 deletions
+7 -6
View File
@@ -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 <memory>
class ArchiveApp: public wxAppConsole
{
public:
@@ -198,7 +199,7 @@ int ArchiveApp::DoCreate()
wxTempFileOutputStream fileOutputStream(m_archiveFileName);
if (m_archiveClassFactory)
{
wxScopedPtr<wxArchiveOutputStream> archiveOutputStream(m_archiveClassFactory->NewStream(fileOutputStream));
std::unique_ptr<wxArchiveOutputStream> archiveOutputStream(m_archiveClassFactory->NewStream(fileOutputStream));
if (m_archiveClassFactory->GetProtocol().IsSameAs("zip", false) && m_forceZip64)
reinterpret_cast<wxZipOutputStream*>(archiveOutputStream.get())->SetFormat(wxZIP_FORMAT_ZIP64);
@@ -229,7 +230,7 @@ int ArchiveApp::DoCreate()
return -1;
}
wxScopedPtr<wxFilterOutputStream> filterOutputStream(m_filterClassFactory->NewStream(fileOutputStream));
std::unique_ptr<wxFilterOutputStream> filterOutputStream(m_filterClassFactory->NewStream(fileOutputStream));
wxFileInputStream inputFileStream(*m_fileNames.begin());
if (!inputFileStream.IsOk())
{
@@ -253,7 +254,7 @@ int ArchiveApp::DoList()
if (m_archiveClassFactory)
{
wxScopedPtr<wxArchiveInputStream> archiveStream(m_archiveClassFactory->NewStream(fileInputStream));
std::unique_ptr<wxArchiveInputStream> 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<wxArchiveInputStream> archiveStream(m_archiveClassFactory->NewStream(fileInputStream));
std::unique_ptr<wxArchiveInputStream> 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<wxFilterInputStream> filterStream(m_filterClassFactory->NewStream(fileInputStream));
std::unique_ptr<wxFilterInputStream> 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))
+3 -2
View File
@@ -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 <memory>
#ifndef wxHAS_IMAGES_IN_RESOURCES
#include "../sample.xpm"
#endif
@@ -1121,7 +1122,7 @@ void MyFrame::OnShowCommandForExt(wxCommandEvent& WXUNUSED(event))
s_ext = ext;
wxScopedPtr<wxFileType>
std::unique_ptr<wxFileType>
ft(wxTheMimeTypesManager->GetFileTypeFromExtension(ext));
if ( !ft )
{
+4 -3
View File
@@ -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 <memory>
#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<wxGraphicsContext> const
std::unique_ptr<wxGraphicsContext> 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<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
wxGraphicsBitmap gb(gc->CreateBitmapFromImage(m_image));
gc->SetFont(*wxNORMAL_FONT, *wxBLACK);
+3 -2
View File
@@ -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 <memory>
// This struct combines the settings edited in the preferences dialog.
struct MySettings
{
@@ -57,7 +58,7 @@ public:
private:
class MyFrame* m_frame;
wxScopedPtr<wxPreferencesEditor> m_prefEditor;
std::unique_ptr<wxPreferencesEditor> m_prefEditor;
MySettings m_settings;
};
+3 -2
View File
@@ -35,7 +35,8 @@
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#include "wx/scopedptr.h"
#include <memory>
#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<wxGraphicsContext> gc(wxGraphicsContext::CreateFromUnknownDC(dc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::CreateFromUnknownDC(dc));
if (gc)
{
+3 -2
View File
@@ -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 <memory>
#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<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
// Draw 3 bands: one opaque, one semi-transparent and one transparent.
const wxSize size = GetClientSize();
+3 -2
View File
@@ -28,7 +28,8 @@
#include "wx/url.h"
#include "wx/sstream.h"
#include "wx/thread.h"
#include "wx/scopedptr.h"
#include <memory>
// --------------------------------------------------------------------------
// 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<wxInputStream> data(url.GetInputStream());
const std::unique_ptr<wxInputStream> data(url.GetInputStream());
if ( !data.get() )
{
wxLogError("Failed to retrieve URL \"%s\"", urlname);