[PyQt] Re: ConvertToSubClass problem

Matt Newell newellm at blur.com
Tue Nov 18 20:23:23 GMT 2008


>
> If the above is fine, then the only problem must be in the code present
> in that patch. Does Matteo's suggestion of type equality ring you a
> bell? Otherwise I'll have a deeper debugging session. It would help if
> you could explain me the original purpose of that check (and
> generically, if you could describe the algorithm implemented by
> convertSubClass()).
>
The purpose of the check is to avoid having a class up-casted when proper 
convertToSubclass code is missing.

For example, if I write a new sip module:

class MyMainWindow : QMainWindow
{
... // No convertToSubclass defined
}

MyMainWindow * createMainWindow(); 

Without the check, the createMainWindow function will actually be returned as 
a QMainWindow object in python, because the convertToSubclass code for the 
QMainWindow class will return the sipClass_QMainWindow type.  The check makes 
sure if to return the original declared type unless a more specific type is 
found.

> > Did you build the above data structure by hand? Or have I given you a
> > copy of my script that automatically generates it?
>
> By hand :) But I think the data structure per-se is correct. I have
> reviewed it many times, and I have even verified that, when that
> convertor is called, the correct result is returned but it is then
> discarded because of that specific subtype check (whose purpose is still
> unknown to me).
Could you be more specific about the situation that is failing.  What actual 
type is the object, and what is the return type of the function being called?

Matt




More information about the PyQt mailing list