Le 30/12/2016 à 17:05, Jean-Marc Lasgouttes a écrit :
Le 29/12/2016 à 07:21, Guillaume Munch a écrit :
Le 27/12/2016 à 23:11, Scott Kostyshak a écrit :
On Tue, May 31, 2016 at 01:15:38AM +0200, Guillaume Munch wrote:
commit 1cc14a31ca8320d881b674f93c34a09cf1666cca
Author: Guillaume Munch <g...@lyx.org>
Date:   Mon May 30 21:42:08 2016 +0100

    TocWidget: fix an erroneous collapse and optimise updates based
on profiling

    TocModels::reset() in GuiView::structureChanged() collapses the
TocWidget, and
    therefore requires an update right after, which was missing.

    In fact, profiling TocWidget::updateView() shows that delaying
the update is
    good only for fast keypresses (essentially movement). It costs 5%
of a
    char-forward operation in a document with approx. 100 table of
contents
    items. The update optimisation has been rewritten to take this
data into
    account.

A git bisect suggests this causes a SIGSEGV. To reproduce:

1. open the attached file
2. open the outline pane
3. put the cursor just to the left of "Hello" (but inside the caption
inset)
4. "Save As" to a new filename.

Can you reproduce?

Backtrace is attached.


Hi,

The root of the issue is in Buffer::reload() called during "Save As".
After loadLyXFile() there, all the insets have been deleted, and
therefore the Inset pointer
GuiView::documentBufferView()->cursor().inset() is dangling. Immediately
after loadLyXFile(), reload() calls updateBuffer() from your backtrace
which then crashes.

In general this is when we add a cursor.fixIfBroken() somewhere.

Ok, I saw that DocIterator::sanitize and DocIterator::updateInsets both
fix the pointers, but I missed that fixIfBroken does that too, and
indeed there's a lot of calls to that. Why do we need three different
functions?


The attached patch fixes this crash, but I find very unsatisfactory to
have to update the cursors by hand like this.

What's with all the indirections? Updating directly one cursor seems
more straightforward.

The buffer has no direct access to these cursors, it has to communicate
with the view...


Reply via email to