KSharedPtr breakage

Frerich Raabe raabe at kde.org
Sun Oct 23 17:05:30 BST 2005


On Sunday 23 October 2005 15:39, Frerich Raabe wrote:
> On Sunday 23 October 2005 05:52, Hamish Rodda wrote:
> > I tried to
> > port it over to 100% shared pointers, but encountered a problem with
> > covariant returns - KSharedPtr can't be used (in its current form) in a
> > covariant return with different class types

This is a bit tricky, but looking at what KSycoca* is doing, maybe there's an 
easy way out. Take KSycocaFactory::findServiceByName:

  virtual KServiceType * findServiceTypeByName(const QString &_name);

It returns a raw pointer, not a shared one, but doesn't document who's 
supposed to call delete on the pointee. If we're lucky, the caller is 
supposed to do so, in which case we could simply let all those functions 
which deal with KSharedPtr's internally, but then return a dumb pointer to 
the client, return 'new Foo( *fooPtr.get() );'. I just hope there are copy 
constructors and assignment operators.

- Frerich




More information about the kde-core-devel mailing list