Unobfuscate wxAnyToVariant registration and remove global var hack.

Note that I don't have any data that the global var hack was causing
the bug, so this may or may not fix it.  But it seems as good a candidate
as any.

Fixes https://gitlab.com/kicad/code/kicad/issues/12871
This commit is contained in:
Jeff Young 2022-11-15 15:45:18 +00:00
parent 5759a3a10a
commit 3af4e889b9
2 changed files with 38 additions and 3 deletions

View File

@ -84,4 +84,3 @@ wxVariantData* EDA_ANGLE_VARIANT_DATA::VariantDataFactory( const wxAny& aAny )
}
REGISTER_WXANY_CONVERSION( EDA_ANGLE, EDA_ANGLE_VARIANT_DATA )

View File

@ -37,8 +37,44 @@
static const wxChar REGEX_SIGNED_DISTANCE[] = wxT( "([-+]?[0-9]+[\\.?[0-9]*) *(mm|in|mils)*" );
static const wxChar REGEX_UNSIGNED_DISTANCE[] = wxT( "([0-9]+[\\.?[0-9]*) *(mm|in|mils)*" );
// Force at least one to exist, otherwise wxWidgets won't register it
static const EDA_ANGLE_VARIANT_DATA g_AngleVariantData;
class wxAnyToEDA_ANGLE_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
{
public:
wxAnyToEDA_ANGLE_VARIANTRegistrationImpl( wxVariantDataFactory factory )
: wxAnyToVariantRegistration( factory )
{
}
public:
static bool IsSameClass(const wxAnyValueType* otherType)
{
return AreSameClasses( *s_instance.get(), *otherType );
}
static wxAnyValueType* GetInstance()
{
return s_instance.get();
}
virtual wxAnyValueType* GetAssociatedType() wxOVERRIDE
{
return wxAnyToEDA_ANGLE_VARIANTRegistrationImpl::GetInstance();
}
private:
static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
{
return wxTypeId(a) == wxTypeId(b);
}
static wxAnyValueTypeScopedPtr s_instance;
};
wxAnyValueTypeScopedPtr wxAnyToEDA_ANGLE_VARIANTRegistrationImpl::s_instance( new wxAnyValueTypeImpl<EDA_ANGLE>() );
static wxAnyToEDA_ANGLE_VARIANTRegistrationImpl s_wxAnyToEDA_ANGLE_VARIANTRegistration( &EDA_ANGLE_VARIANT_DATA::VariantDataFactory );
wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty )
{