> > > So please commit and close bug 3511 with target 1.5.4.
> >
> > Done.
>
> Note that now LyX crashes on View->Source.
Ohmm, This is because view source does not catch this exception. How
about the attached patch? It is not a good idea to show the error
dialog here because the view source dialog will be updated frequently.
Please test.
Thanks.
Bo
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp (revision 22235)
+++ src/Buffer.cpp (working copy)
@@ -1799,34 +1799,39 @@
// No side effect of file copying and image conversion
runparams.dryrun = true;
- if (full_source) {
- os << "% " << _("Preview source code") << "\n\n";
- if (isLatex())
- writeLaTeXSource(os, filePath(), runparams, true, true);
- else {
- writeDocBookSource(os, fileName(), runparams, false);
- }
- } else {
- runparams.par_begin = par_begin;
- runparams.par_end = par_end;
- if (par_begin + 1 == par_end)
- os << "% "
- << bformat(_("Preview source code for paragraph %1$d"), par_begin)
- << "\n\n";
- else
- os << "% "
- << bformat(_("Preview source code from paragraph %1$s to %2$s"),
- convert<docstring>(par_begin),
- convert<docstring>(par_end - 1))
- << "\n\n";
- // output paragraphs
- if (isLatex()) {
- texrow().reset();
- latexParagraphs(*this, paragraphs(), os, texrow(), runparams);
+ try {
+ if (full_source) {
+ os << "% " << _("Preview source code") << "\n\n";
+ if (isLatex())
+ writeLaTeXSource(os, filePath(), runparams, true, true);
+ else {
+ writeDocBookSource(os, fileName(), runparams, false);
+ }
+
} else {
- // DocBook
- docbookParagraphs(paragraphs(), *this, os, runparams);
+ runparams.par_begin = par_begin;
+ runparams.par_end = par_end;
+ if (par_begin + 1 == par_end)
+ os << "% "
+ << bformat(_("Preview source code for paragraph %1$d"), par_begin)
+ << "\n\n";
+ else
+ os << "% "
+ << bformat(_("Preview source code from paragraph %1$s to %2$s"),
+ convert<docstring>(par_begin),
+ convert<docstring>(par_end - 1))
+ << "\n\n";
+ // output paragraphs
+ if (isLatex()) {
+ texrow().reset();
+ latexParagraphs(*this, paragraphs(), os, texrow(), runparams);
+ } else {
+ // DocBook
+ docbookParagraphs(paragraphs(), *this, os, runparams);
+ }
}
+ } catch (EncodingException & e) {
+ os << _("<Error: Unknown character '") << e.failed_char << "'>";
}
}