Disallow overriding wxBitmap::Create() outside of wxWidgets

This doesn't really make much sense, this function is only virtual in
the first place to force wxBitmap (in all ports except for wxMSW) to
implement wxBitmapBase pure virtual functions, but it's implemented only
by wxWidgets itself and shouldn't be overridden again, so declare it as
final in all the ports overriding it and make it non-virtual in wxMSW.

Also, none of the other Create() functions in wxWindow-derived classes
is virtual, so this improves consistency as well.

Finally, this avoids clang-analyzer-optin.cplusplus.VirtualCall warning
from clang-tidy due to calling a virtual function from wxBitmap ctor,
which is the right thing to do only because we really want to call
wxBitmap's own version and not anything defined in a derived class.

Closes #24759.
This commit is contained in:
Vadim Zeitlin
2024-08-19 02:51:42 +02:00
parent 8ffcddaf1d
commit 3e8a84ee86
7 changed files with 21 additions and 22 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ public:
#endif
bool Create(const wxIDirectFBSurfacePtr& surface);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(int width, int height, const wxDC& WXUNUSED(dc))
{ return Create(width,height); }
+2 -2
View File
@@ -80,8 +80,8 @@ public:
wxBitmap(GdkPixbuf* pixbuf, int depth = 0);
explicit wxBitmap(const wxCursor& cursor);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) override;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) override
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
#ifdef __WXGTK3__
bool Create(int width, int height, const wxDC& dc);
+4 -4
View File
@@ -140,12 +140,12 @@ public:
bool ConvertToDIB();
#endif
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual bool Create(int width, int height, const wxDC& dc);
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
bool Create(int width, int height, const wxDC& dc);
bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
bool CreateWithDIPSize(const wxSize& sz,
double scale,
+3 -4
View File
@@ -128,11 +128,11 @@ public:
// get the given part of bitmap
wxBitmap GetSubBitmap( const wxRect& rect ) const override;
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) override;
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) override
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
bool Create( CGImageRef image, double scale = 1.0 );
bool Create( WXImage image );
bool Create( CGContextRef bitmapcontext);
@@ -140,7 +140,6 @@ public:
// Create a bitmap compatible with the given DC, inheriting its magnification factor
bool Create(int width, int height, const wxDC& dc);
// virtual bool Create( WXHICON icon) ;
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE) override;
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = nullptr) const override;
+3 -3
View File
@@ -34,9 +34,9 @@ public:
static void InitStandardHandlers();
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) override;
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) override;
virtual bool Create(int width, int height, const wxDC& dc);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(int width, int height, const wxDC& dc);
virtual void SetScaleFactor(double scale);
virtual double GetScaleFactor() const;
+2 -2
View File
@@ -65,8 +65,8 @@ public:
static void InitStandardHandlers();
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(int width, int height, const wxDC& WXUNUSED(dc))
{ return Create(width,height); }