]> git.lyx.org Git - features.git/commitdiff
Move the call to Buffer::errors("Parse") from BufferView::insertLyXFile to GuiView...
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 29 Oct 2010 16:51:50 +0000 (16:51 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 29 Oct 2010 16:51:50 +0000 (16:51 +0000)
Buffer::errors("Parse") is called 7 times in the whole project. 4 times from GuiView and three times from functions in other classes, but which are (almost) only called from the GuiView.

Buffer::errors is used to signal the GUI that there might be an error occuring, but what sense does it make if it is only called from the Gui ?

Isn't it better to let the function return wether it succeeded or not and let the GuiView take action in doing something with the possible errors.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35911 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/frontends/qt4/GuiView.cpp

index 33d9199f2e573d8075be72ae4dfd4b28800be061..4ae3c5616eef86ed00594527cd372bbdafd0cad1 100644 (file)
@@ -2528,7 +2528,6 @@ void BufferView::insertLyXFile(FileName const & fname)
        buffer_.changed(true);
        // emit message signal.
        message(bformat(res, disp_fn));
-       buffer_.errors("Parse");
 }
 
 
index ecd53ce8b0605339bf7ed647bcffca8bcdaf7193..6dc35a72df8f6e503e6df8aad55f963ae35b00cb 100644 (file)
@@ -2100,44 +2100,41 @@ void GuiView::insertLyXFile(docstring const & fname)
 
        // FIXME UNICODE
        FileName filename(to_utf8(fname));
+       if (filename.empty()) {
+               // Launch a file browser
+               // FIXME UNICODE
+               string initpath = lyxrc.document_path;
+               string const trypath = bv->buffer().filePath();
+               // If directory is writeable, use this as default.
+               if (FileName(trypath).isDirWritable())
+                       initpath = trypath;
 
-       if (!filename.empty()) {
-               bv->insertLyXFile(filename);
-               return;
-       }
-
-       // Launch a file browser
-       // FIXME UNICODE
-       string initpath = lyxrc.document_path;
-       string const trypath = bv->buffer().filePath();
-       // If directory is writeable, use this as default.
-       if (FileName(trypath).isDirWritable())
-               initpath = trypath;
-
-       // FIXME UNICODE
-       FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
-       dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
-       dlg.setButton2(qt_("Examples|#E#e"),
-               toqstr(addPath(package().system_support().absFileName(),
-               "examples")));
+               // FIXME UNICODE
+               FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
+               dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+               dlg.setButton2(qt_("Examples|#E#e"),
+                       toqstr(addPath(package().system_support().absFileName(),
+                       "examples")));
 
-       FileDialog::Result result = dlg.open(toqstr(initpath),
-                                QStringList(qt_("LyX Documents (*.lyx)")));
+               FileDialog::Result result = dlg.open(toqstr(initpath),
+                                        QStringList(qt_("LyX Documents (*.lyx)")));
 
-       if (result.first == FileDialog::Later)
-               return;
+               if (result.first == FileDialog::Later)
+                       return;
 
-       // FIXME UNICODE
-       filename.set(fromqstr(result.second));
+               // FIXME UNICODE
+               filename.set(fromqstr(result.second));
 
-       // check selected filename
-       if (filename.empty()) {
-               // emit message signal.
-               message(_("Canceled."));
-               return;
+               // check selected filename
+               if (filename.empty()) {
+                       // emit message signal.
+                       message(_("Canceled."));
+                       return;
+               }
        }
 
        bv->insertLyXFile(filename);
+       bv->buffer().errors("Parse");
 }