[Kde-perl] Overloading of Qt::ToolTip::maybeTip doesn't work
Ole Christensen
Ole.Christensen at web.de
Sat Oct 30 11:30:11 CEST 2004
Richard,
I have investigated the thing a little bit more. The problem was that I
used the latest CVS export. mapObject actually isn't called in this
version any more. Tracking down the CVS logs I found that Germain Garand
has removed two calls to mapObject in Qt.pm version 1.86. The log holds
"don't map objects twice". Maybe one deletion happened unintentionally.
I have no idea.
http://cvs.sourceforge.net/viewcvs.py/perlqt/PerlQt-3/PerlQt/Qt.pm?r1=1.85&r2=1.86
Your patch applied to 3.008 seems to work fine for me. Thanks a lot. An
appropriate fix should also go into CVS if there is no serious drawback.
Even if Qt-4 is scheduled to have a virtual destructor for QToolTip,
which should solve the problem anyway as far as I have understood.
Regards,
Ole.
Richard Dale wrote:
> On Thursday 28 October 2004 21:14, Ole Christensen wrote:
>
>>Richard,
>>
>>unfortunately the patch you suggested does not fix the problem.
>>Everything unchanged. Find the corresponding output below. Note the "--
>>Ole" ;-) So the right lib actually gets used. The mapObject function
>>obviously does not get called at all in this context. I put an fprintf
>>there which is not reached.
>
> mapObject() should get called when the instance of Qt::ToolTip is created.
> These two lines look for the instance in the map before trying to call the
> virtual method:
>
> SV *obj = getPointerObject(ptr);
> smokeperl_object *o = sv_obj_info(obj);
>
> If it isn't found, you get the 'Cannot find object.. ' error.
>
>
>>virtual 0x8746220->QToolTip::maybeTip() called
>>Cannot find object for virtual method -- Ole
>>
>>I applied the patch on a fresh cvs export from sourceforge. Is there
>>anything else I could do to track down the problem? Thanks in any case
>>for your help.
>
> Can you post the source of a test program to make it possible to reproduce the
> problem? You can add 'use Qt::debug qw( gc );' at the top of your program, to
> produce a debugging trace of the garbage collection and C++ to perl instance
> mapping.
>
> -- Richard
>
>>Richard Dale wrote:
>>
>>>On Wednesday 27 October 2004 22:48, Ole Christensen wrote:
>>>
>>>>Hi,
>>>>
>>>>I am trying to implement a dynamic tooltip. The problem is that
>>>>overloading Qt::ToolTip::maybeTip does not work for me. I already have
>>>>reimplemented virtual functions in perl, but for some reason it does not
>>>>work for maybeTip. QToolTip is not a subclass of QObject. Does that
>>>>matter?
>>>>
>>>>When I switch on debugging of virtual functions I get:
>>>>
>>>>virtual 0x8772ea0->QToolTip::maybeTip() called
>>>>Cannot find object for virtual method
>>>>
>>>>I am using
>>>>PerlQt 3.008
>>>>Qt 3.3.3
>>>>perl 5.8.2
>>>
>>>I had the same problem as this with qtruby. Here is the entry from the
>>>qtruby ChangeLog:
>>>
>>> * If a class doesn't have a virtual destructor, then no mapping was
>>>being kept from the C++ instance to the corresponding ruby value. If the
>>>class had virtual method callbacks, this meant that the ruby instance
>>>couldn't be found, and the callback couldn't be made.
>>>
>>> * Hence, the Qt::ToolTip callback in examples/qt-examples/tooltip didn't
>>> work, as that class doesn't have a virtual destructor.
>>>
>>>For PerlQt, you would need to remove this test from the mapObject()
>>>function in Qt.xs:
>>>
>>> if(!c.hasVirtual() ) {
>>> XSRETURN_EMPTY;
>>> }
>>>
>>>void
>>>mapObject(obj)
>>> SV *obj
>>> CODE:
>>> smokeperl_object *o = sv_obj_info(obj);
>>> if(!o)
>>> XSRETURN_EMPTY;
>>> SmokeClass c( o->smoke, o->classId );
>>>// if(!c.hasVirtual() ) {
>>>// XSRETURN_EMPTY;
>>>// }
>>> mapPointer(obj, o, pointer_map, o->classId, 0);
>>>
>>>So that a mapping of the pointer from a C++ instance to a perl instance
>>>is always kept.
More information about the Kde-perl
mailing list