Static access to ICore
    Esben Mose Hansen 
    kde at mosehansen.dk
       
    Fri Nov 16 18:17:39 UTC 2007
    
    
  
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. 
Feel free to ignore me if I am blabbering :)
-- 
regards, Esben
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
    
    
More information about the KDevelop-devel
mailing list