diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index b8ce17902b..ea3e2f16de 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -425,10 +425,7 @@ typedef struct fontContainerRef = 0; } - // TODO: Is this a correct way of releasing the MMAppController? - // (It doesn't seem like dealloc is ever called.) [NSApp setDelegate:nil]; - [self autorelease]; } - (void)removeVimController:(id)controller diff --git a/src/MacVim/MMFullscreenWindow.m b/src/MacVim/MMFullscreenWindow.m index e1caa370b4..f4b0e5c9c1 100644 --- a/src/MacVim/MMFullscreenWindow.m +++ b/src/MacVim/MMFullscreenWindow.m @@ -76,8 +76,8 @@ static int numFullscreenWindows = 0; - (void)dealloc { - [target release]; - [view release]; + [target release]; target = nil; + [view release]; view = nil; [super dealloc]; } diff --git a/src/MacVim/MMTextStorage.m b/src/MacVim/MMTextStorage.m index 9cfa4f77bc..284cefcad8 100644 --- a/src/MacVim/MMTextStorage.m +++ b/src/MacVim/MMTextStorage.m @@ -91,18 +91,18 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar"; rowCache = NULL; } #endif - [emptyRowString release]; - [boldItalicFontWide release]; - [italicFontWide release]; - [boldFontWide release]; - [fontWide release]; - [boldItalicFont release]; - [italicFont release]; - [boldFont release]; - [font release]; - [defaultBackgroundColor release]; - [defaultForegroundColor release]; - [attribString release]; + [emptyRowString release]; emptyRowString = nil; + [boldItalicFontWide release]; boldItalicFontWide = nil; + [italicFontWide release]; italicFontWide = nil; + [boldFontWide release]; boldFontWide = nil; + [fontWide release]; fontWide = nil; + [boldItalicFont release]; boldItalicFont = nil; + [italicFont release]; italicFont = nil; + [boldFont release]; boldFont = nil; + [font release]; font = nil; + [defaultBackgroundColor release]; defaultBackgroundColor = nil; + [defaultForegroundColor release]; defaultForegroundColor = nil; + [attribString release]; attribString = nil; [super dealloc]; } @@ -631,10 +631,10 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar"; - (void)setFont:(NSFont*)newFont { if (newFont && font != newFont) { - [boldItalicFont release]; - [italicFont release]; - [boldFont release]; - [font release]; + [boldItalicFont release]; boldItalicFont = nil; + [italicFont release]; italicFont = nil; + [boldFont release]; boldFont = nil; + [font release]; font = nil; // NOTE! When setting a new font we make sure that the advancement of // each glyph is fixed. @@ -696,10 +696,10 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar"; // very well include wide characters.) if (font) [self setWideFont:font]; } else if (newFont != fontWide) { - [boldItalicFontWide release]; - [italicFontWide release]; - [boldFontWide release]; - [fontWide release]; + [boldItalicFontWide release]; boldItalicFontWide = nil; + [italicFontWide release]; italicFontWide = nil; + [boldFontWide release]; boldFontWide = nil; + [fontWide release]; fontWide = nil; float pointSize = [newFont pointSize]; NSFontDescriptor *desc = [newFont fontDescriptor]; diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index 3d7df765c0..70ef1185fc 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -98,8 +98,8 @@ enum { // The text storage retains the layout manager which in turn retains // the text container. - [tc release]; - [lm release]; + [tc autorelease]; + [lm autorelease]; // NOTE: This will make the text storage the principal owner of the text // system. Releasing the text storage will in turn release the layout @@ -129,7 +129,7 @@ enum { markedTextField = nil; } - [lastMouseDownEvent release]; + [lastMouseDownEvent release]; lastMouseDownEvent = nil; [super dealloc]; } @@ -249,10 +249,8 @@ enum { int flags = *((int*)bytes); bytes += sizeof(int); int len = *((int*)bytes); bytes += sizeof(int); NSString *string = [[NSString alloc] - initWithBytesNoCopy:(void*)bytes - length:len - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; + initWithBytes:(void*)bytes length:len + encoding:NSUTF8StringEncoding]; bytes += len; #if MM_DEBUG_DRAWING @@ -703,6 +701,9 @@ enum { [markedTextField setBezeled:NO]; [markedTextField setBordered:YES]; + // NOTE: The panel that holds the marked text field is allocated here + // and released in dealloc. No pointer to the panel is kept, instead + // [markedTextField window] is used to access the panel. NSPanel *panel = [[NSPanel alloc] initWithContentRect:cellRect styleMask:NSBorderlessWindowMask|NSUtilityWindowMask diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 5bdc08e334..1964cc38c8 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -833,10 +833,8 @@ static NSTimeInterval MMResendInterval = 0.5; const void *bytes = [data bytes]; int len = *((int*)bytes); bytes += sizeof(int); NSString *actionName = [[NSString alloc] - initWithBytesNoCopy:(void*)bytes - length:len - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; + initWithBytes:(void*)bytes length:len + encoding:NSUTF8StringEncoding]; SEL sel = NSSelectorFromString(actionName); [NSApp sendAction:sel to:nil from:self]; @@ -848,10 +846,8 @@ static NSTimeInterval MMResendInterval = 0.5; int col = *((int*)bytes); bytes += sizeof(int); int len = *((int*)bytes); bytes += sizeof(int); NSString *title = [[NSString alloc] - initWithBytesNoCopy:(void*)bytes - length:len - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; + initWithBytes:(void*)bytes length:len + encoding:NSUTF8StringEncoding]; NSMenu *menu = [self topLevelMenuForTitle:title]; if (menu) { @@ -1222,7 +1218,7 @@ static NSTimeInterval MMResendInterval = 0.5; @implementation MMAlert - (void)dealloc { - [textField release]; + [textField release]; textField = nil; [super dealloc]; } diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m index e925239a65..18c904bbf3 100644 --- a/src/MacVim/MMVimView.m +++ b/src/MacVim/MMVimView.m @@ -287,10 +287,8 @@ enum { int length = *((int*)p); p += sizeof(int); NSString *label = [[NSString alloc] - initWithBytesNoCopy:(void*)p - length:length - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; + initWithBytes:(void*)p length:length + encoding:NSUTF8StringEncoding]; p += length; // Set the label of the tab; add a new tab when needed. @@ -356,7 +354,7 @@ enum { [[self tabView] addTabViewItem:tvi]; vimTaskSelectedTab = NO; - [tvi release]; + [tvi autorelease]; return tvi; } diff --git a/src/MacVim/MMWindow.m b/src/MacVim/MMWindow.m index 70a9fd2ef7..dae9087a56 100644 --- a/src/MacVim/MMWindow.m +++ b/src/MacVim/MMWindow.m @@ -45,6 +45,8 @@ defer:flag]; if (!self) return nil; + [self setReleasedWhenClosed:NO]; + NSRect tabSepRect = { 0, rect.size.height - 1, rect.size.width, 1 }; tablineSeparator = [[NSBox alloc] initWithFrame:tabSepRect]; @@ -61,7 +63,8 @@ - (void)dealloc { - [tablineSeparator removeFromSuperviewWithoutNeedingDisplay]; + // TODO: Is there any reason why we would want the following call? + //[tablineSeparator removeFromSuperviewWithoutNeedingDisplay]; [tablineSeparator release]; tablineSeparator = nil; [super dealloc]; }