* 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
This commit is contained in:
Abdelrazak Younes 2006-11-26 15:47:45 +00:00
parent 4bf43a35ac
commit 0ca269ef39
3 changed files with 25 additions and 3 deletions

View 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())

View 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;

View 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