From 88f0a98b527f5ef1bc5c5c8d06651b0dc039da81 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Mon, 12 Dec 2022 17:33:56 -0500 Subject: [PATCH] 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 d04511ae7f..967f134153 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 fea540ad5a..3e91ffcc2c 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 eff923bda4..57461d09bf 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 &); -- 2.39.5