User forums > Using Code::Blocks

crash when I try to open a wxsmith file under C::B against wx 3.3.1

<< < (2/5) > >>

ollydbg:
Yes, I agree, I see the call stack is not from the wxSmith's source code.

The problem is that if I can't open a wxSmith file in C::B, and we can't fix such issue in the C::B side, I have to revert to use wx 3.2.x to build C::B. I have already switched to use wx 3.3.1 in my github action to build C::B.

ollydbg:
I wrote an issue in the wxWidgets github

crash inside the GetValueAsString function of propgrid control in wx 3.3.1 under Windows 10 Issue #26108 wxWidgets/wxWidgets

ollydbg:
I see that the propgrid sample in the wx3.3.1 works fine. So, maybe it is still something wrong inside our C::B code base?

ollydbg:
I looked at some source code here:

\src\plugins\contrib\wxSmith\wxwidgets\properties\wxscolourproperty.cpp

I see some function get override, such as:


--- Code: ---    // This is based on the code of wxSystemColourProperty in advprops.h|cpp of wxPropertyGrid
    class wxsMyColourPropertyClass : public wxEnumProperty
    {
        WX_PG_DECLARE_PROPERTY_CLASS(wxsMyColourPropertyClass)
    public:

        wxsMyColourPropertyClass( const wxString& label = wxEmptyString,
                                const wxString& name = wxPG_LABEL,
                                const wxColourPropertyValue& value = wxColourPropertyValue(wxsCOLOUR_DEFAULT,*wxWHITE) );
        ~wxsMyColourPropertyClass();

        virtual void OnSetValue();
        virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;

        /** Override in derived class to customize how colours are printed as strings.
        */
        virtual wxString ColourToString( const wxColour& col, int index, int argFlags = 0 ) const;

        /** Returns index of entry that triggers colour picker dialog
            (default is last).
        */
        virtual int GetCustomColourIndex() const;

        virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
        virtual bool StringToValue( wxVariant& variant,
                                    const wxString& text,
                                    int argFlags = 0 ) const;

--- End code ---

Do you mean that we need to add a special function overloading here?

See here:

https://docs.wxwidgets.org/3.3/classwx_p_g_property.html


I see VZ(wx developer) just close my issue, and he suggest that we need to override some functions myself.

Am I correct?



EDIT:

See this code in

https://github.com/wxWidgets/wxWidgets/blob/master/src/propgrid/advprops.cpp#L1102C1-L1182C2



--- Code: ---#if WXWIN_COMPATIBILITY_3_2
// By call to obsolete function we want to check if user-overriden function is still in use
wxString wxSystemColourProperty::ColourToStringWithCheck(const wxColour& col, int index,
                                                         wxPGPropValFormatFlags flags) const
{
    m_oldColourToStringCalled = false;
    wxString res = ColourToString(col, index, static_cast<int>(flags));
    if ( m_oldColourToStringCalled )
    {
        // Our own function was called - this implies that call was forwarded to the new overriding
        // function and there is no need to call it explicitly.
    }
    else
    {   // User-overriden obsolete function was called
        wxFAIL_MSG(wxString::Format("in %s use ColourToString with 'flags' argument as wxPGPropValFormatFlags", GetClassInfo()->GetClassName()));
    }
    return res;
}
#endif // WXWIN_COMPATIBILITY_3_2


wxString wxSystemColourProperty::ColourToString( const wxColour& col,
                                                 int index,
                                                 wxPGPropValFormatFlags flags ) const
{


    if ( index == wxNOT_FOUND )
    {


        if ( !!(flags & wxPGPropValFormatFlags::FullValue) || !!(m_flags & wxPGPropertyFlags_ColourHasAlpha) )
        {
            return wxString::Format(wxS("(%i,%i,%i,%i)"),
                                    (int)col.Red(),
                                    (int)col.Green(),
                                    (int)col.Blue(),
                                    (int)col.Alpha());
        }
        else
        {
            return wxString::Format(wxS("(%i,%i,%i)"),
                                    (int)col.Red(),
                                    (int)col.Green(),
                                    (int)col.Blue());
        }
    }
    else
    {
        return m_choices.GetLabel(index);
    }
}


wxString wxSystemColourProperty::ValueToString( wxVariant& value,
                                                wxPGPropValFormatFlags flags ) const
{
    wxColourPropertyValue val = GetVal(&value);


    int index;


    if ( !!(flags & wxPGPropValFormatFlags::ValueIsCurrent) )
    {
        // GetIndex() only works reliably if wxPGPropValFormatFlags::ValueIsCurrent flag is set,
        // but we should use it whenever possible.
        index = GetIndex();


        // If custom colour was selected, use invalid index, so that
        // ColourToString() will return properly formatted colour text.
        if ( index == GetCustomColourIndex() &&
             !(m_flags & wxPGPropertyFlags_HideCustomColour) )
            index = wxNOT_FOUND;
    }
    else
    {
        index = m_choices.Index(val.m_type);
    }


#if WXWIN_COMPATIBILITY_3_2
    // Special implementation with check if user-overriden obsolete function is still in use
    return ColourToStringWithCheck(val.m_colour, index, flags);
#else
    return ColourToString(val.m_colour, index, flags);
#endif // WXWIN_COMPATIBILITY_3_2 | !WXWIN_COMPATIBILITY_3_2
}


--- End code ---

https://github.com/wxWidgets/wxWidgets/blob/8245e1073ae66fd246d2ec180160d2e20acf3644/interface/wx/propgrid/advprops.h#L92C1-L168C1

This is the header file.

ollydbg:
I can't find a clean way to fix this assert issue.

My guess is that the issue is inside the "class wxsMyColourPropertyClass : public wxEnumProperty", but I don't know how to fix it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version