RFC: singletons and memory management

Leo Franchi lfranchi at kde.org
Thu Sep 11 00:45:48 CEST 2008


On Sep 10, 2008, at 5:37 PM, Jeff Mitchell wrote:

> Soren Harward wrote:
>> On Wednesday 10 September 2008 17:38:06 Ian Monroe wrote:
>>> if (The::playlistModel() )
>>>    The::playlistModel()->something()
>>
>> But if The::playlistModel() is just an alias for  
>> PlaylistModel::instance()
>> (which it is in every single case that I've looked at so far), then  
>> you don't
>> have to check if The::playlistModel() exists, because as soon as  
>> you call it,
>> it does.  That's the whole point of a singleton.
>
> And if we're in an instance where the singleton is deleted, and is  
> then
> called again via ::instance(), we should really fix that anyways.

I don't really see it being an issue. If it is called when it doesn't  
exist b/c it has been deleted, it is created. But that should never  
happen---if we delete it, it should be the last time it is accessed.

So whats wrong?

leo
---
Leo Franchi				(650) 704 3680
Tufts University 2010

lfranchi at kde.org
leonardo.franchi at tufts.edu



More information about the Amarok-devel mailing list