From 0ca269ef3974269d7b7dd400aa2fe9f715646ff7 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 26 Nov 2006 15:47:45 +0000 Subject: [PATCH] * BufferList::last(): new method returning last loaded Buffer if any. * 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 | 8 ++++++++ src/bufferlist.h | 3 +++ src/lyx_main.C | 17 ++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/bufferlist.C b/src/bufferlist.C index fe6516fa4b..5dd594e8cd 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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()) diff --git a/src/bufferlist.h b/src/bufferlist.h index 93d1720686..4debd75e87 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -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; diff --git a/src/lyx_main.C b/src/lyx_main.C index ad50ee6b1c..4a4bd42c38 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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 -- 2.39.2