From 385acccebba2c24c8e32a14371f8a203096fc53a Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Thu, 26 May 2022 21:20:29 -0700 Subject: [PATCH] Fix some harmless MSVC compiler warnings This fixes warnings C4244 ('=': conversion from 'int' to 'xxx', possible loss of data) and C4267 (conversion from 'size_t' to 'int', possible loss of data) from the MSVC compiler (Version 19.29.30136 for x64) when compiling in 64-bits. Note that these warnings are disabled in wx/defs.h by default and so only happen when saving/restoring the warning settings using the appropriate pragmas before/after including wx headers. Closes #22462. --- include/wx/choicebk.h | 2 +- include/wx/htmllbox.h | 2 +- include/wx/richtext/richtextbuffer.h | 6 ++++-- include/wx/richtext/richtextctrl.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/wx/choicebk.h b/include/wx/choicebk.h index aca809932d..8df8221ebd 100644 --- a/include/wx/choicebk.h +++ b/include/wx/choicebk.h @@ -86,7 +86,7 @@ protected: void UpdateSelectedPage(size_t newsel) wxOVERRIDE { - GetChoiceCtrl()->Select(newsel); + GetChoiceCtrl()->Select(static_cast(newsel)); } wxBookCtrlEvent* CreatePageChangingEvent() const wxOVERRIDE; diff --git a/include/wx/htmllbox.h b/include/wx/htmllbox.h index 722013b815..9705a833cd 100644 --- a/include/wx/htmllbox.h +++ b/include/wx/htmllbox.h @@ -265,7 +265,7 @@ public: // ----------------- virtual unsigned int GetCount() const wxOVERRIDE - { return m_items.GetCount(); } + { return static_cast(m_items.GetCount()); } virtual wxString GetString(unsigned int n) const wxOVERRIDE; diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index 4037a64551..598d75d23c 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -368,7 +368,8 @@ public: /** Constructor taking value and units flag. */ - wxTextAttrDimension(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value; m_flags = units|wxTEXT_ATTR_VALUE_VALID; } + wxTextAttrDimension(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value; + m_flags = static_cast(units | wxTEXT_ATTR_VALUE_VALID); } /** Resets the dimension value and flags. @@ -426,7 +427,8 @@ public: /** Sets the integer value and units. */ - void SetValue(int value, wxTextAttrUnits units) { m_value = value; m_flags = units | wxTEXT_ATTR_VALUE_VALID; } + void SetValue(int value, wxTextAttrUnits units) { m_value = value; + m_flags = static_cast(units | wxTEXT_ATTR_VALUE_VALID); } /** Sets the dimension. diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index 5701f6da43..cece67b085 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -178,7 +178,7 @@ public: /** Returns the number of items. */ - int GetCount() const { return m_objects.GetCount(); } + int GetCount() const { return static_cast(m_objects.GetCount()); } wxRichTextObjectPtrArray m_objects; wxArrayString m_labels;