Static access to ICore

David Nolden zwabel at googlemail.com
Fri Nov 16 18:49:44 UTC 2007


On Friday 16 November 2007 19:17:39 Esben Mose Hansen wrote:
> On Friday 16 November 2007 14:23:42 Kris Wong wrote:
> > class Icore
> > {
> >    ICore() {
> >       instance = this;
> >    }
> >    ~ICore() {
> >       instance = 0;
> >    }
> >    ICore* self() {
> >       return instance;
> >    }
> >    static ICore* instance;
> > }
>
> While I realize that I know next to nothing about the KDevelop project,
> that code looks excessively dangerous  to me. At the very least, I would
> add a check in ICore() constructor that instance is null, and likewith in
> the destructor (that instance != 0). I would further suggest that ICore
> constructor/destructor is private but friends with the few classes that
> actually need it.

This was obviously just a simple example ;)

@Kris Since we already discussed this on IRC, and there seems to be not much 
interest in this on the list, I've re-enabled your code there today.

Of course we can still discuss it, and revert if needed, given someone has a 
good argument against it.

greetings, David




More information about the KDevelop-devel mailing list