there were some issues with asking the user on a dirty document to save i #60

Merged
merged 1 commit into from Jun 20, 2011
Jump to file or symbol
Failed to load files and symbols.
+21 −10
Split
View
@@ -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);