From 2a9f07336fca1c228827b762cbf7dd56cb68f0c8 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Thu, 25 Jun 2015 21:04:42 +0200 Subject: [PATCH] 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. --- src/graphics/PreviewLoader.cpp | 6 +++++- src/mathed/MacroTable.h | 2 ++ src/mathed/MathMacro.cpp | 8 ++++++++ status.21x | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index eb25805c9c..e20f1ad86f 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -709,6 +709,7 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval) if (git == in_progress_.end()) { lyxerr << "PreviewLoader::finishedGenerating(): unable to find " "data for PID " << pid << endl; + finished_generating_ = true; return; } @@ -717,8 +718,11 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval) LYXERR(Debug::GRAPHICS, "PreviewLoader::finishedInProgress(" << retval << "): processing " << status << " for " << command); - if (retval > 0) + if (retval > 0) { + in_progress_.erase(git); + finished_generating_ = true; return; + } // Read the metrics file, if it exists vector ascent_fractions(git->second.snippets.size()); diff --git a/src/mathed/MacroTable.h b/src/mathed/MacroTable.h index 3bd04ea917..030e6f74ca 100644 --- a/src/mathed/MacroTable.h +++ b/src/mathed/MacroTable.h @@ -69,6 +69,8 @@ public: char const * MathMLtype() const; /// void setSymbol(latexkeys const * sym) { sym_ = sym; } + /// + DocIterator const & pos() { return pos_; } /// lock while being drawn to avoid recursions int lock() const { return ++lockCount_; } diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 06cfd5c38f..a25c5dbd62 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -176,6 +176,14 @@ void MathMacro::assign(MathMacro const & that) if (p) 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_ = ¯oBackup_; + } } diff --git a/status.21x b/status.21x index 7b1ed0de72..589b94c665 100644 --- a/status.21x +++ b/status.21x @@ -183,6 +183,8 @@ What's new - 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 name and hint of figure captions in documents using the class aastex.