[API addition] AbstractMediaStream::setAutoDelete

Matthias Kretz kretz at kde.org
Mon Aug 27 13:32:31 BST 2007


On Monday 27 August 2007, Hans Meine wrote:
> Am Montag, 27. August 2007 13:03:28 schrieb Matthias Kretz:
> > b) The object might be tied to some parts of the application and
> > auto-deleting it could be a problem there (so it would need at least the
> > setAutoDelete(false) possibility - which keeping a MediaSource object
> > wrapping the stream would also achieve)
> > c) If you want to reuse the stream object you don't want it to get
> > deleted automatically (again this could also be solved by keeping a
> > MediaSource object wrapping the stream)
>
> The obvious d) would be refcounting (e.g. thin wrappers or shared_ptr).
> BTW: I would prefer d). ;-)

AbstractMediaStream is a QObject subclass. How do you want to implement a 
refcount/shared pointer with a nice API for that (and without blowing up the 
implementation)?

> > So, yes, it could be done to pass ownership by default. It's just my
> > feeling that the default should be to not pass ownership.
>
> If ownership is passed, I propose the use of auto_ptr<> to show that in the
> API.  (Admittedly, that does not make for a beautiful API, but for a very
> clear one IMHO.)

As I never use auto_ptr<> it doesn't make the API any clearer. I guess most Qt 
using developers will have that problem, too.

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070827/4ee69d8b/attachment.sig>


More information about the kde-core-devel mailing list