From bcca9bb6b7ac28ea9e905abdcb514218b351f7c3 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 7 Dec 2011 20:45:35 +0000 Subject: [PATCH] Fix bug #7921. We should not allow the user to save a file thereby over-writing a file that is already open. So we issue a warning and ask if they'd like to try a different name. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40421 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 20 +++++++++++++++++++- status.20x | 5 ++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index d3c45676e4..330e8b197b 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2293,9 +2293,27 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname) } // fname is now the new Buffer location. + + // if there is already a Buffer open with this name, we do not want + // to have another one. + if (theBufferList().exists(fname)) { + docstring const text = + bformat(_("The file\n%1$s\nis already open in your current session.\n" + "Please close it before attempting to overwrite it.\n" + "Do you want to choose a new filename?"), + from_utf8(fname.absFileName())); + int const ret = Alert::prompt(_("Chosen File Already Open"), + text, 0, 1, _("&Rename"), _("&Cancel")); + switch (ret) { + case 0: return renameBuffer(b, docstring()); + case 1: return false; + } + //return false; + } + if (FileName(fname).exists()) { docstring const file = makeDisplayPath(fname.absFileName(), 30); - docstring text = bformat(_("The document %1$s already " + docstring const text = bformat(_("The document %1$s already " "exists.\n\nDo you want to " "overwrite that document?"), file); diff --git a/status.20x b/status.20x index ecdf5c8ce2..12274bc8e4 100644 --- a/status.20x +++ b/status.20x @@ -75,8 +75,11 @@ What's new - Fix crash when exporting branches to XHTML. +- Do not allow user to over-write a file already open. Attempting to do so + crashes LyX (bug 7921). -* TeX2LyX + +* TEX2LYX - Formal tables are now supported (bug 4553). -- 2.39.5