From: Vincent van Ravesteijn Date: Fri, 29 Oct 2010 16:51:50 +0000 (+0000) Subject: Move the call to Buffer::errors("Parse") from BufferView::insertLyXFile to GuiView... X-Git-Tag: 2.0.0~2187 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ef7ecea2b3d78a88ee160c583c2cc017d980f4bc;p=features.git Move the call to Buffer::errors("Parse") from BufferView::insertLyXFile to GuiView::insertLyXFile. 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 --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 33d9199f2e..4ae3c5616e 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2528,7 +2528,6 @@ void BufferView::insertLyXFile(FileName const & fname) buffer_.changed(true); // emit message signal. message(bformat(res, disp_fn)); - buffer_.errors("Parse"); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ecd53ce8b0..6dc35a72df 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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"); }