Use of Boost library classes in kdecore?

Thomas Zander zander at kde.org
Sat Jul 7 05:57:03 BST 2007


On Friday 06 July 2007 23:12:22 David Jarvie wrote:
> There is an important issue in the KTimeZone class and the classes
> derived from it which needs to be addressed by using reference counted
> pointers. The most suitable class which I can find is from the Boost
> library: shared_ptr. This has a necessary facility which KSharedPtr
> lacks, i.e. the ability to implicitly convert shared_ptr<T> to
> shared_ptr<U> whenever T* can be implicitly converted to U* (e.g. when
> U is a base class of T).

I'd much rather see this usecase solved using the Q_D macro and thus 
making the KTimeZone objects implicitly shared.

Or, maybe even better, have a d-pointer that is ref-counted (I do that in 
KOffice several times, really really useful) so you can update the 
timezones data without making it invalid.

> KTimeZone instances from referencing invalid pointers if the KTimeZone
> instance happens to get deleted somewhere else. This problem has
> already arisen when iCalendar files are reloaded in kdepimlibs/kcal

Naturally, this seems like a design that could be improved upon; the usage 
of shared pointers IMO works best if you do not delete those instances on 
that reload.  What about updating those instances in-place  instead? That 
surely will save a ripple effect of loads and loads of code having to do 
checking if the shared-pointer is still valid.
And checking such a thing; well then you should just have used a QPointer.

Bottom line; I would really dislike using boost in kdelibs.  Not that I 
have anything against boost per-see. But lets please keep the level of 
complexity (learning new stuff) to a minimum so people can actually roll 
into hacking on kdelibs a bit easier.  Just because you like boost 
doesn't mean all the potential kdelibs hackers should learn to use it.

-- 
Thomas Zander
-------------- 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/20070707/37bd4414/attachment.sig>


More information about the kde-core-devel mailing list