From a4e8e7066d54ff036cd94e7b8fdd448ade76b99a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 6 Mar 2023 23:53:13 +0100 Subject: [PATCH] Replace all remaining occurrences of wxScopedPtr Use std::unique_ptr<> in the library code instead of the legacy wx class. --- include/wx/dcsvg.h | 7 ++++--- include/wx/generic/grideditors.h | 6 ++++-- include/wx/private/webrequest.h | 9 +++++---- include/wx/qt/app.h | 4 +++- include/wx/qt/dcclient.h | 4 ++-- include/wx/qt/window.h | 6 ++++-- src/common/any.cpp | 7 ++++--- src/common/appbase.cpp | 4 +++- src/common/docview.cpp | 7 ++++--- src/common/filefn.cpp | 5 +++-- src/common/imagbmp.cpp | 7 ++++--- src/common/rendcmn.cpp | 4 +--- src/common/sizer.cpp | 6 +++--- src/common/taskbarcmn.cpp | 4 ++-- src/common/translation.cpp | 9 +++++---- src/common/webrequest.cpp | 6 +++--- src/generic/activityindicator.cpp | 5 +++-- src/generic/filepickerg.cpp | 4 ++-- src/generic/markuptext.cpp | 5 +++-- src/generic/preferencesg.cpp | 5 +++-- src/generic/statbmpg.cpp | 5 +++-- src/generic/treelist.cpp | 5 +++-- src/gtk/menu.cpp | 5 +++-- src/gtk/nonownedwnd.cpp | 7 ++++--- src/msw/bitmap.cpp | 5 +++-- src/msw/dib.cpp | 5 +++-- src/msw/filedlg.cpp | 7 ++++--- src/msw/nonownedwnd.cpp | 7 ++++--- src/msw/taskbarbutton.cpp | 9 +++++---- src/qt/graphics.cpp | 5 +++-- src/ribbon/toolbar.cpp | 5 +++-- src/unix/appunix.cpp | 5 +++-- src/unix/evtloopunix.cpp | 7 ++++--- src/unix/glegl.cpp | 6 +++--- src/unix/utilsunx.cpp | 11 ++++++----- src/xml/xml.cpp | 5 +++-- src/xrc/xh_animatctrl.cpp | 7 ++++--- src/xrc/xmlres.cpp | 7 +++---- 38 files changed, 129 insertions(+), 98 deletions(-) diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index f80f27c31b..41d913d3c9 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -16,7 +16,8 @@ #include "wx/string.h" #include "wx/filename.h" #include "wx/dc.h" -#include "wx/scopedptr.h" + +#include #define wxSVGVersion wxT("v0101") @@ -271,8 +272,8 @@ private: bool m_graphics_changed; // set by Set{Brush,Pen}() int m_width, m_height; double m_dpi; - wxScopedPtr m_outfile; - wxScopedPtr m_bmp_handler; // class to handle bitmaps + std::unique_ptr m_outfile; + std::unique_ptr m_bmp_handler; // class to handle bitmaps wxSVGShapeRenderingMode m_renderingMode; // The clipping nesting level is incremented by every call to diff --git a/include/wx/generic/grideditors.h b/include/wx/generic/grideditors.h index 30ac9543d6..b82e8669e0 100644 --- a/include/wx/generic/grideditors.h +++ b/include/wx/generic/grideditors.h @@ -15,7 +15,9 @@ #if wxUSE_GRID -#include "wx/scopedptr.h" +#if wxUSE_VALIDATORS + #include +#endif class wxGridCellEditorEvtHandler : public wxEvtHandler { @@ -102,7 +104,7 @@ protected: private: size_t m_maxChars; // max number of chars allowed #if wxUSE_VALIDATORS - wxScopedPtr m_validator; + std::unique_ptr m_validator; #endif wxString m_value; }; diff --git a/include/wx/private/webrequest.h b/include/wx/private/webrequest.h index 88f2ed1fef..235727232b 100644 --- a/include/wx/private/webrequest.h +++ b/include/wx/private/webrequest.h @@ -12,10 +12,11 @@ #include "wx/ffile.h" #include "wx/hashmap.h" -#include "wx/scopedptr.h" #include "wx/private/refcountermt.h" +#include + WX_DECLARE_STRING_HASH_MAP(wxString, wxWebRequestHeaderMap); // Default buffer size when a fixed-size buffer must be used. @@ -63,7 +64,7 @@ public: void SetData(const wxString& text, const wxString& contentType, const wxMBConv& conv = wxConvUTF8); - bool SetData(wxScopedPtr& dataStream, const wxString& contentType, wxFileOffset dataSize = wxInvalidOffset); + bool SetData(std::unique_ptr& dataStream, const wxString& contentType, wxFileOffset dataSize = wxInvalidOffset); void SetStorage(wxWebRequest::Storage storage) { m_storage = storage; } @@ -111,7 +112,7 @@ protected: wxWebRequest::Storage m_storage; wxWebRequestHeaderMap m_headers; wxFileOffset m_dataSize; - wxScopedPtr m_dataStream; + std::unique_ptr m_dataStream; bool m_peerVerifyDisabled; wxWebRequestImpl(wxWebSession& session, @@ -204,7 +205,7 @@ private: wxMemoryBuffer m_readBuffer; mutable wxFFile m_file; - mutable wxScopedPtr m_stream; + mutable std::unique_ptr m_stream; wxDECLARE_NO_COPY_CLASS(wxWebResponseImpl); }; diff --git a/include/wx/qt/app.h b/include/wx/qt/app.h index c2a3ea5d4c..1dcaab0d24 100644 --- a/include/wx/qt/app.h +++ b/include/wx/qt/app.h @@ -11,6 +11,8 @@ #include +#include + class QApplication; class WXDLLIMPEXP_CORE wxApp : public wxAppBase { @@ -21,7 +23,7 @@ public: virtual bool Initialize(int& argc, wxChar **argv) override; private: - wxScopedPtr m_qtApplication; + std::unique_ptr m_qtApplication; int m_qtArgc; wxScopedArray m_qtArgv; diff --git a/include/wx/qt/dcclient.h b/include/wx/qt/dcclient.h index c9a5986838..76dd03e15e 100644 --- a/include/wx/qt/dcclient.h +++ b/include/wx/qt/dcclient.h @@ -10,7 +10,7 @@ #include "wx/qt/dc.h" -#include "wx/scopedptr.h" +#include class QPicture; @@ -39,7 +39,7 @@ public: ~wxClientDCImpl(); private: - wxScopedPtr m_pict; + std::unique_ptr m_pict; wxDECLARE_CLASS(wxClientDCImpl); wxDECLARE_NO_COPY_CLASS(wxClientDCImpl); diff --git a/include/wx/qt/window.h b/include/wx/qt/window.h index c557b05e37..e6419de987 100644 --- a/include/wx/qt/window.h +++ b/include/wx/qt/window.h @@ -9,6 +9,8 @@ #ifndef _WX_QT_WINDOW_H_ #define _WX_QT_WINDOW_H_ +#include + class QShortcut; template < class T > class QList; @@ -243,13 +245,13 @@ private: bool QtSetBackgroundStyle(); QPicture *m_qtPicture; // not owned - wxScopedPtr m_qtPainter; // always allocated + std::unique_ptr m_qtPainter; // always allocated bool m_mouseInside; #if wxUSE_ACCEL wxVector m_qtShortcuts; // owned by whatever GetHandle() returns - wxScopedPtr m_qtShortcutHandler; // always allocated + std::unique_ptr m_qtShortcutHandler; // always allocated bool m_processingShortcut; #endif // wxUSE_ACCEL diff --git a/src/common/any.cpp b/src/common/any.cpp index e203228e10..f86c9a2764 100644 --- a/src/common/any.cpp +++ b/src/common/any.cpp @@ -25,7 +25,8 @@ #include "wx/module.h" #include "wx/hashmap.h" #include "wx/hashset.h" -#include "wx/scopedptr.h" + +#include using namespace wxPrivate; @@ -118,9 +119,9 @@ private: wxVector m_anyToVariantRegs; }; -static wxScopedPtr& GetAnyValueTypeGlobals() +static std::unique_ptr& GetAnyValueTypeGlobals() { - static wxScopedPtr s_wxAnyValueTypeGlobals; + static std::unique_ptr s_wxAnyValueTypeGlobals; if ( !s_wxAnyValueTypeGlobals ) { // Notice that it is _not_ sufficient to just initialize the static diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index dbc941eba1..dd922685ba 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -74,6 +74,8 @@ #include "wx/recguard.h" #endif // wxDEBUG_LEVEL +#include + // wxABI_VERSION can be defined when compiling applications but it should be // left undefined when compiling the library itself, it is then set to its // default value in version.h @@ -397,7 +399,7 @@ bool wxAppConsoleBase::Yield(bool onlyIfNeeded) if ( loop ) return loop->Yield(onlyIfNeeded); - wxScopedPtr tmpLoop(CreateMainLoop()); + std::unique_ptr tmpLoop(CreateMainLoop()); return tmpLoop->Yield(onlyIfNeeded); } diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 1b94d90ce5..47d484a7e8 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -55,7 +55,6 @@ #include "wx/stdpaths.h" #include "wx/vector.h" #include "wx/scopedarray.h" -#include "wx/scopedptr.h" #include "wx/scopeguard.h" #include "wx/except.h" @@ -68,6 +67,8 @@ #include "wx/wfstream.h" #endif +#include + // ---------------------------------------------------------------------------- // wxWidgets macros // ---------------------------------------------------------------------------- @@ -880,7 +881,7 @@ wxDocTemplate::~wxDocTemplate() wxDocument *wxDocTemplate::CreateDocument(const wxString& path, long flags) { // InitDocument() is supposed to delete the document object if its - // initialization fails so don't use wxScopedPtr<> here: this is fragile + // initialization fails so don't use unique_ptr<> here: this is fragile // but unavoidable because the default implementation uses CreateView() // which may -- or not -- create a wxView and if it does create it and its // initialization fails then the view destructor will delete the document @@ -924,7 +925,7 @@ wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags) wxView *wxDocTemplate::CreateView(wxDocument *doc, long flags) { - wxScopedPtr view(DoCreateView()); + std::unique_ptr view(DoCreateView()); if ( !view ) return nullptr; diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 77d984eda5..f3227d9d57 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -34,7 +34,6 @@ #include "wx/filename.h" #include "wx/dir.h" -#include "wx/scopedptr.h" #include "wx/tokenzr.h" // there are just too many of those... @@ -48,6 +47,8 @@ #include #include +#include + #if defined(__WXMAC__) #include "wx/osx/private.h" // includes mac headers #endif @@ -669,7 +670,7 @@ bool wxDirExists(const wxString& pathName) // Get first file name matching given wild card. -static wxScopedPtr gs_dir; +static std::unique_ptr gs_dir; static wxString gs_dirPath; wxString wxFindFirstFile(const wxString& spec, int flags) diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 8011b7dfc7..3cf5db45af 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -30,13 +30,14 @@ #include "wx/wfstream.h" #include "wx/quantize.h" #include "wx/scopedarray.h" -#include "wx/scopedptr.h" #include "wx/anidecod.h" #include "wx/private/icondir.h" // For memcpy #include +#include + // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- @@ -269,10 +270,10 @@ bool wxBMPHandler::SaveDib(wxImage *image, } #if wxUSE_PALETTE - wxScopedPtr palette; // entries for quantized images + std::unique_ptr palette; // entries for quantized images #endif // wxUSE_PALETTE wxScopedArray rgbquad; // for the RGBQUAD bytes for the colormap - wxScopedPtr q_image; // destination for quantized image + std::unique_ptr q_image; // destination for quantized image // if <24bpp use quantization to reduce colors for *some* of the formats if ( (format == wxBMP_1BPP) || (format == wxBMP_4BPP) || diff --git a/src/common/rendcmn.cpp b/src/common/rendcmn.cpp index 232f29091e..a6b3d0f068 100644 --- a/src/common/rendcmn.cpp +++ b/src/common/rendcmn.cpp @@ -28,8 +28,6 @@ #include "wx/apptrait.h" #include "wx/renderer.h" -#include "wx/scopedptr.h" - #if wxUSE_DYNLIB_CLASS #include "wx/dynlib.h" #endif // wxUSE_DYNLIB_CLASS @@ -38,7 +36,7 @@ // wxRendererPtr: auto pointer holding the global renderer // ---------------------------------------------------------------------------- -typedef wxScopedPtr wxRendererPtrBase; +using wxRendererPtrBase = std::unique_ptr; class wxRendererPtr : public wxRendererPtrBase { diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 238c25f631..b4ef2a05b4 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -32,8 +32,8 @@ #include "wx/vector.h" #include "wx/listimpl.cpp" #include "wx/private/window.h" -#include "wx/scopedptr.h" +#include //--------------------------------------------------------------------------- @@ -832,7 +832,7 @@ wxSizerItem* wxSizer::DoInsert( size_t index, wxSizerItem *item ) } private: - wxScopedPtr m_item; + std::unique_ptr m_item; }; ContainingSizerGuard guard( item ); @@ -1527,7 +1527,7 @@ wxGridSizer::wxGridSizer( int rows, int cols, const wxSize& gap ) wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item) { // Ensure that the item will be deleted in case of exception. - wxScopedPtr scopedItem( item ); + std::unique_ptr scopedItem( item ); // if only the number of columns or the number of rows is specified for a // sizer, arbitrarily many items can be added to it but if both of them are diff --git a/src/common/taskbarcmn.cpp b/src/common/taskbarcmn.cpp index 000264e6db..4d96230872 100644 --- a/src/common/taskbarcmn.cpp +++ b/src/common/taskbarcmn.cpp @@ -22,7 +22,7 @@ #include "wx/menu.h" #endif -#include "wx/scopedptr.h" +#include extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete; @@ -46,7 +46,7 @@ wxEND_EVENT_TABLE() void wxTaskBarIconBase::OnRightButtonDown(wxTaskBarIconEvent& WXUNUSED(event)) { - wxScopedPtr menuDeleter; + std::unique_ptr menuDeleter; wxMenu *menu = GetPopupMenu(); if ( !menu ) { diff --git a/src/common/translation.cpp b/src/common/translation.cpp index c00969e94e..d76c8d34b2 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -43,7 +43,6 @@ #include "wx/filename.h" #include "wx/tokenzr.h" #include "wx/fontmap.h" -#include "wx/scopedptr.h" #include "wx/stdpaths.h" #include "wx/version.h" #include "wx/private/threadinfo.h" @@ -56,6 +55,8 @@ #include "wx/msw/missing.h" #endif +#include + // ---------------------------------------------------------------------------- // simple types // ---------------------------------------------------------------------------- @@ -1084,7 +1085,7 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash, // conversion to use to convert catalog strings to the GUI encoding wxMBConv *inputConv = nullptr; - wxScopedPtr inputConvPtr; // just to delete inputConv if needed + std::unique_ptr inputConvPtr; // just to delete inputConv if needed if ( !m_charset.empty() ) { @@ -1157,7 +1158,7 @@ wxMsgCatalog::~wxMsgCatalog() = default; wxMsgCatalog *wxMsgCatalog::CreateFromFile(const wxString& filename, const wxString& domain) { - wxScopedPtr cat(new wxMsgCatalog(domain)); + std::unique_ptr cat(new wxMsgCatalog(domain)); wxMsgCatalogFile file; @@ -1174,7 +1175,7 @@ wxMsgCatalog *wxMsgCatalog::CreateFromFile(const wxString& filename, wxMsgCatalog *wxMsgCatalog::CreateFromData(const wxScopedCharBuffer& data, const wxString& domain) { - wxScopedPtr cat(new wxMsgCatalog(domain)); + std::unique_ptr cat(new wxMsgCatalog(domain)); wxMsgCatalogFile file; diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index ccb1c22dd7..82914c5470 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -113,13 +113,13 @@ void wxWebRequestImpl::SetData(const wxString& text, const wxString& contentType { m_dataText = text.mb_str(conv); - wxScopedPtr + std::unique_ptr stream(new wxMemoryInputStream(m_dataText, m_dataText.length())); SetData(stream, contentType); } bool -wxWebRequestImpl::SetData(wxScopedPtr& dataStream, +wxWebRequestImpl::SetData(std::unique_ptr& dataStream, const wxString& contentType, wxFileOffset dataSize) { @@ -431,7 +431,7 @@ wxWebRequest::SetData(wxInputStream* dataStream, wxFileOffset dataSize) { // Ensure that the stream is destroyed even we return below. - wxScopedPtr streamPtr(dataStream); + std::unique_ptr streamPtr(dataStream); wxCHECK_IMPL( false ); diff --git a/src/generic/activityindicator.cpp b/src/generic/activityindicator.cpp index 72d173e089..76c7ffbd3c 100644 --- a/src/generic/activityindicator.cpp +++ b/src/generic/activityindicator.cpp @@ -30,7 +30,8 @@ #endif // WX_PRECOMP #include "wx/graphics.h" -#include "wx/scopedptr.h" + +#include // ---------------------------------------------------------------------------- // constants @@ -121,7 +122,7 @@ private: { wxPaintDC pdc(m_win); - wxScopedPtr const + std::unique_ptr const gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(pdc)); const wxSize size = m_win->GetClientSize(); diff --git a/src/generic/filepickerg.cpp b/src/generic/filepickerg.cpp index 0f1f642be5..7a1d228c6a 100644 --- a/src/generic/filepickerg.cpp +++ b/src/generic/filepickerg.cpp @@ -25,7 +25,7 @@ #include "wx/filename.h" #include "wx/filepicker.h" -#include "wx/scopedptr.h" +#include // ============================================================================ @@ -89,7 +89,7 @@ bool wxGenericFileDirButton::Create(wxWindow *parent, void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) { - wxScopedPtr p(CreateDialog()); + std::unique_ptr p(CreateDialog()); if (p->ShowModal() == wxID_OK) { // save updated path in m_path diff --git a/src/generic/markuptext.cpp b/src/generic/markuptext.cpp index 394564b4aa..4ebbdc4f6f 100644 --- a/src/generic/markuptext.cpp +++ b/src/generic/markuptext.cpp @@ -35,7 +35,8 @@ #if wxUSE_GRAPHICS_CONTEXT #include "wx/graphics.h" - #include "wx/scopedptr.h" + + #include #endif namespace @@ -292,7 +293,7 @@ public: private: #if wxUSE_GRAPHICS_CONTEXT - wxScopedPtr m_gc; + std::unique_ptr m_gc; #endif wxWindow* const m_win; int const m_rendererFlags; diff --git a/src/generic/preferencesg.cpp b/src/generic/preferencesg.cpp index bcfe9011f7..5a9663194e 100644 --- a/src/generic/preferencesg.cpp +++ b/src/generic/preferencesg.cpp @@ -30,10 +30,11 @@ #include "wx/notebook.h" #include "wx/sizer.h" #include "wx/sharedptr.h" -#include "wx/scopedptr.h" #include "wx/scopeguard.h" #include "wx/vector.h" +#include + namespace { @@ -205,7 +206,7 @@ public: virtual void Show(wxWindow* parent) override { - wxScopedPtr dlg(CreateDialog(parent)); + std::unique_ptr dlg(CreateDialog(parent)); // Store it for Dismiss() but ensure that the pointer is reset to nullptr // when the dialog is destroyed on leaving this function. diff --git a/src/generic/statbmpg.cpp b/src/generic/statbmpg.cpp index e40ea89b01..e58d3016a2 100644 --- a/src/generic/statbmpg.cpp +++ b/src/generic/statbmpg.cpp @@ -19,7 +19,8 @@ #if wxUSE_GRAPHICS_CONTEXT #include "wx/graphics.h" - #include "wx/scopedptr.h" + + #include #else #include "wx/image.h" #include "wx/math.h" @@ -92,7 +93,7 @@ void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event)) wxDouble x = (drawSize.x - w) / 2; wxDouble y = (drawSize.y - h) / 2; #if wxUSE_GRAPHICS_CONTEXT - wxScopedPtr const + std::unique_ptr const gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc)); gc->DrawBitmap(bitmap, x, y, w, h); #else diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index 324e0477ca..eb903ace00 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -30,7 +30,8 @@ #include "wx/dataview.h" #include "wx/renderer.h" #include "wx/scopedarray.h" -#include "wx/scopedptr.h" + +#include // ---------------------------------------------------------------------------- // Constants @@ -486,7 +487,7 @@ wxTreeListModel::InsertItem(Node* parent, dvc->SetIndent(dvc->GetIndent()); } - wxScopedPtr + std::unique_ptr newItem(new Node(parent, text, imageClosed, imageOpened, data)); // If we have no children at all, then inserting as last child is the same diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 2ef76ae8ea..213109586a 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -24,7 +24,8 @@ #if wxUSE_ACCEL #include "wx/accel.h" - #include "wx/scopedptr.h" + + #include #endif // wxUSE_ACCEL #include "wx/stockitem.h" @@ -1433,7 +1434,7 @@ void GtkAccel::Init(const wxAcceleratorEntry* entry) GtkAccel::GtkAccel(const wxMenuItem* item) { - wxScopedPtr accel(item->GetAccel()); + std::unique_ptr accel(item->GetAccel()); Init(accel.get()); #ifndef __WXGTK4__ diff --git a/src/gtk/nonownedwnd.cpp b/src/gtk/nonownedwnd.cpp index c70655f392..a44910818f 100644 --- a/src/gtk/nonownedwnd.cpp +++ b/src/gtk/nonownedwnd.cpp @@ -24,13 +24,14 @@ #include "wx/dcclient.h" #include "wx/dcmemory.h" #include "wx/region.h" - #include "wx/scopedptr.h" #endif // WX_PRECOMP #include "wx/graphics.h" #include "wx/gtk/private/wrapgtk.h" +#include + // ---------------------------------------------------------------------------- // wxNonOwnedWindowShapeImpl: base class for region and path-based classes. // ---------------------------------------------------------------------------- @@ -162,7 +163,7 @@ private: #ifdef __WXGTK3__ wxGraphicsContext* context = dc.GetGraphicsContext(); #else - wxScopedPtr context(wxGraphicsContext::Create(dc)); + std::unique_ptr context(wxGraphicsContext::Create(dc)); #endif context->SetBrush(*wxWHITE); context->FillPath(path); @@ -195,7 +196,7 @@ private: #ifdef __WXGTK3__ wxGraphicsContext* context = dc.GetGraphicsContext(); #else - wxScopedPtr context(wxGraphicsContext::Create(dc)); + std::unique_ptr context(wxGraphicsContext::Create(dc)); #endif context->SetPen(wxPen(*wxLIGHT_GREY, 2)); context->StrokePath(m_path); diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 2809c02c79..5a238bbcc3 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -36,7 +36,6 @@ #endif #include "wx/scopedarray.h" -#include "wx/scopedptr.h" #include "wx/msw/private.h" #include "wx/msw/dc.h" @@ -48,6 +47,8 @@ #include "wx/rawbmp.h" #endif +#include + // missing from mingw32 header #ifndef CLR_INVALID #define CLR_INVALID ((COLORREF)-1) @@ -634,7 +635,7 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon, wxBitmapTransparency transp) bool wxBitmap::CopyFromDIB(const wxDIB& dib) { - wxScopedPtr newData(new wxBitmapRefData); + std::unique_ptr newData(new wxBitmapRefData); newData->CopyFromDIB(dib); if ( !newData->IsOk() ) return false; diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 0aaa5d64bc..4fcc152e14 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -39,13 +39,14 @@ #include "wx/file.h" #include "wx/quantize.h" #include "wx/scopedarray.h" -#include "wx/scopedptr.h" #include #include #include +#include + #include "wx/msw/dib.h" // ---------------------------------------------------------------------------- @@ -676,7 +677,7 @@ bool wxDIB::Create(const wxImage& image, PixelFormat pf, int dstDepth) { return false; } - wxScopedPtr palette(tempPalette); + std::unique_ptr palette(tempPalette); eightBitData.reset(tempEightBitData); // use palette's colors in result bitmap diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 10bb5a2939..4ce1e63b4d 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -41,7 +41,6 @@ #include "wx/dynlib.h" #include "wx/filename.h" -#include "wx/scopedptr.h" #include "wx/scopeguard.h" #include "wx/tokenzr.h" #include "wx/modalhook.h" @@ -67,6 +66,8 @@ #include "wx/msw/private/cotaskmemptr.h" #endif // wxUSE_IFILEOPENDIALOG +#include + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -579,7 +580,7 @@ public: // We pass the ID of the first control that will be added to the // combobox as the ctor argument. - wxScopedPtr + std::unique_ptr impl(new wxFileDialogChoiceImplFDC(m_fdc, m_lastId, m_lastAuxId - 1)); for ( size_t i = 0; i < n; ++i ) @@ -1162,7 +1163,7 @@ static bool DoShowCommFileDialog(OPENFILENAME *of, long style, DWORD *err) { // Extra controls do not handle per-monitor DPI, fall back to system DPI // so entire file-dialog is resized. - wxScopedPtr dpiAwareness; + std::unique_ptr dpiAwareness; if ( of->Flags & OFN_ENABLEHOOK ) dpiAwareness.reset(new wxMSWImpl::AutoSystemDpiAware()); diff --git a/src/msw/nonownedwnd.cpp b/src/msw/nonownedwnd.cpp index 2f9f30b2be..5af845f6c1 100644 --- a/src/msw/nonownedwnd.cpp +++ b/src/msw/nonownedwnd.cpp @@ -35,9 +35,10 @@ #endif // wxUSE_GRAPHICS_CONTEXT #include "wx/dynlib.h" -#include "wx/scopedptr.h" #include "wx/msw/missing.h" +#include + // ============================================================================ // wxNonOwnedWindow implementation // ============================================================================ @@ -91,7 +92,7 @@ public: { // Create the region corresponding to this path and set it as windows // shape. - wxScopedPtr context(wxGraphicsContext::Create(win)); + std::unique_ptr context(wxGraphicsContext::Create(win)); Region gr(static_cast(m_path.GetNativePath())); win->SetShape( wxRegion( @@ -117,7 +118,7 @@ private: event.Skip(); wxPaintDC dc(m_win); - wxScopedPtr context(wxGraphicsContext::Create(dc)); + std::unique_ptr context(wxGraphicsContext::Create(dc)); context->SetPen(wxPen(*wxLIGHT_GREY, 2)); context->StrokePath(m_path); } diff --git a/src/msw/taskbarbutton.cpp b/src/msw/taskbarbutton.cpp index 8f6c7a5430..6b278536b4 100644 --- a/src/msw/taskbarbutton.cpp +++ b/src/msw/taskbarbutton.cpp @@ -25,13 +25,14 @@ #include "wx/msw/private.h" #include "wx/msw/taskbarbutton.h" #include "wx/dynlib.h" -#include "wx/scopedptr.h" #include "wx/msw/private/comptr.h" #include "wx/msw/private/cotaskmemptr.h" #include #include +#include + // ---------------------------------------------------------------------------- // Redefine the interfaces: ITaskbarList3, IObjectCollection, // ICustomDestinationList, IShellLink, IShellItem, IApplicationDocumentLists @@ -566,9 +567,9 @@ private: wxCOMPtr m_destinationList; wxCOMPtr m_objectArray; - wxScopedPtr m_tasks; - wxScopedPtr m_frequent; - wxScopedPtr m_recent; + std::unique_ptr m_tasks; + std::unique_ptr m_frequent; + std::unique_ptr m_recent; wxTaskBarJumpListCategories m_customCategories; bool m_recent_visible; bool m_frequent_visible; diff --git a/src/qt/graphics.cpp b/src/qt/graphics.cpp index 2cd680aefc..92c32c880c 100644 --- a/src/qt/graphics.cpp +++ b/src/qt/graphics.cpp @@ -29,11 +29,12 @@ #endif #include "wx/graphics.h" -#include "wx/scopedptr.h" #include "wx/tokenzr.h" #include "wx/private/graphics.h" +#include + namespace { @@ -1064,7 +1065,7 @@ protected: private: // This pointer may be empty if we don't own m_qtPainter. - wxScopedPtr m_ownedPainter; + std::unique_ptr m_ownedPainter; wxDECLARE_NO_COPY_CLASS(wxQtGraphicsContext); }; diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index 2072ad45d8..81f00fbfc9 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -17,7 +17,6 @@ #include "wx/ribbon/art.h" #include "wx/ribbon/bar.h" #include "wx/dcbuffer.h" -#include "wx/scopedptr.h" #ifndef WX_PRECOMP #endif @@ -26,6 +25,8 @@ #include "wx/msw/private.h" #endif +#include + class wxRibbonToolBarToolBase { public: @@ -242,7 +243,7 @@ wxRibbonToolBarToolBase* wxRibbonToolBar::InsertTool( wxASSERT(bitmap.IsOk()); // Create the wxRibbonToolBarToolBase with parameters - wxScopedPtr tool(new wxRibbonToolBarToolBase); + std::unique_ptr tool(new wxRibbonToolBarToolBase); tool->id = tool_id; tool->bitmap = bitmap; if(bitmap_disabled.IsOk()) diff --git a/src/unix/appunix.cpp b/src/unix/appunix.cpp index a9fb317c6a..c5c828c383 100644 --- a/src/unix/appunix.cpp +++ b/src/unix/appunix.cpp @@ -16,7 +16,6 @@ #endif #include "wx/evtloop.h" -#include "wx/scopedptr.h" #include "wx/unix/private/wakeuppipe.h" #include "wx/private/fdiodispatcher.h" #include "wx/private/fdioeventloopsourcehandler.h" @@ -24,6 +23,8 @@ #include #include +#include + #ifndef SA_RESTART // don't use for systems which don't define it (at least VMS and QNX) #define SA_RESTART 0 @@ -134,7 +135,7 @@ wxFDIOHandler* wxAppConsole::RegisterSignalWakeUpPipe(wxFDIODispatcher& dispatch // we need a bridge to wxFDIODispatcher // // TODO: refactor the code so that only wxEventLoopSourceHandler is used - wxScopedPtr + std::unique_ptr fdioHandler(new wxFDIOEventLoopSourceHandler(m_signalWakeUpPipe)); if ( !dispatcher.RegisterFD diff --git a/src/unix/evtloopunix.cpp b/src/unix/evtloopunix.cpp index 0c1e72ce41..52fec7fee0 100644 --- a/src/unix/evtloopunix.cpp +++ b/src/unix/evtloopunix.cpp @@ -30,7 +30,6 @@ #endif #include "wx/apptrait.h" -#include "wx/scopedptr.h" #include "wx/thread.h" #include "wx/module.h" #include "wx/unix/private/timer.h" @@ -45,6 +44,8 @@ #include "wx/evtloopsrc.h" #endif // wxUSE_EVENTLOOP_SOURCE +#include + // =========================================================================== // wxEventLoop implementation // =========================================================================== @@ -61,7 +62,7 @@ wxConsoleEventLoop::wxConsoleEventLoop() m_wakeupSource = nullptr; // Create the pipe. - wxScopedPtr wakeupPipe(new wxWakeUpPipeMT); + std::unique_ptr wakeupPipe(new wxWakeUpPipeMT); const int pipeFD = wakeupPipe->GetReadFd(); if ( pipeFD == wxPipe::INVALID_FD ) return; @@ -119,7 +120,7 @@ public: // we need a bridge to wxFDIODispatcher // // TODO: refactor the code so that only wxEventLoopSourceHandler is used - wxScopedPtr + std::unique_ptr fdioHandler(new wxFDIOEventLoopSourceHandler(handler)); if ( !wxFDIODispatcher::Get()->RegisterFD(fd, fdioHandler.get(), flags) ) diff --git a/src/unix/glegl.cpp b/src/unix/glegl.cpp index 90e468f419..5e94e99876 100644 --- a/src/unix/glegl.cpp +++ b/src/unix/glegl.cpp @@ -26,8 +26,6 @@ #include "wx/log.h" #endif //WX_PRECOMP -#include "wx/scopedptr.h" - #include "wx/gtk/private/wrapgtk.h" #include "wx/gtk/private/backend.h" #ifdef GDK_WINDOWING_WAYLAND @@ -41,6 +39,8 @@ #include #include +#include + // ---------------------------------------------------------------------------- // wxGLContextAttrs: OpenGL rendering context attributes // ---------------------------------------------------------------------------- @@ -583,7 +583,7 @@ EGLConfig *wxGLCanvasEGL::InitConfig(const wxGLAttributes& dispAttrs) /* static */ bool wxGLCanvasBase::IsDisplaySupported(const wxGLAttributes& dispAttrs) { - wxScopedPtr config(wxGLCanvasEGL::InitConfig(dispAttrs)); + std::unique_ptr config(wxGLCanvasEGL::InitConfig(dispAttrs)); return config != nullptr; } diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index a40115024e..078167db02 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -45,7 +45,6 @@ #include "wx/apptrait.h" #include "wx/process.h" -#include "wx/scopedptr.h" #include "wx/thread.h" #include "wx/cmdline.h" @@ -63,6 +62,8 @@ #include "wx/mstream.h" #include "wx/private/fdioeventloopsourcehandler.h" +#include + #include #include // waitpid() @@ -546,12 +547,12 @@ int BlockUntilChildExit(wxExecuteData& execData) // Do register all the FDs we want to monitor here: first, the one used to // handle the signals asynchronously. - wxScopedPtr + std::unique_ptr signalHandler(wxTheApp->RegisterSignalWakeUpPipe(dispatcher)); #if wxUSE_STREAMS // And then the two for the child output and error streams if necessary. - wxScopedPtr + std::unique_ptr stdoutHandler, stderrHandler; if ( execData.IsRedirected() ) @@ -622,7 +623,7 @@ long wxExecute(const char* const* argv, int flags, wxProcess* process, #endif // __DARWIN__ // this struct contains all information which we use for housekeeping - wxScopedPtr execDataPtr(new wxExecuteData); + std::unique_ptr execDataPtr(new wxExecuteData); wxExecuteData& execData = *execDataPtr; execData.m_flags = flags; @@ -1570,7 +1571,7 @@ wxAppTraits::RunLoopUntilChildExit(wxExecuteData& execData, #if wxUSE_STREAMS // Monitor the child streams if necessary. - wxScopedPtr + std::unique_ptr stdoutHandler, stderrHandler; if ( execData.IsRedirected() ) diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 06dc3cc318..0cd69a8cf5 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -25,9 +25,10 @@ #include "wx/datstrm.h" #include "wx/zstream.h" #include "wx/strconv.h" -#include "wx/scopedptr.h" #include "wx/versioninfo.h" +#include + #include "expat.h" // from Expat // DLL options compatibility check: @@ -1139,7 +1140,7 @@ bool wxXmlDocument::Save(wxOutputStream& stream, int indentstep) const if ( !IsOk() ) return false; - wxScopedPtr convMem, convFile; + std::unique_ptr convMem, convFile; convFile.reset(new wxCSConv(GetFileEncoding())); diff --git a/src/xrc/xh_animatctrl.cpp b/src/xrc/xh_animatctrl.cpp index 58481c8daa..59f82559d1 100644 --- a/src/xrc/xh_animatctrl.cpp +++ b/src/xrc/xh_animatctrl.cpp @@ -16,7 +16,8 @@ #include "wx/xrc/xh_animatctrl.h" #include "wx/animate.h" #include "wx/generic/animate.h" -#include "wx/scopedptr.h" + +#include wxIMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler, wxXmlResourceHandler); @@ -57,7 +58,7 @@ wxObject *wxAnimationCtrlXmlHandler::DoCreateResource() if ( GetBool("hidden", 0) == 1 ) ctrl->Hide(); - wxScopedPtr animation(GetAnimation("animation", ctrl)); + std::unique_ptr animation(GetAnimation("animation", ctrl)); if ( animation ) ctrl->SetAnimation(*animation); @@ -85,7 +86,7 @@ wxAnimation* wxXmlResourceHandlerImpl::GetAnimation(const wxString& param, return nullptr; // load the animation from file - wxScopedPtr ani(ctrl ? new wxAnimation(ctrl->CreateAnimation()) + std::unique_ptr ani(ctrl ? new wxAnimation(ctrl->CreateAnimation()) : new wxAnimation); #if wxUSE_FILESYSTEM wxFSFile * const diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 659d18996a..44f2d801bb 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -39,7 +39,6 @@ #include "wx/imaglist.h" #include "wx/dir.h" #include "wx/xml/xml.h" -#include "wx/scopedptr.h" #include "wx/config.h" #include "wx/platinfo.h" @@ -61,7 +60,7 @@ wxDateTime GetXRCFileModTime(const wxString& filename) { #if wxUSE_FILESYSTEM wxFileSystem fsys; - wxScopedPtr file(fsys.OpenFile(filename)); + std::unique_ptr file(fsys.OpenFile(filename)); return file ? file->GetModificationTime() : wxDateTime(); #else // wxUSE_FILESYSTEM @@ -777,7 +776,7 @@ wxXmlDocument *wxXmlResource::DoLoadFile(const wxString& filename) #if wxUSE_FILESYSTEM wxFileSystem fsys; - wxScopedPtr file(fsys.OpenFile(filename)); + std::unique_ptr file(fsys.OpenFile(filename)); if (file) { // Notice that we don't have ownership of the stream in this case, it @@ -797,7 +796,7 @@ wxXmlDocument *wxXmlResource::DoLoadFile(const wxString& filename) wxString encoding(wxT("UTF-8")); - wxScopedPtr doc(new wxXmlDocument); + std::unique_ptr doc(new wxXmlDocument); if (!doc->Load(*stream, encoding)) { wxLogError(_("Cannot load resources from file '%s'."), filename);