]> git.lyx.org Git - features.git/commitdiff
Fix bug #12609
authorRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 12 Dec 2022 22:33:56 +0000 (17:33 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 12 Dec 2022 22:33:56 +0000 (17:33 -0500)
src/frontends/qt/GuiApplication.cpp
src/frontends/qt/GuiView.cpp
src/frontends/qt/GuiView.h

index d04511ae7f23f6e68144ec688d5a034cabf42ed7..967f13415347d15be28eb60027da16cdf86c02de 100644 (file)
@@ -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();
index fea540ad5a2149943ba5acb5482cf3af38e5f2cb..3e91ffcc2c8d90199637d22692e65ca146582152 100644 (file)
@@ -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);
index eff923bda456862bf163c3c47c0adafde84e2e4d..57461d09bf747a3d277ce4ffda9eda51cb8d123c 100644 (file)
@@ -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 &);