* 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
}
+Buffer * BufferList::last()
+{
+ if (bstore.empty())
+ return 0;
+ return bstore.back();
+}
+
+
Buffer * BufferList::getBuffer(unsigned int const choice)
{
if (choice >= bstore.size())
/// 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;
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