From 4f35896057fdc7b6e16c55cf4805177c00967f18 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 25 Aug 2011 23:03:00 +0000 Subject: - Prevent export and indexes controller awakeFromNib: routines from being run multiple times - Fix crashes and exceptions when using "Use monospaced fonts" or "Display vertical grid lines" preferences after closing at least one window --- Source/SPIndexesController.m | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Source/SPIndexesController.m') diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index 8058ff3f..92a0ddf6 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -79,6 +79,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; #endif if ((self = [super initWithWindowNibName:nibName])) { + _mainNibLoaded = NO; table = @""; fields = [[NSMutableArray alloc] init]; @@ -114,6 +115,11 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; */ - (void)awakeFromNib { + + // As this controller also loads its own nib, it may call awakeFromNib multiple times; perform setup only once. + if (_mainNibLoaded) return; + _mainNibLoaded = YES; + #ifndef SP_REFACTOR /* patch */ // Set the index tables view's vertical gridlines if required [indexesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; @@ -1018,6 +1024,10 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if (indexedFields) [indexedFields release], indexedFields = nil; +#ifndef SP_REFACTOR + [prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines]; +#endif + [super dealloc]; } -- cgit v1.2.3