src/cocoa/application.mm in reflexion-0.1.2 vs src/cocoa/application.mm in reflexion-0.1.3

- old
+ new

@@ -1,20 +1,35 @@ // -*- objc -*- #include "reflex/application.h" #import <Cocoa/Cocoa.h> +#include <reflex/exception.h> #include "applicationdata.h" #import "cocoaapplication.h" namespace Reflex { + static Application* instance = NULL; + + + Application* + app () + { + return instance; + } + + Application::Application () { + if (instance) error("multiple application instance."); + + instance = this; + self->this_ = this; self->self_ = NSApp ? [NSApp retain] : nil; if (self->self_) [self->self_ setApplicationData: self]; } @@ -25,9 +40,11 @@ { [self->self_ release]; self->self_ = nil; } self->this_ = NULL; + + instance = NULL; } bool Application::run () {