[Phoenix Issue] wx.FlexGridSizer.AddGrowableCol results in C++ assert

Const <[email protected]>
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
*Summary*
 
Environment: wxPython Phoenix, head of master branch, Windows 7 64-bit, 
Python 3.4.3.
 

The error can be reproduced in the GenericDirCtrl demo of the wxPython demo 
application. The following is a snippet of code from the demo around the 
source of the error.

    sz = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
    sz.Add((35, 35))  # some space above
    sz.Add((35, 35))
    sz.Add((35, 35))

    sz.Add(txt1)
    sz.Add(txt2)
    sz.Add(txt3)

    sz.Add(dir1, 0, wx.EXPAND)
    sz.Add(dir2, 0, wx.EXPAND)
    sz.Add(dir3, 0, wx.EXPAND)

    sz.Add((35,35))  # some space below

    sz.AddGrowableRow(2)
    sz.AddGrowableCol(0)  # <-- error here
    sz.AddGrowableCol(1)
    sz.AddGrowableCol(2)

The error is :

    "!m_cols || idx < (size_t)m_cols" failed at 
..\..\src\common\sizer.cpp(1980)
    in wxFlexGridSizer::AddGrowableCol(): invalid column index

*Details*
 
I've done some poking around to try and diagnose the problem. Here are some 
observation.
 
(1)
 
In Python, if you specify the named argument, it works. For example:

    sz.AddGrowableCol(0, proportion=0)

Although, this does not:

    sz.AddGrowableCol(0, 0)

(2)
 
The C++, wxWidgets, version of the demo works as expected.
 
(3)
 
At the C++ level in wxWidgets, when AddGrowableCol(size_t idx, int 
proportion) is called, the value of idx equals some super large number (as 
reported by the C++ debugger), hence the reason the C++ assert fails 
(perhaps idx is uninitialized?).
 
(4)
 
If I insert a printf("idx=%d\n", idx) to see the value of the idx inside 
the SIP generated wrapper function meth_wxFlexGridSizer_AddGrowableRow() 
(source file sip\cpp\sip_corewxFlexGridSizer.cpp), sz.AddGrowableCol() in 
Python works (hence the demo) works. Remove the printf() and it does not.
 

    static PyObject *meth_wxFlexGridSizer_AddGrowableRow(PyObject *sipSelf, 
PyObject *sipArgs, PyObject *sipKwds)
    {
        PyObject *sipParseErr = NULL;

        {
            size_t idx;
            int proportion = 0;
            wxFlexGridSizer *sipCpp;

            static const char *sipKwdList[] = {
                sipName_idx,
                sipName_proportion,
            };

            if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, 
NULL, "Bm|i", &sipSelf, sipType_wxFlexGridSizer, &sipCpp, &idx, 
&proportion))
            {
                PyErr_Clear();

                *printf("idx=%d\n", idx)*
                sipCpp->AddGrowableRow(idx,proportion);

                if (PyErr_Occurred())
                    return 0;

                Py_INCREF(Py_None);
                return Py_None;
            }
        }

        /* Raise an exception if the arguments couldn't be parsed. */
        sipNoMethod(sipParseErr, sipName_FlexGridSizer, 
sipName_AddGrowableRow, NULL);

        return NULL;
    }

(5)
 
wx.Sizer.InsertStretchSpace() also asserts for the similar reason of the 
index argument being a large number.  Coincidently, it has the same calling 
signature. 

Before I attempt to probe this any further, does anyone have any idea what 
might be going on?

 

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.