cinder/Cinder — pull request #480 by pizthewiz (2014-08-09 01:57:46+00:00)
Title: avoid out of bounds access when windowless

(originally #479, now against the new `master` branch)

A window-less Cinder application can be very useful and yet it isn't obvious how best it should be created. Options are not available on `Window::Format` or `Settings` to prevent the creation in `App::prepareSettings(Settings* settings)`, instead one must call `close()` on it. While `hide()` will conceal the window, the draw loop is still executed.

If `close()` is called during `App::setup()`, an error is logged to the console after it executes:
```sh
2014-08-06 11:37:58.747 Process[77904:996154] *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
```

The error originates from `-[AppImplCocoaBasic applicationDidFinishLaunching:]` [line 101](https://github.com/cinder/Cinder/blob/dev/src/cinder/app/AppImplCocoaBasic.mm#L101):
```Objective-C
// make the first window the active window
[self setActiveWindow:[mWindows objectAtIndex:0]];
```

When the window is closed, `mWindows` is empty. `-[NSArray firstObject]` will internally handle the empty case and return `nil`.