[PyQt] Re: ConvertToSubClass problem
Giovanni Bajo
rasky at develer.com
Tue Nov 18 13:38:54 GMT 2008
On Tue, 2008-11-18 at 13:22 +0000, Phil Thompson wrote:
> On Tue, 18 Nov 2008 14:06:10 +0100, Giovanni Bajo <rasky at develer.com>
> wrote:
> > On Tue, 2008-11-18 at 09:27 +0000, Phil Thompson wrote:
> >> On Tue, 18 Nov 2008 01:12:49 +0100, Giovanni Bajo <rasky at develer.com>
> >> wrote:
> >> > Hi Phil,
> >> >
> >> > this patch:
> >> >
> >> > 2007/02/25 0:19:29 phil
> >> > Included Matt Newell's fix for making sure that a sub-class convertor
> >> > returns the most specific type available.
> >> >
> >> > causes problem with PyQt3Support. Specifically, the
> >> > ConvertToSubClassCode in q3mainwindow.sip does not seem to work as
> >> > expected. The bug manifests itself when the code is invoked to find
> the
> >> > most derived class for a Q3ListView. The convertor correctly detects
> >> > the
> >> > correct type, but this additional check (added by Matt Newell):
> >> >
> >> > && !PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)subtype)
> >> >
> >> > make it so that the convertor's result is ignored.
> >> >
> >> > It might well be that the bug is in the placement of the convertor
> >> > within pyqt3support. It is currently placed within Q3MainWindow, but
> it
> >> > contains conversion code for many different classes (unrelated to
> >> > Q3MainWindow). I'm afraid I'm not sure where one should place the
> >> > convertors code.
> >> >
> >> > Any guess on what exactly is the bug?
> >>
> >> As the documentation says, the conversion code must be placed in one of
> >> the
> >> classes that the code is handling. If the code handled unrelated
> classes,
> >> how would SIP know when to invoke it?
> >
> > The problem is that I don't understand the sentence "one of the classes
> the
> > code is handling".
> >
> > We have this graph within q3mainwindow.sip:
> >
> > static struct class_graph {
> > char *name;
> > sipWrapperType **type;
> > int yes, no;
> > } graph[] = {
> > {sipName_Q3Header, &sipClass_Q3Header,
>
> > -1, 1}, // 0
> > {sipName_Q3Accel, &sipClass_Q3Accel,
>
> > -1, 2}, // 1
> > {sipName_Q3Action, &sipClass_Q3Action,
>
> > 3, 4}, // 2
> > {sipName_Q3ActionGroup, &sipClass_Q3ActionGroup,
>
> > -1, -1}, // 3
> > {sipName_Q3DockArea, &sipClass_Q3DockArea,
>
> > -1, 5}, // 4
> > {sipName_Q3Frame, &sipClass_Q3Frame,
>
> > 6, 15}, // 5
> > {sipName_Q3DockWindow,
> &sipClass_Q3DockWindow,
> > 7, 8}, // 6
> > {sipName_Q3ToolBar,
> &sipClass_Q3ToolBar,
> > -1, -1}, // 7
> > {sipName_Q3Grid, &sipClass_Q3Grid,
>
> > -1, 9}, // 8
> > {sipName_Q3HBox, &sipClass_Q3HBox,
>
> > 10, 11}, // 9
> > {sipName_Q3VBox, &sipClass_Q3VBox,
>
> > -1, -1}, // 10
> > {sipName_Q3ScrollView, &sipClass_Q3ScrollView,
>
> > 12, -1}, // 11
> > {sipName_Q3ListView, &sipClass_Q3ListView,
>
> > -1, 13}, // 12
> > {sipName_Q3Table, &sipClass_Q3Table,
>
> > -1, 14}, // 13
> > {sipName_Q3ListBox, &sipClass_Q3ListBox,
>
> > -1, -1}, // 14
> > {sipName_Q3MainWindow, &sipClass_Q3MainWindow,
>
> > -1, 16}, // 15
> > {sipName_Q3PopupMenu, &sipClass_Q3PopupMenu,
>
> > -1, 17}, // 16
> > {sipName_Q3StyleSheet, &sipClass_Q3StyleSheet,
>
> > -1, -1}, // 17
> > };
> >
> >
> >
> > As you can see, the convertor is placed within "one of the class it's
> > handling" (literally: Q3MainWindow). Moreover, they all derive from
> > QObject (and QWidget).
> >
> > So I don't really understand if the code is correct or not; and if not,
> > what we should put where (= how we should split it).
>
> The above is fine, so long as they all have a common super class somewhere
> in their class hiearchy.
>
> You said "many different classes (unrelated to Q3MainWindow)" which made it
> sound like you were talking about classes that didn't have any super
> classes in common.
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()).
> 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).
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com
More information about the PyQt
mailing list