Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Merged
merged 1 commit into from about 3 years ago

3 participants

Andreas Schubert Parker Moore Rasmus
Andreas Schubert

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.

Andreas Schubert 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
Rasmus rsms merged commit 6043dcb into from
Rasmus rsms closed this
Parker Moore
parkr commented on d1b1e56

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

Showing 1 unique commit by 1 author.

May 23, 2011
Andreas Schubert 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 21 additions and 10 deletions. Show diff stats Hide diff stats

  1. +21 10 src/KBrowser.mm
31 src/KBrowser.mm
@@ -52,15 +52,7 @@ - (CTTabContents*)addTabContents:(CTTabContents*)tab
52 52 // Overriding CTBrowser's -closeTab in order to check if the document is
53 53 // dirty or not before closing.
54 54 - (void)closeTab {
55   - KDocument *doc = (KDocument *)[self tabContentsAtIndex:[self selectedTabIndex]];
56   -
57   - if ([doc isDirty]) {
58   - [doc canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(document:shouldClose:contextInfo:) contextInfo:nil];
59   - } else {
60   - shouldCloseTab = YES;
61   - [super closeTab];
62   - }
63   -
  55 + shouldCloseTab = NO;
64 56 }
65 57
66 58
@@ -69,7 +61,10 @@ - (void)document:(NSDocument *)tab
69 61 shouldClose:(BOOL)shouldClose
70 62 contextInfo:(void*)contextInfo {
71 63 shouldCloseTab = shouldClose;
72   - [super closeTab];
  64 +
  65 + if ( shouldClose ) {
  66 + [super closeTab];
  67 + }
73 68 }
74 69
75 70
@@ -78,6 +73,22 @@ - (BOOL)canCloseTab {
78 73 return shouldCloseTab;
79 74 }
80 75
  76 +- (BOOL)canCloseContentsAt:(int)index {
  77 + if ( shouldCloseTab == YES ) {
  78 + return shouldCloseTab;
  79 + }
  80 +
  81 + KDocument *doc = (KDocument *)[self tabContentsAtIndex:index];
  82 +
  83 + if ([doc isDirty]) {
  84 + [doc canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(document:shouldClose:contextInfo:) contextInfo:nil];
  85 + } else {
  86 + shouldCloseTab = YES;
  87 + }
  88 +
  89 + return shouldCloseTab;
  90 +}
  91 +
81 92
82 93 /*-(void)updateTabStateForContent:(CTTabContents*)contents {
83 94 DLOG("updateTabStateForContent:%@", contents);

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.