]> git.lyx.org Git - features.git/commitdiff
* BufferList::last(): new method returning last loaded Buffer if any.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 26 Nov 2006 15:47:45 +0000 (15:47 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 26 Nov 2006 15:47:45 +0000 (15:47 +0000)
* LyX::exec(): fix batch export in non GUI mode.

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

src/bufferlist.C
src/bufferlist.h
src/lyx_main.C

index fe6516fa4be836f54552ca53e9110a4d4d340f9b..5dd594e8cd8e40aa557b05e37009c86730466a8b 100644 (file)
@@ -235,6 +235,14 @@ Buffer * BufferList::first()
 }
 
 
+Buffer * BufferList::last()
+{
+       if (bstore.empty())
+               return 0;
+       return bstore.back();
+}
+
+
 Buffer * BufferList::getBuffer(unsigned int const choice)
 {
        if (choice >= bstore.size())
index 93d172068604fd7b1215cb0e0405b2e8602647eb..4debd75e87eccaaa945e5e134fbe19634a9f32ee 100644 (file)
@@ -61,6 +61,9 @@ public:
        /// return head of buffer list if any
        Buffer * first();
 
+       /// return back of buffer list if any
+       Buffer * last();
+
        /// returns true if the buffer exists already
        bool exists(std::string const &) const;
 
index ad50ee6b1ce06db542ebe26b961e393a021a4b24..4a4bd42c3845c5ef6d7b59daf607e9dc007f2c17 100644 (file)
@@ -332,10 +332,21 @@ int LyX::exec(int & argc, char * argv[])
        if (!use_gui) {
                // FIXME: create a ConsoleApplication
                int exit_status = loadFiles(argc, argv, files);
-               if (exit_status)
+               if (exit_status) {
+                       prepareExit();
                        return exit_status;
-               execBatchCommands();
-               return EXIT_SUCCESS;
+               }
+               Buffer * last_loaded = pimpl_->buffer_list_.last();
+               if (batch_command.empty() || !last_loaded) {
+                       prepareExit();
+                       return EXIT_SUCCESS;
+               }
+
+               // try to dispatch to last loaded buffer first
+               bool success = false;
+               last_loaded->dispatch(batch_command, &success);
+               prepareExit();
+               return !success;
        }
 
        // Force adding of font path _before_ Application is initialized