From cd046f0e0cdea5aae064284790e4e17f0c60bd03 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 23 Jun 2015 02:39:48 +0200 Subject: [PATCH] Avoid an exception when the lyxpreview2bitmap.py script fails completely If latex fails to generate any output, the forked process was not removed. Now, if a snippet was changed a new one was started but, if also the zoom was changed, things went awry because the 2 concurrent processes were asked to process again the same snippet. Previously this would have simply caused a waste of resources because the changed snippet would have not been regenerated. Also reset the guard due to the early exit. --- src/graphics/PreviewLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index c3055dc61e..f38c157e7e 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -746,6 +746,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; } @@ -754,8 +755,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());