Skip to content

Commit fdb147a

Browse files
authored
Merge pull request #1270 from ychin/fix-settitle-crash-appearance-changed
Fix potential crash in setTitle
2 parents ec02e85 + db90226 commit fdb147a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/MacVim/MMWindowController.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,13 @@ - (void)dealloc
245245
ASLogDebug(@"");
246246

247247
[decoratedWindow release]; decoratedWindow = nil;
248+
[fullScreenWindow release]; fullScreenWindow = nil;
248249
[windowAutosaveKey release]; windowAutosaveKey = nil;
249250
[vimView release]; vimView = nil;
250251
[toolbar release]; toolbar = nil;
251252
// in case processAfterWindowPresentedQueue wasn't called
252253
[afterWindowPresentedQueue release]; afterWindowPresentedQueue = nil;
254+
[lastSetTitle release]; lastSetTitle = nil;
253255

254256
[super dealloc];
255257
}
@@ -461,8 +463,9 @@ - (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state
461463
- (void)setTitle:(NSString *)title
462464
{
463465
// Save the original title, if we haven't already.
466+
[title retain]; // retain the title first before release lastSetTitle, since you can call setTitle on lastSetTitle itself.
464467
[lastSetTitle release];
465-
lastSetTitle = [title retain];
468+
lastSetTitle = title;
466469

467470
// While in live resize the window title displays the dimensions of the
468471
// window so don't clobber this with the new title. We have already set
@@ -934,10 +937,6 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
934937
// Enter custom full-screen mode.
935938
ASLogInfo(@"Enter custom full-screen");
936939

937-
// fullScreenWindow could be non-nil here if this is called multiple
938-
// times during startup.
939-
[fullScreenWindow release];
940-
941940
NSColor *fullscreenBg = back;
942941

943942
// See setDefaultColorsBackground: for why set a transparent
@@ -946,6 +945,10 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
946945
fullscreenBg = [fullscreenBg colorWithAlphaComponent:0.001];
947946
}
948947

948+
// fullScreenWindow could be non-nil here if this is called multiple
949+
// times during startup.
950+
[fullScreenWindow release];
951+
949952
fullScreenWindow = [[MMFullScreenWindow alloc]
950953
initWithWindow:decoratedWindow view:vimView backgroundColor:fullscreenBg];
951954
[fullScreenWindow setOptions:fuoptions];

0 commit comments

Comments
 (0)