Commits

Anonymous committed 1ca236a

disable persistent window state which prevented new windows from displaying
after finishLaunching on 10.8

Comments (0)

Files changed (1)

 NSAutoreleasePool = ObjCClass('NSAutoreleasePool')
 NSDate = ObjCClass('NSDate')
 NSEvent = ObjCClass('NSEvent')
+NSUserDefaults = ObjCClass('NSUserDefaults')
 
 def add_menu_item(menu, title, action, key):
     title = CFSTR(title)
         self.pool = NSAutoreleasePool.alloc().init()
         create_menu()
         self.NSApp.setActivationPolicy_(NSApplicationActivationPolicyRegular)
+        # Prevent Lion / Mountain Lion from automatically saving application state.
+        # If we don't do this, new windows will not display on 10.8 after finishLaunching
+        # has been called.  
+        defaults = NSUserDefaults.standardUserDefaults()
+        ignoreState = CFSTR("ApplerPersistenceIgnoreState")
+        if not defaults.objectForKey_(ignoreState):
+            defaults.setBool_forKey_(True, ignoreState)
 
     def start(self):
         self.NSApp.finishLaunching()