aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-03-23 21:08:33 +0000
committerrowanbeentje <rowan@beent.je>2010-03-23 21:08:33 +0000
commitc2351f2220ac01cac614de93bad05022d89d7790 (patch)
tree253cb24dac45eaa8a29924d3fe4017d1cad684ce
parent4755e7c7209582b09f59905540f459accc32acb3 (diff)
downloadsequelpro-c2351f2220ac01cac614de93bad05022d89d7790.tar.gz
sequelpro-c2351f2220ac01cac614de93bad05022d89d7790.tar.bz2
sequelpro-c2351f2220ac01cac614de93bad05022d89d7790.zip
- Remove observers for key paths when dealloc'ing objects to fix later crashes when changing those keyvalues (eg changing query editor background colour after closing windows - http://log.sequelpro.com/view/44 )
- Fix a memory leak of a prefs reference in CMTextView
-rw-r--r--Source/CMTextView.m17
-rw-r--r--Source/CustomQuery.m1
-rw-r--r--Source/SPConnectionController.m3
-rw-r--r--Source/SPProcessListController.m2
-rw-r--r--Source/SPServerVariablesController.m2
-rw-r--r--Source/SPTableRelations.m4
-rw-r--r--Source/SPTableTriggers.m1
-rw-r--r--Source/SPUserManager.m6
-rw-r--r--Source/TableDocument.m16
9 files changed, 46 insertions, 6 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 2a5c43c7..3ea60174 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -3225,7 +3225,24 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void) dealloc
{
+
+ // Remove observers
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorFont];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorBackgroundColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorHighlightQueryColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryHighlightCurrentQuery];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorCommentColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorQuoteColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorSQLKeywordColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorBacktickColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorNumericColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorVariableColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorTextColor];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorTabStopWidth];
+ [prefs removeObserver:self forKeyPath:SPCustomQueryAutoUppercaseKeywords];
+
+ [prefs release];
[lineNumberView release];
if(queryHiliteColor) [queryHiliteColor release];
if(queryEditorBackgroundColor) [queryEditorBackgroundColor release];
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index f359f9d1..c1ffa4f0 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -3246,6 +3246,7 @@
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ [prefs removeObserver:self forKeyPath:SPGlobalResultTableFont];
[usedQuery release];
[resultData release];
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 869bd35c..7e84a7f0 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -125,7 +125,8 @@
}
- (void) dealloc
-{
+{
+ [prefs removeObserver:self forKeyPath:SPFavorites];
[keychain release];
[prefs release];
if (favorites) [favorites release];
diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m
index 51f644d6..ab0ae931 100644
--- a/Source/SPProcessListController.m
+++ b/Source/SPProcessListController.m
@@ -408,6 +408,8 @@
*/
- (void)dealloc
{
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts];
+
[processes release], processes = nil;
[super dealloc];
diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m
index f8b39c19..180fe2be 100644
--- a/Source/SPServerVariablesController.m
+++ b/Source/SPServerVariablesController.m
@@ -271,6 +271,8 @@
*/
- (void)dealloc
{
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts];
+
[variables release], variables = nil;
[super dealloc];
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index 043b5d66..0788f832 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -468,8 +468,10 @@
*/
- (void)dealloc
{
- [relationData release], relationData = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts];
+
+ [relationData release], relationData = nil;
[super dealloc];
}
diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m
index 26011044..e9283124 100644
--- a/Source/SPTableTriggers.m
+++ b/Source/SPTableTriggers.m
@@ -446,6 +446,7 @@
[triggerData release], triggerData = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts];
[super dealloc];
}
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 84053fbb..35b4bcec 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -1313,10 +1313,8 @@
*/
- (void)dealloc
{
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSManagedObjectContextDidSaveNotification
- object:nil];
- [managedObjectContext release];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [managedObjectContext release];
[persistentStoreCoordinator release];
[managedObjectModel release];
[privColumnToGrantMap release];
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index ac076c8b..ee793689 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -4006,6 +4006,22 @@
*/
- (void)dealloc
{
+
+ // Unregister observers
+ [prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines];
+ [prefs removeObserver:tableSourceInstance forKeyPath:SPDisplayTableViewVerticalGridlines];
+ [prefs removeObserver:tableContentInstance forKeyPath:SPDisplayTableViewVerticalGridlines];
+ [prefs removeObserver:customQueryInstance forKeyPath:SPDisplayTableViewVerticalGridlines];
+ [prefs removeObserver:tableRelationsInstance forKeyPath:SPDisplayTableViewVerticalGridlines];
+ [prefs removeObserver:[SPQueryController sharedQueryController] forKeyPath:SPDisplayTableViewVerticalGridlines];
+ [prefs removeObserver:tableSourceInstance forKeyPath:SPUseMonospacedFonts];
+ [prefs removeObserver:[SPQueryController sharedQueryController] forKeyPath:SPUseMonospacedFonts];
+ [prefs removeObserver:tableContentInstance forKeyPath:SPGlobalResultTableFont];
+ [prefs removeObserver:[SPQueryController sharedQueryController] forKeyPath:SPConsoleEnableLogging];
+ [prefs removeObserver:self forKeyPath:SPConsoleEnableLogging];
+ if (processListController) [prefs removeObserver:processListController forKeyPath:SPDisplayTableViewVerticalGridlines];
+ if (serverVariablesController) [prefs removeObserver:serverVariablesController forKeyPath:SPDisplayTableViewVerticalGridlines];
+
[_encoding release];
[allDatabases release];
[allSystemDatabases release];