Eliminate -Wcast-qual warnings with GCC and Clang

Use const_cast, mutable, and various other changes to avoid -Wcast-qual
This commit is contained in:
Paul Cornett
2020-02-02 22:50:32 -08:00
parent 6724f8c052
commit 948ddc6e0f
115 changed files with 273 additions and 303 deletions

View File

@@ -28,7 +28,7 @@
#include "artbrows.h"
#define ART_CLIENT(id) \
choice->Append(#id, (void*)id);
choice->Append(#id, const_cast<void*>(static_cast<const void*>(id)));
#define ART_ICON(id) \
{ \
int ind; \

View File

@@ -292,7 +292,7 @@ unsigned int MyMusicTreeModel::GetChildren( const wxDataViewItem &parent,
if (node == m_classical)
{
MyMusicTreeModel *model = (MyMusicTreeModel*)(const MyMusicTreeModel*) this;
MyMusicTreeModel* model = const_cast<MyMusicTreeModel*>(this);
model->m_classicalMusicIsKnownToControl = true;
}

View File

@@ -2022,7 +2022,7 @@ void DnDShapeDataObject::CreateBitmap() const
m_shape->Draw(dc);
dc.SelectObject(wxNullBitmap);
DnDShapeDataObject *self = (DnDShapeDataObject *)this; // const_cast
DnDShapeDataObject* self = const_cast<DnDShapeDataObject*>(this);
self->m_dobjBitmap.SetBitmap(bitmap);
self->m_hasBitmap = true;
}

View File

@@ -53,7 +53,7 @@ public:
bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap);
//// Accessors
wxBitmap& GetBackgroundBitmap() const { return (wxBitmap&) m_background; }
const wxBitmap& GetBackgroundBitmap() const { return m_background; }
bool GetUseScreen() const { return m_useScreen; }
void SetUseScreen(bool useScreen) { m_useScreen = useScreen; }
@@ -136,7 +136,7 @@ public:
wxRect GetRect() const { return wxRect(m_pos.x, m_pos.y, m_bitmap.GetWidth(), m_bitmap.GetHeight()); }
wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
const wxBitmap& GetBitmap() const { return m_bitmap; }
void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
int GetDragMethod() const { return m_dragMethod; }

View File

@@ -634,7 +634,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
pgman->SetPropertyValue("ArrayStringProperty",test_arrstr_1);
wxColour emptyCol;
pgman->SetPropertyValue("ColourProperty",emptyCol);
pgman->SetPropertyValue("ColourProperty",(wxObject*)wxBLACK);
pgman->SetPropertyValue("ColourProperty", const_cast<wxObject*>(static_cast<const wxObject*>(wxBLACK)));
pgman->SetPropertyValue("Size",WXVARIANT(wxSize(150,150)));
pgman->SetPropertyValue("Position",WXVARIANT(wxPoint(150,150)));
pgman->SetPropertyValue("MultiChoiceProperty",test_arrint_1);
@@ -690,7 +690,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
pg->SetPropertyValue("BoolProperty",true);
pg->SetPropertyValue("EnumProperty",80);
pg->SetPropertyValue("ArrayStringProperty",test_arrstr_2);
pg->SetPropertyValue("ColourProperty",(wxObject*)wxWHITE);
pg->SetPropertyValue("ColourProperty", const_cast<wxObject*>(static_cast<const wxObject*>(wxWHITE)));
pg->SetPropertyValue("Size",WXVARIANT(wxSize(300,300)));
pg->SetPropertyValue("Position",WXVARIANT(wxPoint(300,300)));
pg->SetPropertyValue("MultiChoiceProperty",test_arrint_2);

View File

@@ -1205,11 +1205,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
m_tab = new MyTextCtrl( this, 100, "Multiline, allow <TAB> processing.",
wxPoint(180,90), wxSize(200,70), wxTE_MULTILINE | wxTE_PROCESS_TAB );
m_tab->SetClientData((void *)wxS("tab"));
m_tab->SetClientData(const_cast<void*>(static_cast<const void*>(wxS("tab"))));
m_enter = new MyTextCtrl( this, 100, "Multiline, allow <ENTER> processing.",
wxPoint(180,170), wxSize(200,70), wxTE_MULTILINE | wxTE_PROCESS_ENTER );
m_enter->SetClientData((void *)wxS("enter"));
m_enter->SetClientData(const_cast<void*>(static_cast<const void*>(wxS("enter"))));
m_textrich = new MyTextCtrl(this, wxID_ANY, "Allows more than 30Kb of text\n"
"(on all Windows versions)\n"