]> git.lyx.org Git - features.git/commitdiff
Fix to Bug 1287 and Bug 1297
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 29 Jul 2003 16:40:26 +0000 (16:40 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 29 Jul 2003 16:40:26 +0000 (16:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7443 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/buffer_funcs.C
src/frontends/xforms/lyx_gui.C
src/lyx_main.C

index 2efe77dc3de700631464e2cd042e1dc2cb545d2d..c15bf9b7d23cda9b9ece972b357a20078804e16b 100644 (file)
@@ -188,9 +188,11 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
        // get absolute path of file and add ".lyx" to the filename if
        // necessary
        string s = FileSearch(string(), filename, "lyx");
-       if (s.empty()) {
+       
+       bool const found = !s.empty();
+
+       if (!found) 
                s = filename;
-       }
 
        // file already open?
        if (bufferlist.exists(s)) {
@@ -211,29 +213,35 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
                        // Fall through to new load. (Asger)
                }
        }
-       Buffer * b = bufferlist.newBuffer(s);
 
-       connectBuffer(*b);
+       Buffer * b;
 
-       if (! ::loadLyXFile(b, s)) {
-               bufferlist.release(b);
+       if (found) {
+               b = bufferlist.newBuffer(s);
+               connectBuffer(*b);
+               if (!::loadLyXFile(b, s)) {
+                       bufferlist.release(b);
+                       return false;
+               }
+       } else {
                string text = bformat(_("The document %1$s does not yet "
                                        "exist.\n\nDo you want to create "
                                        "a new document?"), s);
                int const ret = Alert::prompt(_("Create new document?"),
                         text, 0, 1, _("&Create"), _("Cancel"));
 
-               if (ret != 0)
+               if (ret == 0)
+                       b = ::newFile(s, string(), true);
+               else
                        return false;
        }
 
        buffer(b);
+       bv_->showErrorList(_("Parse"));
 
        if (tolastfiles)
                lastfiles->newFile(b->fileName());
 
-       bv_->showErrorList(_("Parse"));
-
        return true;
 }
 
@@ -281,18 +289,16 @@ void BufferView::Pimpl::buffer(Buffer * b)
                return;
 
        // if we are closing the buffer, use the first buffer as current
-       if (!buffer_) {
+       if (!buffer_)
                buffer_ = bufferlist.first();
-       }
 
        if (buffer_) {
                lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
                connectBuffer(*buffer_);
 
                // If we don't have a text object for this, we make one
-               if (bv_->text == 0) {
+               if (bv_->text == 0)
                        resizeCurrentBuffer();
-               }
 
                // FIXME: needed when ?
                bv_->text->top_y(screen().topCursorVisible(bv_->text));
index 571694f49433a9376ae20e35566c61f39b8cb2a0..7088cf6a46fe5e53acb0f58c95ee720bd68ad77e 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-29  Alfredo Braunstein  <abraunst@libero.it>
+       
+       * lyx_main.C (LyX):
+       * BufferView_pimpl.C (loadLyXFile): fix to bugs 1287 and 1297 + ws
+
+       
 2003-07-29  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * LaTeXFeatures.C:
index 59b1cfc9e43c65ecd9c150da7bded07b9532dfae..018a0bf4bd1082e148287189516bf6d21bb43f63 100644 (file)
@@ -163,8 +163,7 @@ Buffer * newFile(string const & filename, string const & templatename,
        if (!tname.empty()) {
                if (!b->readFile(tname)) {
                        string const file = MakeDisplayPath(tname, 50);
-                       string const text  = bformat(_("The specified document template\n%1$s\n"
-                               "could not be read."), file);
+                       string const text  = bformat(_("The specified document template\n%1$s\ncould not be read."), file);
                        Alert::error(_("Could not read template"), text);
                        // no template, start with empty buffer
                        b->paragraphs.push_back(Paragraph());
index c97b591b3da2626430e46a9914eff61fea94d269..c86b834d466de0e507a2ca39ed5d8e75b6169231 100644 (file)
@@ -290,9 +290,8 @@ void start(string const & batch, vector<string> const & files)
                view.view()->loadLyXFile(*cit, true);
 
        // handle the batch commands the user asked for
-       if (!batch.empty()) {
+       if (!batch.empty())
                view.getLyXFunc().dispatch(batch);
-       }
 
        // enter the event loop
        while (!finished) {
index f12367b635a9517618eebed035035155a94a32f7..666362d2295fd174007c822b809996cfa77585b3 100644 (file)
@@ -59,7 +59,6 @@ using std::signal;
 using std::system;
 #endif
 
-extern void LoadLyXFile(string const &);
 extern void QuitLyX();
 
 extern LyXServer * lyxserver;
@@ -97,9 +96,8 @@ LyX::LyX(int & argc, char * argv[])
        // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
        lyx::graphics::setDisplayTranslator();
 
-       if (want_gui) {
+       if (want_gui)
                lyx_gui::parse_init(argc, argv);
-       }
 
        // check for any spurious extra arguments
        // other than documents
@@ -116,15 +114,13 @@ LyX::LyX(int & argc, char * argv[])
        init(want_gui);
        lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
 
-       if (want_gui) {
+       if (want_gui) 
                lyx_gui::parse_lyxrc();
-       }
 
        vector<string> files;
 
-       for (int argi = argc - 1; argi >= 1; --argi) {
+       for (int argi = argc - 1; argi >= 1; --argi) 
                files.push_back(argv[argi]);
-       }
 
        if (first_start)
                files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
@@ -145,14 +141,14 @@ LyX::LyX(int & argc, char * argv[])
                        // the filename if necessary
                        string s = FileSearch(string(), *it, "lyx");
                        if (s.empty()) {
-                               last_loaded = newFile(*it, "");
+                               last_loaded = newFile(*it, string(), true);
                        } else {
-                               last_loaded = bufferlist.newBuffer(s, false);
-                               last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
-                               if (!loadLyXFile(last_loaded, s)) {
-                                       bufferlist.release(last_loaded);
-                                       last_loaded = newFile(*it, string());
-                               }
+                               Buffer * buf = bufferlist.newBuffer(s, false);
+                               buf->error.connect(boost::bind(&LyX::printError, this, _1));
+                               if (loadLyXFile(buf, s)) 
+                                       last_loaded = buf;
+                               else
+                                       bufferlist.release(buf);
                        }
                }