Do not compute metrics at each preview when loading file

With the branch-test.lyx file from #12297, loading takes forever when
previews are activated. This is because each preview element causes a
full screen metrics recomputation.

This commit just skips these calls and only does one when all previews
have been obtained. As a result, computing the previews takes 1 second
instead of 25 seconds on branch-test.lyx.

Part of bug #12297.

(cherry picked from commit 2449693301)
This commit is contained in:
Jean-Marc Lasgouttes 2023-12-21 16:33:06 +01:00
parent e5aaa64b63
commit 15eef6a2c7

View File

@ -787,6 +787,16 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
// Remove the item from the list of still-executing processes. // Remove the item from the list of still-executing processes.
in_progress_.erase(git); in_progress_.erase(git);
#if 0
/* FIXME : there is no need for all these calls, which recompute
* all metrics for each and every preview. The single call at the
* end of this method is sufficient.
* It seems that this whole imageReady mechanism is actually not
* needed. If it is the case, the whole updateFrontend/updateInset
* bloat can go too.
*/
// Tell the outside world // Tell the outside world
list<PreviewImagePtr>::const_reverse_iterator list<PreviewImagePtr>::const_reverse_iterator
nit = newimages.rbegin(); nit = newimages.rbegin();
@ -795,6 +805,8 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
for (; nit != nend; ++nit) { for (; nit != nend; ++nit) {
imageReady(*nit->get()); imageReady(*nit->get());
} }
#endif
finished_generating_ = true; finished_generating_ = true;
buffer_.scheduleRedrawWorkAreas(); buffer_.scheduleRedrawWorkAreas();
} }