Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

3 participants

@schubter

there were some issues with asking the user on a dirty document to save it
most of the time it wasn't asking until you quit the app

this change now asks the user on closing a dirty tab if he wants to save, discard changes and close anyway or leave the tab open and handles the response properly.

@schubter schubter there were some issues with asking the user on a dirty document to sa…
…ve it

most of the time it wasn't asking until you quit the app

this change now asks the user on closing a dirty tab if he wants to save, discard changes and close anyway or leave the tab open and handles the response properly.
d1b1e56
@rsms rsms merged commit 6043dcb into rsms:master
@parkr

Wouldn't it be better to write canCloseContentsAt:(int)index this way? Don't want to be redundant!
Kod
I don't think we lose any optimization, because that whole if-statement will be skipped if shouldCloseTab is not YES. Just ought not to repeat code, y'know what I mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 23, 2011
  1. @schubter

    there were some issues with asking the user on a dirty document to sa…

    schubter authored
    …ve it
    
    most of the time it wasn't asking until you quit the app
    
    this change now asks the user on closing a dirty tab if he wants to save, discard changes and close anyway or leave the tab open and handles the response properly.
This page is out of date. Refresh to see the latest.
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);
Something went wrong with that request. Please try again.