[Kst] Re: branches/work/kst/portto4/kst

Peter Kümmel syntheticpp at gmx.net
Fri Dec 31 21:18:24 CET 2010


Yes, my plan is to replace Kst::Shared and Kst::SharedPtr by QSharedPointer.
Currently it seems to me that the lifetime management of objects is a little
bit cumbersome, hard to understand, and influenced by legacy code of KDE3.
But now we have Qt4 and QSharedPointer, so why should we implement our own
shared pointer class?

The idea is to use the well known reference counted shared pointer C++ idiom,
implemented by QSharedPointer. The current solution is a bit wired because it
strongly correlates "worker" classes with the memory management system
(protected destructors, friend classes). But in principle it should be enough
to follow two paradigm:
- a object will not be deleted when it is in use, means an objects holds
  a shared pointer.
- maybe it is necessary to register a object globally so it can be used by
  other functions.

I know we have discussed this topic a bit a year ago without a result,
but now having the merged build of cmake it doesn't hurt to recompile
everything again and again, so I tried it again. And while investigating
bug https://bugs.kde.org/show_bug.cgi?id=261260
I thought that the main reason for this bug is the memory management.

Because I don't wanna make a branch I've used a macro which is disabled by
default. As mentioned in the commit message it's only the beginning
of the replacement, but I will have much time in January to finish it.

I plan to replace more and more and if I don't get stopped by an overseen
feature of the old approach Kst::Shared and Kst::SharedPtr will be gone
and also all the #ifdef ST_USE_QSHAREDPOINTER.

You know the old system much better, don't you also think it is a little
bit aged? Especially having the scripting support in mind I think a more
up-to-date system will avoid problems in future.

Peter






On 31.12.2010 19:55, Barth Netterfield wrote:
> Peter,
> 
> Can you outline your plan in a little more detail.
> Are you planning to replace KstSharedPtr?  If so, this needs to be discussed.
> 
> cbn
> 
> On Sat, Jan 1, 2011 at 6:51 AM, Peter Kümmel <syntheticpp at gmx.net> wrote:
>> SVN commit 1210492 by kuemmel:
>>
>> Start port to QSharedPointer:
>> - the current live time handling is no standard C++ idiom
>> - implementing a shared pointer is legacy code from KDE 3
>> - QSharedPointer is a bullet proofed Qt class
>> - better encapsulation: objects should not know how they are stored (remove inheritance from Shared)
>> - define KST_USE_QSHAREDPOINTER in sharedptr.h to enable new code
>>
>> One problem is the pointer -> SharedPointer transition, because mostly there exists already
>> a QSharedPointer for the object Qt asserts. Could be solved with a consequent usage of shared pointers.
>> Don't know why raw pointers are used.
>>
>>
>>  M  +12 -0     devel-docs/Kst2Specs/Wishlist
>>  M  +2 -0      src/libkst/datamatrix.cpp
>>  M  +5 -0      src/libkst/datamatrix.h
>>  M  +4 -0      src/libkst/dataplugin.h
>>  M  +4 -0      src/libkst/datavector.cpp
>>  M  +6 -0      src/libkst/datavector.h
>>  M  +6 -0      src/libkst/matrix.h
>>  M  +9 -1      src/libkst/object.cpp
>>  M  +9 -1      src/libkst/object.h
>>  M  +11 -0     src/libkst/objectstore.h
>>  M  +13 -0     src/libkst/primitive.h
>>  M  +37 -1     src/libkst/sharedptr.h
>>  M  +5 -2      src/libkst/timezones.h
>>  M  +6 -0      src/libkst/vector.h
>>  M  +5 -0      src/libkstmath/basicplugin.h
>>  M  +6 -0      src/libkstmath/csd.h
>>  M  +5 -0      src/libkstmath/curve.h
>>  M  +1 -1      src/libkstmath/curvehint.cpp
>>  M  +4 -0      src/libkstmath/curvehint.h
>>  M  +8 -8      src/libkstmath/dataobject.cpp
>>  M  +6 -0      src/libkstmath/dataobject.h
>>  M  +6 -0      src/libkstmath/equation.h
>>  M  +6 -0      src/libkstmath/eventmonitorentry.h
>>  M  +6 -0      src/libkstmath/histogram.h
>>  M  +6 -0      src/libkstmath/image.h
>>  M  +6 -0      src/libkstmath/psd.h
>>  M  +8 -8      src/libkstmath/relation.cpp
>>  MM +6 -0      src/plugins/filters/cumulativesum/cumulativesum.h
>>  M  +4 -0      src/widgets/matrixselector.cpp
>>  M  +4 -0      src/widgets/scalarselector.cpp
>>  M  +4 -0      src/widgets/stringselector.cpp
>>  M  +4 -0      src/widgets/vectorselector.cpp
>>
>>
>> http://websvn.kde.org/?view=rev&revision=1210492
>> _______________________________________________
>> Kst mailing list
>> Kst at kde.org
>> https://mail.kde.org/mailman/listinfo/kst
>>
> 
> 
> 


More information about the Kst mailing list