On 08/12/2009 11:11 AM, Jürgen Spitzmüller wrote:
rgheck wrote:
With this, I don't get ask anymore if I want to die a dirty buffer.


Sorry, I don't understand. If I open LyX, type a few characters, and
choose "Close" or "Quit", I get asked as usual about closing.

I meant on buffer hiding. If I hide a dirty buffer with this new patch, LyX
just hides it without asking me if I want to save it.

Yes, that is right. The new patch doesn't try to ask about that: Vincent didn't like where I was doing it, and I can't see any other place; there were Pavel's worries; etc. So this one just asks when the Buffer itself is destroyed.

Longer term, I think Abdel's idea, that we should show a list of open buffers, with check marks, etc, is a good one, but I don't think it should delay 1.6.4. And, as I said elsewhere, even if we implement Abdel's idea, I think this is yet worthwhile, to try to catch anything we may have missed. The only thing to keep in mind is that, if the user chooses not save the buffer, or if for some other reason it ought not to be saved, then it should be marked clean---clean in the sense that it doesn't need saving. It occurred to me, for example, that we need to do this in BufferList::emergencyWrite(): If we fail, then we have to mark the Buffer clean, so as not to try to save it again when the Buffer is destroyed.

So here's the current version.

rh

Index: src/frontends/qt4/GuiView.cpp
===================================================================
--- src/frontends/qt4/GuiView.cpp       (revision 30988)
+++ src/frontends/qt4/GuiView.cpp       (working copy)
@@ -1979,6 +1979,8 @@
                // have no autosave file but I guess
                // this is really improbable (Jug)
                buf.removeAutosaveFile();
+               // clean, in the sense that it doesn't need saving
+               buf.markClean();
                break;
        case 2:
                return false;
Index: src/BufferList.cpp
===================================================================
--- src/BufferList.cpp  (revision 30988)
+++ src/BufferList.cpp  (working copy)
@@ -282,6 +282,8 @@
        }
 
        user_message += _("  Save failed! Bummer. Document is lost.");
+       // Don't try again.
+       buf->markClean();
        return user_message;
 }
 
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp      (revision 30988)
+++ src/Buffer.cpp      (working copy)
@@ -328,6 +328,20 @@
                        theBufferList().releaseChild(this, child);
        }
 
+       if (!isClean()) {
+               docstring const text = bformat(_("The document %1$s has unsaved 
changes."
+                       "\n\nDo you want to save the document or discard the 
changes?"), from_utf8(absFileName()));
+               int const ret = Alert::prompt(_("Save changed document?"),
+                               text, 0, 2, _("&Save"), _("&Discard"));
+               switch (ret) {
+               case 0:
+                       save();
+                       break;
+               case 1:
+                       break;
+               }
+       }
+
        // clear references to children in macro tables
        d->children_positions.clear();
        d->position_to_children.clear();

Reply via email to