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

Barth Netterfield netterfield at astro.utoronto.ca
Sat Jan 1 13:06:11 CET 2011


Thanks Peter.

As you say, I looked into this extensively a year ago.  (See the
thread Titled "Architectural changes" from Dec 2009).  The main issue
is that QSharedPtr stores the reference count externally, so once it
has been passed through a plain pointer, the referencing is lost.
KSharedPtr (or, KstSharedPtr) store the reference in the object
itself, which lets one go back and forth when necessary.  This is
important in places where we pass 'this' on to another class - eg, a
dialog - which needs to keep a reference to the object. QSharedPointer
would require us to look up the object's QSharedPointer from the
store() in order to maintain reference.  This might be OK.  I would
like to keep the store() around, as it makes a lot of things easy to
handle.

I tend to be conservative about making a major change like this unless
we are pretty sure it will provide actual benefit to users over the
long term.  There are certainly memory leaks in kst2 (I just
experienced on while writing this email) so further cleaning of the
memory system makes sense.  Whether it is better to fix our usage of
KSharedPtr, or to change over to QSharedPointers I'll leave up to you,
but please consider carefully: are you fairly sure this change will
result in a real benefit?

We also need to get to threading one of these days.

cbn

PS, BLAST is flying right now, and so I am spending about 15 hours/day
down here in Antarctica staring at kst2 plots of its  performance.

Where our balloon is right now:
http://www.csbf.nasa.gov/map/balloon8/balloon8.htm
Links about the project, including photoblogs: http://blastexperiment.info/

On Sat, Jan 1, 2011 at 9:18 AM, Peter Kümmel <syntheticpp at gmx.net> wrote:
> 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
>>>
>>
>>
>>
> _______________________________________________
> Kst mailing list
> Kst at kde.org
> https://mail.kde.org/mailman/listinfo/kst
>



-- 
C. Barth Netterfield
University of Toronto
416-845-0946


More information about the Kst mailing list