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 411 - Incorrect return statement generated in a function that returns a reference
: Incorrect return statement generated in a function that returns a reference
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: Shiboken
: HEAD
: All All
: P3 normal
Assigned To: Marcelo Lira
:
:
:
  Show dependency treegraph
 
Reported: 2010-10-13 17:40 EEST by Bruno Araujo
Modified: 2010-11-25 17:48 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 Bruno Araujo 2010-10-13 17:40:48 EEST
If I have a function that returns a reference, e.g. QObject & someFunction(),
some of the return statements inside the generated code will be 'return 0',
which is incompatible with the effective return type and the compilation will
not proceed. Although this kind of signature may be considered a bad coding
practice, the generator must be able to cope with this. An example of this
behavior can be found in the following functions in
QOrganizerCollectionEngineLocalId class:

    virtual QDataStream& dataStreamOut(QDataStream& out) = 0;
    virtual QDataStream& dataStreamIn(QDataStream& in) = 0;

The code generated for those functions have some 'return 0' statements on it,
breaking compilation.
Comment 1 Bruno Araujo 2010-10-13 18:35:51 EEST
Actually, returning variable references may be useful in some situations, as
described in [1]. I guess I wasn't fair in labeling this kind of signature "bad
coding practice"; I hope no one gets angry :-)

Anyway, Shiboken must be fixed to allow using these functions.

[1]
http://www.learncpp.com/cpp-tutorial/74a-returning-values-by-value-reference-and-address/
Comment 2 Hugo Parente Lima 2010-10-18 10:56:06 EEST
Fixed in commit/6b57558fefd3a1e3913e8fe386a07da0d8aeedc3

See the example included on commit to know how to handle this kind of problem.
http://qt.gitorious.org/pyside/shiboken/commit/6b57558fefd3a1e3913e8fe386a07da0d8aeedc3
Comment 3 renato filho 2010-11-25 17:48:13 EET
released on 1.0.0~beta1