Crash on startup

Casper Boemann cbr at boemann.dk
Fri Feb 4 01:12:25 CET 2005


On Thursday 03 February 2005 22:57, Casper Boemann wrote:
> I create an iterator in KisBackground. When I delete the iterator (this is
> the fix I mention in my previous commit) The background somehow gets
> deleted as well. This most probably happens because KShared thinks the last
> reference has gone.
>
> I'm trying to get to the bottom of this asap
Ok, I think I got it now

in the constructor the SP ref count is 0 as no external KSharedPtr has 
referenced us yet.

When I create my iterator I create an SP and count goes up to 1.
I delete the iterator and count goes down to 0. Bang the paintdevice is delete
WHILE we're still in the constructor.

A design flaw in my mind.

Short of redesigning C++ so KShared can do what would be appropiate, I have 
done the next best thing. Namely to not let the iterators take SPs but just 
plain pointers.

Offcourse that my leave them dangling, but on the other hand SPs should be no 
excuse for safe programming style.

So let this be a warning: never create or use a temp. SP to this during 
construction.

I have committed so krita should no longer crash on startup.

-- 
best regards / venlig hilsen
Casper Boemann


More information about the kimageshop mailing list