[PyQt] SIP 4.7.6 -> 4.7.9 upgrade cause compilation problems
(missing typedef)
Phil Thompson
phil at riverbankcomputing.com
Mon Dec 8 20:38:52 GMT 2008
On Mon, 08 Dec 2008 16:21:45 +0300, Yury Aliaev <mutab0r at rambler.ru> wrote:
> Hello,
>
> Recently I tried to compile QtiPlot
> (http://soft.proindependent.com/qtiplot.html), an application using SIP
> during building. At some stage of the compilation I got the following
> error:
>
> sipqtiApplicationWindow.cpp: In function 'PyObject*
> meth_ApplicationWindow_windows(PyObject*, PyObject*)':
> sipqtiApplicationWindow.cpp:1144: error: 'MDIWindowList' was not
> declared in this scope
> sipqtiApplicationWindow.cpp:1144: error: 'sipRes' was not declared in
> this scope
> sipqtiApplicationWindow.cpp:1147: error: expected type-specifier before
> 'MDIWindowList'
> sipqtiApplicationWindow.cpp:1147: error: expected `;' before
> 'MDIWindowList'
> sipqtiApplicationWindow.cpp:1151: error: type '<type error>' argument
> given to 'delete', expected pointer
> make[1]: *** [../tmp/qtiplot/sipqtiApplicationWindow.o] Error 1
>
> I started exploring the above file (sipqtiApplicationWindow.cpp) and
> found that the error was caused by the following fragment:
>
> MDIWindowList *sipRes;
>
> Py_BEGIN_ALLOW_THREADS
> sipRes = new MDIWindowList(sipCpp->windowsList());
> Py_END_ALLOW_THREADS
>
> PyObject *sipResObj =
>
sipConvertFromMappedType(sipRes,sipMappedType_QList_0201MdiSubWindow,NULL);
> delete sipRes;
>
>
> But MDIWindowList type was never be defined. Although in the file
> qti.sip, from wich the pointed .cpp file was generated, the following
> line presented:
>
> typedef QList<MdiSubWindow*> MDIWindowList;
>
> Also, I remembered that earlier the compilation hadn't failed. I'd found
> that since that time SIP was updated from 4.7.6 nj 4.7.9. I proposed
> that this may cause the error and downgraded SIP back to 4.7.6. After
> that the compilation stopped failing. The errorneos fragment of the
> generated file sipqtiApplicationWindow.cpp changed to the following:
>
> QList<MdiSubWindow *> *sipRes;
>
> Py_BEGIN_ALLOW_THREADS
> sipRes = new QList<MdiSubWindow *>(sipCpp->windowsList());
> Py_END_ALLOW_THREADS
>
> PyObject *sipResObj =
>
sipConvertFromMappedType(sipRes,sipMappedType_QList_0201MdiSubWindow,NULL);
> delete sipRes;
>
> return sipResObj;
>
> that is old SIP performed correct type placement.
>
> So I now have a question, whether new SIP has a bug, or it's a feature
> and QtiPlot sources should be adopted for it (how?)? I'm a newbie with
> SIP and ask you for a help, please.
The latest version of SIP doesn't expand typedefs in generated code. It
expects that the proper typedef definition will be available to the
generated code - usually via a .h file specified in a %TypeHeaderCode
block. It looks like you are missing a #include of the .h file containing
the missing typedef.
Phil
More information about the PyQt
mailing list