Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #60 from schubter/patch-1

there were some issues with asking the user on a dirty document to save i
  • Loading branch information...
commit 6043dcb673c3431e5f4cbcad3e3254560f7ca3bc 2 parents af00f25 + d1b1e56
@rsms authored
Showing with 21 additions and 10 deletions.
  1. +21 −10 src/KBrowser.mm
View
31 src/KBrowser.mm
@@ -52,15 +52,7 @@ - (CTTabContents*)addTabContents:(CTTabContents*)tab
// Overriding CTBrowser's -closeTab in order to check if the document is
// dirty or not before closing.
- (void)closeTab {
- KDocument *doc = (KDocument *)[self tabContentsAtIndex:[self selectedTabIndex]];
-
- if ([doc isDirty]) {
- [doc canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(document:shouldClose:contextInfo:) contextInfo:nil];
- } else {
- shouldCloseTab = YES;
- [super closeTab];
- }
-
+ shouldCloseTab = NO;
}
@@ -69,7 +61,10 @@ - (void)document:(NSDocument *)tab
shouldClose:(BOOL)shouldClose
contextInfo:(void*)contextInfo {
shouldCloseTab = shouldClose;
- [super closeTab];
+
+ if ( shouldClose ) {
+ [super closeTab];
+ }
}
@@ -78,6 +73,22 @@ - (BOOL)canCloseTab {
return shouldCloseTab;
}
+- (BOOL)canCloseContentsAt:(int)index {
+ if ( shouldCloseTab == YES ) {
+ return shouldCloseTab;
+ }
+
+ KDocument *doc = (KDocument *)[self tabContentsAtIndex:index];
+
+ if ([doc isDirty]) {
+ [doc canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(document:shouldClose:contextInfo:) contextInfo:nil];
+ } else {
+ shouldCloseTab = YES;
+ }
+
+ return shouldCloseTab;
+}
+
/*-(void)updateTabStateForContent:(CTTabContents*)contents {
DLOG("updateTabStateForContent:%@", contents);
Please sign in to comment.
Something went wrong with that request. Please try again.