/// has this user started lyx for the first time?
bool first_start;
/// the parsed command line batch command if any
- string batch_command;
+ vector<string> batch_commands;
};
///
// this is correct, since return values are inverted.
exit_status = !loadFiles();
- if (pimpl_->batch_command.empty() || pimpl_->buffer_list_.empty()) {
+ if (pimpl_->batch_commands.empty() || pimpl_->buffer_list_.empty()) {
prepareExit();
return exit_status;
}
if (buf != buf->masterBuffer())
continue;
bool success = false;
- buf->dispatch(pimpl_->batch_command, &success);
- final_success |= success;
+ vector<string>::const_iterator bcit = pimpl_->batch_commands.begin();
+ vector<string>::const_iterator bcend = pimpl_->batch_commands.end();
+ for (; bcit != bcend; bcit++) {
+ buf->dispatch(*bcit, &success);
+ final_success |= success;
+ }
}
prepareExit();
return !final_success;
// Let the frontend parse and remove all arguments that it knows
pimpl_->application_.reset(createApplication(argc, argv));
+ // Reestablish our defaults, as Qt overwrites them
+ // after createApplication()
+ locale_init();
+
// Parse and remove all known arguments in the LyX singleton
// Give an error for all remaining ones.
int exit_status = init(argc, argv);
// do any other cleanup procedures now
if (package().temp_dir() != package().system_temp_dir()) {
- LYXERR(Debug::INFO, "Deleting tmp dir "
- << package().temp_dir().absFilename());
-
- if (!package().temp_dir().destroyDirectory()) {
+ string const abs_tmpdir = package().temp_dir().absFilename();
+ if (!contains(package().temp_dir().absFilename(), "lyx_tmpdir")) {
docstring const msg =
- bformat(_("Unable to remove the temporary directory %1$s"),
- from_utf8(package().temp_dir().absFilename()));
- Alert::warning(_("Unable to remove temporary directory"), msg);
+ bformat(_("%1$s does not appear like a LyX created temporary directory."),
+ from_utf8(abs_tmpdir));
+ Alert::warning(_("Cannot remove temporary directory"), msg);
+ } else {
+ LYXERR(Debug::INFO, "Deleting tmp dir "
+ << package().temp_dir().absFilename());
+ if (!package().temp_dir().destroyDirectory()) {
+ docstring const msg =
+ bformat(_("Unable to remove the temporary directory %1$s"),
+ from_utf8(package().temp_dir().absFilename()));
+ Alert::warning(_("Unable to remove temporary directory"), msg);
+ }
}
}
}
-void LyX::addFileToLoad(string const & fname)
-{
- vector<string>::const_iterator cit = find(
- pimpl_->files_to_load_.begin(), pimpl_->files_to_load_.end(),
- fname);
-
- if (cit == pimpl_->files_to_load_.end())
- pimpl_->files_to_load_.push_back(fname);
-}
-
-
bool LyX::loadFiles()
{
LASSERT(!use_gui, /**/);
pimpl_->application_->restoreGuiSession();
// Execute batch commands if available
- if (pimpl_->batch_command.empty())
+ if (pimpl_->batch_commands.empty())
return;
- LYXERR(Debug::INIT, "About to handle -x '" << pimpl_->batch_command << '\'');
-
- pimpl_->lyxfunc_.dispatch(lyxaction.lookupFunc(pimpl_->batch_command));
+ vector<string>::const_iterator bcit = pimpl_->batch_commands.begin();
+ vector<string>::const_iterator bcend = pimpl_->batch_commands.end();
+ for (; bcit != bcend; bcit++) {
+ LYXERR(Debug::INIT, "About to handle -x '" << *bcit << '\'');
+ pimpl_->lyxfunc_.dispatch(lyxaction.lookupFunc(*bcit));
+ }
}
if (document_path.exists() && document_path.isDirectory())
package().document_dir() = document_path;
- package().temp_dir() = createLyXTmpDir(FileName(lyxrc.tempdir_path));
+ package().set_temp_dir(createLyXTmpDir(FileName(lyxrc.tempdir_path)));
if (package().temp_dir().empty()) {
Alert::error(_("Could not create temporary directory"),
bformat(_("Could not create a temporary directory in\n"
- "%1$s. Make sure that this\n"
- "path exists and is writable and try again."),
+ "\"%1$s\"\n"
+ "Make sure that this path exists and is writable and try again."),
from_utf8(lyxrc.tempdir_path)));
// createLyXTmpDir() tries sufficiently hard to create a
// usable temp dir, so the probability to come here is
namespace {
-string batch;
-
/// return the the number of arguments consumed
-typedef boost::function<int(string const &, string const &)> cmd_helper;
+typedef boost::function<int(string const &, string const &, string &)> cmd_helper;
-int parse_dbg(string const & arg, string const &)
+int parse_dbg(string const & arg, string const &, string &)
{
if (arg.empty()) {
lyxerr << to_utf8(_("List of supported debug flags:")) << endl;
}
-int parse_help(string const &, string const &)
+int parse_help(string const &, string const &, string &)
{
lyxerr <<
to_utf8(_("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
}
-int parse_version(string const &, string const &)
+int parse_version(string const &, string const &, string &)
{
lyxerr << "LyX " << lyx_version
<< " (" << lyx_release_date << ")" << endl;
}
-int parse_sysdir(string const & arg, string const &)
+int parse_sysdir(string const & arg, string const &, string &)
{
if (arg.empty()) {
Alert::error(_("No system directory"),
}
-int parse_userdir(string const & arg, string const &)
+int parse_userdir(string const & arg, string const &, string &)
{
if (arg.empty()) {
Alert::error(_("No user directory"),
}
-int parse_execute(string const & arg, string const &)
+int parse_execute(string const & arg, string const &, string & batch)
{
if (arg.empty()) {
Alert::error(_("Incomplete command"),
}
-int parse_export(string const & type, string const &)
+int parse_export(string const & type, string const &, string & batch)
{
if (type.empty()) {
lyxerr << to_utf8(_("Missing file type [eg latex, ps...] after "
}
-int parse_import(string const & type, string const & file)
+int parse_import(string const & type, string const & file, string & batch)
{
if (type.empty()) {
lyxerr << to_utf8(_("Missing file type [eg latex, ps...] after "
}
-int parse_geometry(string const & arg1, string const &)
+int parse_geometry(string const & arg1, string const &, string &)
{
geometryArg = arg1;
#if defined(_WIN32) || (defined(__CYGWIN__) && defined(X_DISPLAY_MISSING))
string const arg2 =
(i + 2 < argc) ? to_utf8(from_local8bit(argv[i + 2])) : string();
- int const remove = 1 + it->second(arg, arg2);
+ string batch;
+ int const remove = 1 + it->second(arg, arg2, batch);
+ if (!batch.empty())
+ pimpl_->batch_commands.push_back(batch);
// Now, remove used arguments by shifting
// the following ones remove places down.
--i;
}
}
-
- pimpl_->batch_command = batch;
}