diff options
author | Max <post@wickenrode.com> | 2017-05-16 00:29:21 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2017-05-16 00:29:21 +0200 |
commit | 8fcdb7bcc6dedb7af9b1a7829a83cdc2fca54f4b (patch) | |
tree | 6b550386c3b2c9e2d8b2f5627beb6b03b30609fa | |
parent | b50d4e9a6f55c26d3fbe33b33d78063ad1e9e9fd (diff) | |
download | sequelpro-8fcdb7bcc6dedb7af9b1a7829a83cdc2fca54f4b.tar.gz sequelpro-8fcdb7bcc6dedb7af9b1a7829a83cdc2fca54f4b.tar.bz2 sequelpro-8fcdb7bcc6dedb7af9b1a7829a83cdc2fca54f4b.zip |
Fix an erroneous check that would allow to close windows with only one tab even when it was busy (#2787)
-rw-r--r-- | Source/SPWindowController.m | 7 | ||||
-rw-r--r-- | Source/SPWindowControllerDelegate.m | 16 |
2 files changed, 10 insertions, 13 deletions
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index 7f3c687b..9755cd0d 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -160,15 +160,14 @@ */ - (IBAction)closeTab:(id)sender { - // Return if the selected tab shouldn't be closed - if (![selectedTableDocument parentTabShouldClose]) return; - // If there are multiple tabs, close the front tab. if ([tabView numberOfTabViewItems] > 1) { + // Return if the selected tab shouldn't be closed + if (![selectedTableDocument parentTabShouldClose]) return; [tabView removeTabViewItem:[tabView selectedTabViewItem]]; - } else { + //trying to close the window will itself call parentTabShouldClose for all tabs in windowShouldClose: [[self window] performClose:self]; } } diff --git a/Source/SPWindowControllerDelegate.m b/Source/SPWindowControllerDelegate.m index 79b1e2f1..009dc0a4 100644 --- a/Source/SPWindowControllerDelegate.m +++ b/Source/SPWindowControllerDelegate.m @@ -56,15 +56,11 @@ */ - (BOOL)windowShouldClose:(id)sender { - // Iterate through all tabs if more than one tab is opened only otherwise - // [... parentTabShouldClose] will be called twice [see self closeTab:(id)sender] - if ([[tabView tabViewItems] count] > 1) { - for (NSTabViewItem *eachItem in [tabView tabViewItems]) - { - SPDatabaseDocument *eachDocument = [eachItem identifier]; - - if (![eachDocument parentTabShouldClose]) return NO; - } + for (NSTabViewItem *eachItem in [tabView tabViewItems]) + { + SPDatabaseDocument *eachDocument = [eachItem identifier]; + + if (![eachDocument parentTabShouldClose]) return NO; } // Remove global session data if the last window of a session will be closed @@ -190,6 +186,8 @@ /** * Called to determine whether a tab view item can be closed + * + * Note: This is ONLY called when using the "X" button on the tab itself. */ - (BOOL)tabView:(NSTabView *)aTabView shouldCloseTabViewItem:(NSTabViewItem *)tabViewItem { |