Skip to content
Snippets Groups Projects
Commit f9fd4ae1 authored by George Nachman's avatar George Nachman
Browse files

Add -shutdown to Popup and don't twiddle key status from within...

Add -shutdown to Popup and don't twiddle key status from within windowDidResignKey, which has crazy side effects. Fix bug where clicking on a background term while a popup is opened resulted in two key terms. Also fix a crash when quitting iTerm2 without confirmation while a popup is open. Fixes a crash when closing a term with cmd-opt-w while a popup is open.
parent 98e4085e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -11,6 +11,7 @@
 
@interface PopupWindow : NSWindow {
NSWindow* parentWindow_;
BOOL shutdown_;
}
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
Loading
Loading
@@ -19,6 +20,7 @@
- (void)setParentWindow:(NSWindow*)parentWindow;
- (BOOL)canBecomeKeyWindow;
- (void)keyDown:(NSEvent *)event;
- (void)shutdown;
 
@end
 
Loading
Loading
@@ -110,6 +112,10 @@
// Called by clients to open window.
- (void)popInSession:(PTYSession*)session;
 
// Safely shut down the popup when the parent is about to be dealloced. Clients must call this from
// dealloc. It removes possible pending timers.
- (void)shutdown;
// Subclasses may override these methods.
// Begin populating the unfiltered model.
- (void)refresh;
Loading
Loading
Loading
Loading
@@ -158,6 +158,11 @@ DebugLog([NSString stringWithFormat:args]); \
}
}
 
- (void)shutdown
{
shutdown_ = YES;
}
- (void)setParentWindow:(NSWindow*)parentWindow
{
parentWindow_ = parentWindow;
Loading
Loading
@@ -165,8 +170,21 @@ DebugLog([NSString stringWithFormat:args]); \
 
- (void)close
{
// The OS will send a hotkey window to the background if it's open and in
// all spaces. So make it key before closing.
if (shutdown_) {
[super close];
} else {
// The OS will send a hotkey window to the background if it's open and in
// all spaces. Make it key before closing. This has to be done later because if you do it
// here the OS gets confused and two windows are key.
NSLog(@"Perform delayed selector with target %@", self);
[self performSelector:@selector(twiddleKeyWindow)
withObject:self
afterDelay:0];
}
}
- (void)twiddleKeyWindow
{
iTermApplicationDelegate* theDelegate = [NSApp delegate];
[theDelegate makeHotKeyWindowKeyIfOpen];
[super close];
Loading
Loading
@@ -317,6 +335,19 @@ DebugLog([NSString stringWithFormat:args]); \
[super dealloc];
}
 
- (void)shutdown
{
// Disable the fancy footwork in -[PopupWindow close]
[(PopupWindow*)[self window] shutdown];
// Prevent twiddleKeyWindow from running after parent window is dealloc'ed.
[NSObject cancelPreviousPerformRequestsWithTarget:[self window]];
// Force the window to close immediately.
[self close];
}
- (BOOL)disableFocusFollowsMouse
{
return YES;
Loading
Loading
@@ -598,6 +629,13 @@ DebugLog([NSString stringWithFormat:args]); \
 
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
if (!session_) {
// A dialog box can cause you to become key after closing because of a
// race condition with twiddleKeyWindow. But it immediately loses key
// status again after this. Because it was already closed, there is no
// session at this point and we just return harmlessly.
return;
}
clearFilterOnNextKeyDown_ = NO;
if (timer_) {
[timer_ invalidate];
Loading
Loading
Loading
Loading
@@ -704,6 +704,8 @@ NSString *sessionsKey = @"sessions";
[commandField release];
[bottomBar release];
[_toolbarController release];
[autocompleteView shutdown];
[pbHistoryView shutdown];
[pbHistoryView release];
[autocompleteView release];
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment