From 7dfca01f48bdd178be872341391b109e20c5e3d4 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 14 May 2012 15:26:51 +0200 Subject: [PATCH] Allow an unnamed buffer to be saved with the same name The check whether fname != oldname does not work for unnamed buffers. Therefore, we check explicitly whether the Buffer that already exists with the same name isn't really the buffer we are trying to save. (cherry picked from commit 30475664d380474f4ea0666e9aaf006cf22c1c7e) --- src/frontends/qt4/GuiView.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ea08213066..3adc781b49 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2259,8 +2259,10 @@ 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) && fname != oldname) { + // to have another one. (the second test makes sure we're not just + // trying to overwrite ourselves, which is fine.) + if (theBufferList().exists(fname) && fname != oldname + && theBufferList().getBuffer(fname) != &b) { 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" -- 2.39.5