On 08/11/2009 12:21 PM, Jürgen Spitzmüller wrote:
If you add Pavel's valid concerns about multiple views to this, I think theonly way to go now is your second approach: check for dirty hidden buffers on exit. I agree that this is sub-optimal, but everything else strikes me pretty complicated for the time being.
The more I look, the more problems there are with the other approach. And I think the safety net in the ~Buffer approach is probably worth it, anyway, if it can be made to work.

The only glitch I observed with this second route is that the dialog shows up 
after the main window was closed. I think we should try to keep this open, 
maybe even bring the hidden buffer up, in the given case.

There's no way around this, I don't think. The Buffer only gets destroyed at the very end, in prepareExit(). So the window is long since gone, or may be.

So try the attached. The only change from before is the one line in GuiView.cpp, which marks the Buffer clean if the user says she wants to discard changes. It's clean in the sense that it doesn't need to be saved. That way we don't get asked again about saving it when the Buffer object is destroyed.

rh

Index: Buffer.cpp
===================================================================
--- Buffer.cpp  (revision 30978)
+++ 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();
Index: frontends/qt4/GuiView.cpp
===================================================================
--- frontends/qt4/GuiView.cpp   (revision 30978)
+++ 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;

Reply via email to