The implicit conversion of the enum is now disabled. I just added 2 static_cast instead.
--- trunk_20250716_vanilla/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp 2025-07-16 20:46:08.000000000 +0200
+++ trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp 2025-07-16 21:39:08.141146237 +0200
@@ -205,7 +205,7 @@
else
cpv.Init( type, *wxWHITE );
- m_flags |= wxPG_PROP_STATIC_CHOICES; // Colour selection cannot be changed.
+ m_flags |= static_cast<wxPGFlags>(wxPG_PROP_STATIC_CHOICES); // Colour selection cannot be changed.
m_value << cpv;
OnSetValue();
}
@@ -583,7 +583,7 @@
int index = paintdata.m_choiceItem;
value = wxsColourValues[index];
}
- else if ( !(m_flags & (wxPGPropertyFlags)wxPG_PROP_UNSPECIFIED) )
+ else if ( !(m_flags & static_cast<wxPGFlags>(wxPG_PROP_UNSPECIFIED)) )
{
value = GetVal().m_type;
}
I compiled it under Arch-Linux out-out-of tree using cmake, WX_PREFIX and --enable-pch=no as always.
Please feel free to correct trunk in a better way. Thank you for noticing this.
Yes. That does not compile either.
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp: In member function 'void {anonymous}::wxsMyColourPropertyClass::Init(int, const wxColour&)':
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:209:17: error: no match for 'operator|=' (operand types are 'wxPGFlags' and 'const int')
209 | m_flags |= wxPG_PROP_STATIC_CHOICES; // Colour selection cannot be changed.
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:209:17: note: there is 1 candidate
In file included from /opt/wx/include/wx-3.3/wx/propgrid/propgrid.h:21,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/../../properties/wxsproperty.h:34,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/../../properties/wxsproperties.h:8,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.h:28,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:23:
/opt/wx/include/wx-3.3/wx/propgrid/property.h:423:18: note: candidate 1: 'wxPGFlags operator|=(wxPGFlags&, wxPGFlags)'
423 | inline wxPGFlags operator|=(wxPGFlags & a, wxPGFlags b)
| ^~~~~~~~
/opt/wx/include/wx-3.3/wx/propgrid/property.h:423:54: note: no known conversion for argument 2 from 'const int' to 'wxPGFlags'
423 | inline wxPGFlags operator|=(wxPGFlags & a, wxPGFlags b)
| ~~~~~~~~~~^
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp: In member function 'virtual void {anonymous}::wxsMyColourPropertyClass::OnCustomPaint(wxDC&, const wxRect&, wxPGPaintData&)':
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:587:29: error: no match for 'operator&' (operand types are 'wxPGFlags' and 'wxPG_EX_WINDOW_STYLES')
587 | else if ( !(m_flags & wxPG_PROP_UNSPECIFIED) )
| ~~~~~~~ ^
| |
| wxPGFlags
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:587:29: note: there is 1 candidate
587 | else if ( !(m_flags & wxPG_PROP_UNSPECIFIED) )
/opt/wx/include/wx-3.3/wx/propgrid/property.h:428:21: note: candidate 1: 'constexpr wxPGFlags operator&(wxPGFlags, wxPGFlags)'
428 | constexpr wxPGFlags operator&(wxPGFlags a, wxPGFlags b)
| ^~~~~~~~
/opt/wx/include/wx-3.3/wx/propgrid/property.h:428:54: note: no known conversion for argument 2 from 'wxPG_EX_WINDOW_STYLES' to 'wxPGFlags'
428 | constexpr wxPGFlags operator&(wxPGFlags a, wxPGFlags b)
| ~~~~~~~~~~^
Hand edited untested patch
--- trunk_20250716_vanilla/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp 2025-07-16 20:46:08.000000000 +0200
+++ trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp 2025-07-16 21:39:08.141146237 +0200
@@ -205,7 +205,11 @@
else
cpv.Init( type, *wxWHITE );
+#if wxCHECK_VERSION(3, 1, 1)
+ m_flags |= static_cast<wxPGFlags>(wxPG_PROP_STATIC_CHOICES); // Colour selection cannot be changed.
+#else
m_flags |= wxPG_PROP_STATIC_CHOICES; // Colour selection cannot be changed.
+#endif // wxCHECK_VERSION
m_value << cpv;
OnSetValue();
}
@@ -583,7 +583,11 @@
int index = paintdata.m_choiceItem;
value = wxsColourValues[index];
}
+#if wxCHECK_VERSION(3, 1, 1)
+ else if ( !(m_flags & static_cast<wxPGFlags>(wxPG_PROP_UNSPECIFIED)) )
+#else
else if ( !(m_flags & (wxPGPropertyFlags)wxPG_PROP_UNSPECIFIED) )
+#endif // wxCHECK_VERSION
{
value = GetVal().m_type;
}
You are right. I should have written 3.3.1. I have corrected my previous post.
And of course, the patch should be with :
#if wxCHECK_VERSION(3, 3, 1)
Tested and looks OK
reinterpret_cast also does not compile as I suspected.
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp: In member function 'void {anonymous}::wxsMyColourPropertyClass::Init(int, const wxColour&)':
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:210:37: warning: 'wxPGProperty::FlagType' is deprecated: use wxPGFlags type instead [-Wdeprecated-declarations]
210 | m_flags |= reinterpret_cast<FlagType>(wxPG_PROP_STATIC_CHOICES); // Colour selection cannot be changed.
| ^~~~~~~~
In file included from /opt/wx/include/wx-3.3/wx/propgrid/propgrid.h:21,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/../../properties/wxsproperty.h:34,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/../../properties/wxsproperties.h:8,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.h:28,
from ../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:23:
/opt/wx/include/wx-3.3/wx/propgrid/property.h:1038:22: note: declared here
1038 | typedef wxUint32 FlagType;
| ^~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:210:20: error: invalid cast from type 'int' to type 'wxPGProperty::FlagType' {aka 'unsigned int'}
210 | m_flags |= reinterpret_cast<FlagType>(wxPG_PROP_STATIC_CHOICES); // Colour selection cannot be changed.
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:211:37: warning: 'wxPGProperty::FlagType' is deprecated: use wxPGFlags type instead [-Wdeprecated-declarations]
211 | m_flags |= reinterpret_cast<FlagType>(wxPG_PROP_STATIC_CHOICES); // Colour selection cannot be changed.
| ^~~~~~~~
/opt/wx/include/wx-3.3/wx/propgrid/property.h:1038:22: note: declared here
1038 | typedef wxUint32 FlagType;
| ^~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:211:20: error: invalid cast from type 'int' to type 'wxPGProperty::FlagType' {aka 'unsigned int'}
211 | m_flags |= reinterpret_cast<FlagType>(wxPG_PROP_STATIC_CHOICES); // Colour selection cannot be changed.
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp: In member function 'virtual void {anonymous}::wxsMyColourPropertyClass::OnCustomPaint(wxDC&, const wxRect&, wxPGPaintData&)':
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:589:48: warning: 'wxPGProperty::FlagType' is deprecated: use wxPGFlags type instead [-Wdeprecated-declarations]
589 | else if ( !(m_flags & reinterpret_cast<FlagType>(wxPG_PROP_UNSPECIFIED)) )
| ^~~~~~~~
/opt/wx/include/wx-3.3/wx/propgrid/property.h:1038:22: note: declared here
1038 | typedef wxUint32 FlagType;
| ^~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:589:31: error: invalid cast from type 'wxPG_EX_WINDOW_STYLES' to type 'wxPGProperty::FlagType' {aka 'unsigned int'}
589 | else if ( !(m_flags & reinterpret_cast<FlagType>(wxPG_PROP_UNSPECIFIED)) )
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp: In member function 'virtual bool {anonymous}::wxsMyColourPropertyClass::StringToValue(wxVariant&, const wxString&, int) const':
../../../../../../../trunk/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp:674:57: warning: 'virtual bool wxEnumProperty::StringToValue(wxVariant&, const wxString&, int) const' is deprecated: use StringToValue with 'flags' argument as wxPGPropValFormatFlags [-Wdeprecated-declarations]
674 | bool res = wxEnumProperty::StringToValue(value, colourName, argFlags);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/wx/include/wx-3.3/wx/propgrid/propgrid.h:2210:
/opt/wx/include/wx-3.3/wx/propgrid/props.h:519:18: note: declared here
519 | virtual bool StringToValue(wxVariant& variant, const wxString& text,
| ^~~~~~~~~~~~~
make[7]: *** [Makefile:677: wxscolourproperty.lo] Fehler 1
wxCHECK_VERSION seems to be used quite often in cb. Where do I find the minimum required version? Can't find it at first glance.
In case it is wxCHECK_VERSION(3, 0, 0) anyway, shouldn't those conditionals be updated, that is eliminated? I also like backwards
compatibility for some not too short time. That allows to update dependent projects like cb on their own pace and stepwise instead of
a big bang. Nice if indicated by [[deprecated]] and tools like clang-tidy [-modernize-...].
Thanks for the active contributions.