bustiiing / blazingstars

Automatically exported from code.google.com/p/blazingstars
0 stars 0 forks source link

Code in DBPrefsWindowController might need synchronization #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm not an Objective-C expert so I might be wrong, but this code looks 
suspicious. It's a singleton without synchronization. 

+ (DBPrefsWindowController *)sharedPrefsWindowController
{
    if (!_sharedPrefsWindowController) {
        _sharedPrefsWindowController = [[self alloc] 
initWithWindowNibName:[self nibName]];
    }
    return _sharedPrefsWindowController;
}

This could lead to spurious, seldom, hard-to-trace bugs.

Original issue reported on code.google.com by steve.mc...@gmail.com on 29 Dec 2009 at 9:54

GoogleCodeExporter commented 8 years ago
I don't *think* that this is a problem;  it matches code in Apple's developer
documentation.  For example, see:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFunda
mentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32

And Matt Gallagher has a good post on this:
http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html

(Note that in the apple docs, we don't need the memory management methods 
because
BlazingStars is garbage collected).

Original comment by steven.h...@gmail.com on 30 Dec 2009 at 7:16