From 43c6809ab432dbb13a1a777c189ed056fcdfd2c8 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Fri, 27 Jun 2003 07:11:31 +0000 Subject: [PATCH] Fix two loading-related bugs reported by Kayvan git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7213 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 9 +++++---- src/ChangeLog | 5 +++++ src/frontends/qt2/ChangeLog | 4 ++++ src/frontends/qt2/lyx_gui.C | 14 ++------------ src/frontends/xforms/ChangeLog | 4 ++++ src/frontends/xforms/lyx_gui.C | 14 ++------------ src/lyx_main.C | 21 ++++++++++++--------- 7 files changed, 34 insertions(+), 37 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 13cf1d1b98..be1cea275f 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -182,10 +182,11 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles) int const ret = Alert::prompt(_("Create new document?"), text, 0, 1, _("&Create"), _("Cancel")); - if (ret == 0) { - bufferlist.close(buffer_, false); - buffer(newFile(s, string(), true)); - } + if (ret == 0) + b = newFile(s, string(), true); + else + return false; + } buffer(b); diff --git a/src/ChangeLog b/src/ChangeLog index aa646750ea..6697d026c6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,9 @@ +2003-06-26 Alfredo Brauntein + + * lyx_main.C (LyX): get full path of document loaded on the + command line + 2003-06-26 André Pönitz * lyxcursor.[Ch]: move rarely used operator==,!= out of line diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 7c68d9e7ca..0e981e1286 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-06-27 Alfredo Braunstein + + * lyx_gui.C (start): use BufferView::loadLyXFile + 2003-06-12 Jean-Marc Lasgouttes * Toolbar_pimpl.C (add): do not add unknown lfuns diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index 08413432c0..ce6371da26 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -145,24 +145,14 @@ void start(string const & batch, vector const & files) view.show(); view.init(); - Buffer * last = 0; - // FIXME: some code below needs moving lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes); vector::const_iterator cit = files.begin(); vector::const_iterator end = files.end(); - for (; cit != end; ++cit) { - Buffer * b = bufferlist.newBuffer(*cit); - if (loadLyXFile(b, *cit)) - last = b; - } - - // switch to the last buffer successfully loaded - if (last) { - view.view()->buffer(last); - } + for (; cit != end; ++cit) + view.view()->loadLyXFile(*cit, true); // handle the batch commands the user asked for if (!batch.empty()) { diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 6af27ac3f5..4d819e3017 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2003-06-27 Alfredo Braunstein + + * lyx_gui.C (start): use BufferView::loadLyXFile + 2003-06-21 Alfredo Braunstein * FormError.[Ch]: diff --git a/src/frontends/xforms/lyx_gui.C b/src/frontends/xforms/lyx_gui.C index ccf772656d..656d663579 100644 --- a/src/frontends/xforms/lyx_gui.C +++ b/src/frontends/xforms/lyx_gui.C @@ -277,24 +277,14 @@ void start(string const & batch, vector const & files) view.show(xpos, ypos, "LyX"); view.init(); - Buffer * last = 0; - // FIXME: some code below needs moving lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes); vector::const_iterator cit = files.begin(); vector::const_iterator end = files.end(); - for (; cit != end; ++cit) { - Buffer * b = bufferlist.newBuffer(*cit); - if (loadLyXFile(b, *cit)) - last = b; - } - - // switch to the last buffer successfully loaded - if (last) { - view.view()->buffer(last); - } + for (; cit != end; ++cit) + view.view()->loadLyXFile(*cit, true); // handle the batch commands the user asked for if (!batch.empty()) { diff --git a/src/lyx_main.C b/src/lyx_main.C index 45936db479..44cd30ab06 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -143,21 +143,24 @@ LyX::LyX(int & argc, char * argv[]) Buffer * last_loaded = 0; - vector::iterator it = files.begin(); - vector::iterator end = files.end(); + vector::const_iterator it = files.begin(); + vector::const_iterator end = files.end(); + for (; it != end; ++it) { - last_loaded = bufferlist.newBuffer(*it, false); + // get absolute path of file and add ".lyx" to + // the filename if necessary + string s = FileSearch(string(), *it, "lyx"); + if (s.empty()) { + s = *it; + } + + last_loaded = bufferlist.newBuffer(s, false); last_loaded->parseError.connect(boost::bind(&LyX::printError, this, _1)); - loadLyXFile(last_loaded, *it); + loadLyXFile(last_loaded, s); } files.clear(); - // no buffer loaded, create one - string const tmpfile = "tmpfile"; - if (!last_loaded) - last_loaded = newFile(tmpfile, string()); - bool success = false; // try to dispatch to last loaded buffer first -- 2.39.2