PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 1016 - Calling of Q_INVOKABLE method returning not QVariant is impossible...
: Calling of Q_INVOKABLE method returning not QVariant is impossible...
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: PySide
: 1.0.6
: PC Linux
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-09-30 01:16 EEST by Alexander A. Prokhorov
Modified: 2011-11-29 21:28 EET (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander A. Prokhorov 2011-09-30 01:16:22 EEST
My program plugin contains method I would like to call from python:

class A : public QObject {
  Q_OBJECT
public:
  Q_INVOKABLE
  void call_me();
};

due to the fact that it is C++ written plugin I don't have pyside generated
bindings on it, but, after some googling and reading libpyside code I have
figured out that, actually, if PySide cannot find attribute it will finally
look through methods in QMetaObject. That is done in getMetaDataFromQObject in
pyside.cpp. So I expect that writing a.call_me() will call my C++ method.
Unfortunately that is not the case, and the worst thing that there is no even
error message. It just does nothing. At the same time if I try to call
inexistent method it throws AttributeError exception. So at the first look I
thought that it works, but it doesn't :(

Two sleepless nights helped me to figure out what is wrong ;) The problem is in
the fact that QMetaMethod::invoke() (called from functionCall() in
pysidemetafunction.cpp) checks that given 'QGenericReturnArgument' represents
exactly the return type of the method called. But functionCall() always puts
QVariant as a return value receiver. Indeed changing result type to QVariant
helped! But the problem is still here: it is impossible to call Q_INVOKABLE
method which return type is not QVariant.

I suppose improvement needed in function functionCall()....

I think at the moment it would be extremely useful to describe this limitation
somewhere in the documentation.
Comment 1 Hugo Parente Lima 2011-10-27 17:14:02 EEST
Fixed in commit:

pyside/05719145fcb21d34c351fd01be2ac6b694674260

Thanks for the detailed report!
Comment 2 Luciano Wolf 2011-11-29 21:28:46 EET
Released on PySide 1.0.9. Closing.