RFC: singletons and memory management

Andreas Mützel andreas.muetzel at gmx.net
Thu Sep 11 12:08:50 CEST 2008


> What happens is that if you call "delete Singleton::instance()", then
> the object pointed to by s_instance is freed, but s_instance is never
> reset to zero. [...] You could also use a "smart" pointer like
> auto_ptr or QPointer that automatically set to zero when they're
> deleted, but I personally prefer the static destroy() method.  

Hi, 
just a naive question: Wouldn't it be sufficient to set s_instance to 0 in the 
destructor?
This seems much easier to me, but maybe there is a good reason for not doing 
it that way?

andreas


More information about the Amarok-devel mailing list