[Kde-bindings] Problem condition in Qyoto MethodCall

Richard Dale richard.j.dale at gmail.com
Sat Feb 10 15:14:16 UTC 2007

This is wrong, but I still haven't worked out what the correct version should

// We have to check here, if our target does still exists.
// If there is no entry in the weakRef Dictionary, the instance doesn't exist
// There's also no entry, if the method is a constructor or the method is
// If the target doesn't exist anymore, set _called to true so the method
won't be invoked.
// The other possibility is that the qApp was just destroyed and we want to
call a destructor.
// This could lead to a crash when we interfere with the destroying mechanism
of Q(Core)Application.
if ( ((getPointerObject(_current_object) == 0) && !_ctor && !(_tmp.flags &
        || ((_tmp.flags & Smoke::mf_dtor) && (qApp == 0)) )
        _called = true;

Not every instance has an entry in the weak reference map. For example, I had
a QVariant which was created in C++ code and it failed the condition
and '_called' was set to true. Try the qdbus/pingpong example - it crashes
when trying to access to QVariant returned.

We should only be looking at the 'o' and 'o->ptr' values and not call the
method if they are zero and it's not a static method or constructor. I don't
think we need to test for destructors at all because 'o->ptr' is set
to 0 once something has been deleted (or it should be anyway).

-- Richard

More information about the Kde-bindings mailing list