aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-03-16 13:22:06 +0000
committerstuconnolly <stuart02@gmail.com>2010-03-16 13:22:06 +0000
commit392c1e5c5579b1b58e02acddf2880097d9e1e0ce (patch)
tree34c6a679d610802bf570272fdc3cb04fd2053970 /Source
parent332f6201ce607a6622fadfd3e6426e4571dc035f (diff)
downloadsequelpro-392c1e5c5579b1b58e02acddf2880097d9e1e0ce.tar.gz
sequelpro-392c1e5c5579b1b58e02acddf2880097d9e1e0ce.tar.bz2
sequelpro-392c1e5c5579b1b58e02acddf2880097d9e1e0ce.zip
Modify our current implementation of all singleton instances to be inline with Apple's recommendations detailed at http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32 This also fixes the associated static analysis warnings of potentially leaked objects.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPExportController.m6
-rw-r--r--Source/SPGrowlController.m12
-rw-r--r--Source/SPLogger.m20
-rw-r--r--Source/SPNotLoaded.m7
-rw-r--r--Source/SPQueryController.m10
5 files changed, 23 insertions, 32 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index c1e72b8a..caa504e7 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -449,8 +449,8 @@
[errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
}
- SPExporter *exporter;
- SPCSVExporter *csvExporter;
+ SPExporter *exporter = nil;
+ SPCSVExporter *csvExporter = nil;
// Based on the type of export create a new instance of the corresponding exporter and set it's specific options
switch (type)
@@ -508,6 +508,8 @@
// maximum number of concurrent operations. See the docs for more details.
[operationQueue addOperation:exporter];
+ if (csvExporter) [csvExporter release];
+
// Add a spacer to the file
//[fileHandle writeData:[[NSString stringWithFormat:@"%@%@%@", csvLineEnd, csvLineEnd, csvLineEnd] dataUsingEncoding:encoding]];
}
diff --git a/Source/SPGrowlController.m b/Source/SPGrowlController.m
index 0e41a258..13d06f3c 100644
--- a/Source/SPGrowlController.m
+++ b/Source/SPGrowlController.m
@@ -39,7 +39,7 @@ static SPGrowlController *sharedGrowlController = nil;
{
@synchronized(self) {
if (sharedGrowlController == nil) {
- [[self alloc] init];
+ sharedGrowlController = [[super allocWithZone:NULL] init];
}
}
@@ -49,14 +49,8 @@ static SPGrowlController *sharedGrowlController = nil;
+ (id)allocWithZone:(NSZone *)zone
{
@synchronized(self) {
- if (sharedGrowlController == nil) {
- sharedGrowlController = [super allocWithZone:zone];
-
- return sharedGrowlController;
- }
- }
-
- return nil; // On subsequent allocation attempts return nil
+ return [[self sharedGrowlController] retain];
+ }
}
- (id)init
diff --git a/Source/SPLogger.m b/Source/SPLogger.m
index 9d8f7a92..d492fe32 100644
--- a/Source/SPLogger.m
+++ b/Source/SPLogger.m
@@ -47,7 +47,7 @@ static SPLogger *logger = nil;
{
@synchronized(self) {
if (logger == nil) {
- [[self alloc] init];
+ logger = [[super allocWithZone:NULL] init];
}
}
@@ -60,16 +60,20 @@ static SPLogger *logger = nil;
+ (id)allocWithZone:(NSZone *)zone
{
@synchronized(self) {
- if (logger == nil) {
- logger = [super allocWithZone:zone];
-
- return logger;
- }
+ return [[self logger] retain];
}
-
- return nil;
}
+- (id)copyWithZone:(NSZone *)zone { return self; }
+
+- (id)retain { return self; }
+
+- (NSUInteger)retainCount { return NSUIntegerMax; }
+
+- (void)release {}
+
+- (id)autorelease { return self; }
+
- (id)init
{
if ((self = [super init])) {
diff --git a/Source/SPNotLoaded.m b/Source/SPNotLoaded.m
index e1e76806..6814e2e8 100644
--- a/Source/SPNotLoaded.m
+++ b/Source/SPNotLoaded.m
@@ -34,7 +34,7 @@ static SPNotLoaded *notLoaded = nil;
{
@synchronized(self) {
if (notLoaded == nil) {
- [[self alloc] init];
+ notLoaded = [[super allocWithZone:NULL] init];
}
}
return notLoaded;
@@ -43,11 +43,8 @@ static SPNotLoaded *notLoaded = nil;
+ (id) allocWithZone:(NSZone *)zone
{
@synchronized(self) {
- if (notLoaded == nil) {
- return [super allocWithZone:zone];
- }
+ return [[self notLoaded] retain];
}
- return notLoaded;
}
- (id) init
diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m
index fec04630..b7fd77c3 100644
--- a/Source/SPQueryController.m
+++ b/Source/SPQueryController.m
@@ -62,7 +62,7 @@ static SPQueryController *sharedQueryController = nil;
{
@synchronized(self) {
if (sharedQueryController == nil) {
- [[self alloc] init];
+ sharedQueryController = [[super allocWithZone:NULL] init];
}
}
@@ -72,14 +72,8 @@ static SPQueryController *sharedQueryController = nil;
+ (id)allocWithZone:(NSZone *)zone
{
@synchronized(self) {
- if (sharedQueryController == nil) {
- sharedQueryController = [super allocWithZone:zone];
-
- return sharedQueryController;
- }
+ return [[self sharedQueryController] retain];
}
-
- return nil; // On subsequent allocation attempts return nil
}
- (id)init