[LyX/master] Fix bug #12609

Richard Kimberly Heck rikiheck at lyx.org
Mon Dec 12 21:37:46 UTC 2022


commit 88f0a98b527f5ef1bc5c5c8d06651b0dc039da81
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Mon Dec 12 17:33:56 2022 -0500

    Fix bug #12609
---
 src/frontends/qt/GuiApplication.cpp |    4 ++--
 src/frontends/qt/GuiView.cpp        |   15 +++++++++++++--
 src/frontends/qt/GuiView.h          |    2 +-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index d04511a..967f134 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -1858,7 +1858,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 			// We want the ui session to be saved per document and not per
 			// window number. The filename crc is a good enough identifier.
 			createView(support::checksum(fname));
-			current_view_->openDocument(fname);
+			current_view_->openDocument(fname, cmd.origin());
 			if (!current_view_->documentBufferView())
 				current_view_->close();
 			else if (cmd.origin() == FuncRequest::LYXSERVER) {
@@ -1867,7 +1867,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 				current_view_->showNormal();
 			}
 		} else {
-			current_view_->openDocument(fname);
+			current_view_->openDocument(fname, cmd.origin());
 			if (cmd.origin() == FuncRequest::LYXSERVER) {
 				current_view_->raise();
 				current_view_->activateWindow();
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index fea540a..3e91ffc 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -2792,7 +2792,7 @@ Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
 }
 
 
-void GuiView::openDocument(string const & fname)
+void GuiView::openDocument(string const & fname, int origin)
 {
 	string initpath = lyxrc.document_path;
 
@@ -2849,7 +2849,18 @@ void GuiView::openDocument(string const & fname)
 	// let the user create one
 	if (!fullname.exists() && !theBufferList().exists(fullname) &&
 	    !LyXVC::file_not_found_hook(fullname)) {
-		// The user specifically chose this name. Believe them.
+		// see bug #12609
+		if (origin == FuncRequest::MENU) {
+			docstring const & msg =
+				bformat(_("File\n %1$s\n does not exist. Create empty file?"),
+						from_utf8(filename));
+			int ret = Alert::prompt(_("File does not exist"),
+						msg, 0, 1,
+						_("&Create File"),
+						_("&Cancel"));
+			if (ret == 1)
+				return;
+		}
 		Buffer * const b = newFile(filename, string(), true);
 		if (b)
 			setBuffer(b);
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index eff923b..57461d0 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -164,7 +164,7 @@ public:
 	/// closes the buffer
 	bool closeBuffer(Buffer & buf);
 	///
-	void openDocument(std::string const & filename);
+	void openDocument(std::string const & filename, int origin);
 	///
 	void importDocument(std::string const &);
 


More information about the lyx-cvs mailing list