Qt-interest Archive, September 2002
When is it safe to delete things?
Message 1 in thread
Hello,
This seems to be a pretty basic question, but I can't find the answer
in any of the Trolltech docs. This leads me to suspect that there's
some unstated convention that everybody in the world (except me)
already knows about Qt/C++
I'm trying to write a binding to Qt in a language that supports
garbage collection. What I really need to know is things like
this..
How do you know which objects refer to other objects?
Is the QObject parent/child relationship the only
possible reference mechanism?
Which objects can safely be stack allocated and which
must heap allocated?
If I pass a QString (for example) as an argument to a
method can I delete the QString after, or will it create
some kind of hidden pointer to the QString embedded in the
corresponding object, or make a local copy perhaps?
Do the answers to these questions depend on whether or not
the object class inherits QObject? Or maybe it depends on whether
of not the argument is passed as a pointer or a reference? Does
the const qualifier have anything to do with this?
Sorry if this is a dumb question. I've afraid I've never used
either Qt or C++ before.
Thanks for any enlightenment
--
[ signature omitted ]
Message 2 in thread
On Monday 02 September 2002 5:04 am, Adrian Hey wrote:
> If I pass a QString (for example) as an argument to a
> method can I delete the QString after, or will it create
> some kind of hidden pointer to the QString embedded in the
> corresponding object, or make a local copy perhaps?
Ah, serves me right. As soon as I ask the question I find
the TrollTech documentation about implicit and explicit
sharing :-)
I'd still be interested to know of any other hidden
referencing strangeness in Qt which may trap inexperienced
users. Can I assume that objects of a class which isn't listed
as using either implicit of explicit sharing are never shared
at all (within Qt)?
Thanks
--
[ signature omitted ]