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

Barth Netterfield netterfield at astro.utoronto.ca
Sat Jan 1 19:59:13 CET 2011


On Sun, Jan 2, 2011 at 6:26 AM, Peter Kümmel <syntheticpp at gmx.net> wrote:
> I also discovered by my own that the main problem is the switching
> between raw pointers and smart pointers. I will investigate it
> further because I wonder why we need to pass raw pointers around
> and to understand how it works at the moment.

Here is some very brief documentation on K[st]SharedPtr:

K[st]SharedPtr is a smart reference counted pointer where the
reference count is held by the object
being pointed to.  For this reason, the object must inherit from K[st]Shared.

It can be used like a normal pointer.  When the reference count gets
to zero, the object is deleted.  Having the KSharedPtr go out of
scope, or being set to 0 decrements the reference count.

A bare pointer can be converted to a K[st]SharedPtr.  The reference
count is incremented.

You can also manually increment or decrement the reference count
(->ref() and ->unref()) if needed - like to protect the passing of a
bare pointer.

I think K[st]SharedPtr is a good class.

There is some 'spooky stuff' related to slave scalars in kst2 which I
think might be wrong.  In particular, I'm not sure why ->ref() and
->unref() are being used in some places.

> But I will be very
> carefully and when the changes become to big I'll make a branch.
>
> I think the benefits will be a simpler to maintain code, less memory
> leaks, maybe more type checking by the compiler and at least I will
> understand the code better. Working on this we get a lot of help from
> the compiler and of Qt's checks in QSharedPointer, so I'm confident
> that there will be not too much big surprises at runtime. So let's
> see how far will get.
>
> Threading would be good with all these cores around.
>
> Peter
>
> PS, the BLAST pages are very interesting. But I have no
> real imagination how Kst looks like in your real world
> application. Do you think some screen shots are worth to
> add to our web page?

I'll send or post some at some point.

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


More information about the Kst mailing list