[PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton
not writing configuration)
phil at riverbankcomputing.com
Fri Mar 13 10:31:41 GMT 2009
On Fri, 13 Mar 2009 11:15:41 +0100, Till Gerken <till.gerken at gmail.com>
> sorry for keeping replying to myself, but nobody else seems to show
> interest and I am trying to find the root cause of the error:
> The QString() that I am passing as reference to the C++ class
> KCoreConfigSkeleton exists as local variable in my Python class
> derived from KCoreConfigSkeleton. Now any code that interacts with
> KCoreConfigSkeleton (C++ or Python) may change this QString instance.
> Looking at the SIP file I see the following:
> KCoreConfigSkeleton::ItemString* addItemString (const QString& name,
> QString& reference, const QString& defaultValue = QLatin1String(""),
> const QString& key = QString());
> Could it be that this method declaration misses /In/ and /Out/ for
> QString &reference? The documentation on /In/ and /Out/ was not too
> clear for me, could someone elaborate what happens exactly when these
> statements are given?
By default SIP infers whether an argument is being passed into a function
or is only being used to return a value from the function according to the
type of the argument. /In/ and /Out/ allow you to be explicit about the
direction in case the default behaviour is wrong.
For a QString& the default is that the argument is being passed into the
function. The fact that the string may be being updated doesn't qualify it
as being used to return a value in this context.
It looks like the omission of any /In/ or /Out/ is correct in this case.
More information about the PyQt