- string format;
- string using_format = Converter::SplitFormat(format0, format);
-
- string backend_format = (format == "txt")
- ? format : BufferExtension(buffer);
- bool only_backend = backend_format == format;
+ // There are so many different places that this function can be called
+ // from that the removal of auto insets is best done here. This ensures
+ // we always have a clean buffer for inserting errors found during export.
+ BufferView * bv = buffer->getUser();
+ if (bv) {
+ // Remove all error insets
+ if (bv->removeAutoInsets()) {
+#warning repaint() or update() or nothing ?
+ bv->repaint();
+ bv->fitCursor();
+ }
+ }
+
+ string backend_format;
+ vector<string> backends = Backends(buffer);
+ if (find(backends.begin(), backends.end(), format) == backends.end()) {
+ for (vector<string>::const_iterator it = backends.begin();
+ it != backends.end(); ++it) {
+ Converters::EdgePath p =
+ converters.getPath(*it, format);
+ if (!p.empty()) {
+ lyxrc.pdf_mode = converters.usePdflatex(p);
+ backend_format = *it;
+ break;
+ }
+ }
+ if (backend_format.empty()) {
+ Alert::alert(_("Cannot export file"),
+ _("No information for exporting to ")
+ + formats.prettyName(format));
+ return false;
+ }
+ } else
+ backend_format = format;