Fix crashes related to macros and instant preview

* Fix crash when zooming after latex failed to generate any output for previews.
  This was new in 2.1.4, so no status line is needed.

* Fix crash when copying macros with instant preview on.
This commit is contained in:
Enrico Forestieri 2015-06-25 21:04:42 +02:00
parent 93c0512ba2
commit 2a9f07336f
4 changed files with 17 additions and 1 deletions

View File

@ -709,6 +709,7 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
if (git == in_progress_.end()) { if (git == in_progress_.end()) {
lyxerr << "PreviewLoader::finishedGenerating(): unable to find " lyxerr << "PreviewLoader::finishedGenerating(): unable to find "
"data for PID " << pid << endl; "data for PID " << pid << endl;
finished_generating_ = true;
return; return;
} }
@ -717,8 +718,11 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
LYXERR(Debug::GRAPHICS, "PreviewLoader::finishedInProgress(" LYXERR(Debug::GRAPHICS, "PreviewLoader::finishedInProgress("
<< retval << "): processing " << status << retval << "): processing " << status
<< " for " << command); << " for " << command);
if (retval > 0) if (retval > 0) {
in_progress_.erase(git);
finished_generating_ = true;
return; return;
}
// Read the metrics file, if it exists // Read the metrics file, if it exists
vector<double> ascent_fractions(git->second.snippets.size()); vector<double> ascent_fractions(git->second.snippets.size());

View File

@ -69,6 +69,8 @@ public:
char const * MathMLtype() const; char const * MathMLtype() const;
/// ///
void setSymbol(latexkeys const * sym) { sym_ = sym; } void setSymbol(latexkeys const * sym) { sym_ = sym; }
///
DocIterator const & pos() { return pos_; }
/// lock while being drawn to avoid recursions /// lock while being drawn to avoid recursions
int lock() const { return ++lockCount_; } int lock() const { return ++lockCount_; }

View File

@ -176,6 +176,14 @@ void MathMacro::assign(MathMacro const & that)
if (p) if (p)
p->setOwner(this); p->setOwner(this);
} }
if (macro_ && lyxrc.preview == LyXRC::PREVIEW_ON) {
// We need to update macro_ by ourselves because in this case
// MathData::metrics() is not called when selecting a math inset
DocIterator const & pos = macroBackup_.pos();
macro_ = pos.buffer() ? pos.buffer()->getMacro(name(), pos) : 0;
if (!macro_)
macro_ = &macroBackup_;
}
} }

View File

@ -183,6 +183,8 @@ What's new
- Fix crash when copying macros with arguments (bug 9418). - Fix crash when copying macros with arguments (bug 9418).
- Fix crash when copying macros with instant preview on.
- Fix bad cursor font in some cases after changing layout (bug 4294). - Fix bad cursor font in some cases after changing layout (bug 4294).
- Fix name and hint of figure captions in documents using the class aastex. - Fix name and hint of figure captions in documents using the class aastex.