On Tue, 19 Feb 2002, John Levon wrote:

> On Tue, Feb 19, 2002 at 01:26:25PM +1000, Allan Rae wrote:
>
> > What are you on about?  What rat's nest?  Which code?
> > [pause]
> > Maybe I see what you want to do now.
>
> You have to admit that pissing around with the cursor is not the most
> hygeinic of code. Especially as we need to do it /again/ somewhere in
> the insets (see bugzilla).

The trouble is how do we turn it off.  If we pass a parameter we have
to go through up to three or four functions.  Maybe as you suggested
we could add LyXText::{en,dis}ableDEPM() methods.  While this might be
okay for something like removeAutoInsets() where we are just looping
through the whole document I don't think this is really a valid
solution for the #243 problem or any other case where we set the
cursor to some random location in a file
(cursor_follows_scrollbar==true and scroll the scrollbar for example).

I've been thinking about splitting out the cursor tracking code in
rAI() to a separate helper class to make the code clearer but I'm not
sure it would be usable anywhere else -- unless that code also
iterates through the whole document.

As it is I've added a bool return value to most of the functionos I
could find that call dEPM() and it shouldn't be too hard to figure out
what needs to make use of that return value.

> > How do you intend to collapse
> > empty paragraphs?  Another run through the document with DEPM enabled?
>
> why can't it get collapsed on the next user action it makes sense to ? isn't
> this OK as long as we make sure export is still correct ?

But we can only really do that by iterating through the whole document
since we have just forgotten where the cursor used to be.  This would
be okay for rAI() but if we have to iterate through the entire doc
each time the user jumps around their document we'll be doing a lot of
iterating.  There should be a common code path for most of the user
jumps and a fairly simple fix there.  Hmm... maybe.  I tried #240 and
got a different crash to you. Valgrind didn't provide much insight:

==2167== Invalid read of size 4
==2167==    at 0x80C730E: Paragraph::getLayout(void) const
        (../../lyx-devel/src/paragraph.C:2122)
==2167==    by 0x80E9A86: LyXText::setCursor(BufferView *, Paragraph *, int, bool, 
bool) const
        (../../lyx-devel/src/text2.C:2101)
==2167==    by 0x813FDED: InsetText::edit(BufferView *, bool)
        (../../../lyx-devel/src/insets/insettext.C:706)
==2167==    by 0x8125EB0: InsetCollapsable::edit(BufferView *, int, int, unsigned int)
        (../../../lyx-devel/src/insets/insetcollapsable.C:255)
==2167==    by 0x8054FAD: BufferView::Pimpl::workAreaButtonPress(int, int, unsigned 
int)
        (../../lyx-devel/src/BufferView_pimpl.C:653)

(gdb) bt
[...]
#4  0x080e9a86 in LyXText::setCursor (this=0x23d16c8, bview=0x317ded8, par=0x30a8e24, 
pos=0,
    setfont=true, boundary=false) at ../../lyx-devel/src/text2.C:2101
#5  0x0813fded in InsetText::edit (this=0x30aa614, bv=0x317ded8, front=true)
    at ../../../lyx-devel/src/insets/insettext.C:706
#6  0x08125eb0 in InsetCollapsable::edit (this=0x30aa5b8, bv=0x317ded8, xp=36, yp=-2, 
button=3)
    at ../../../lyx-devel/src/insets/insetcollapsable.C:255
#7  0x08054fad in BufferView::Pimpl::workAreaButtonPress (this=0x317df1c, xpos=36, 
ypos=-2, button=3)
    at ../../lyx-devel/src/BufferView_pimpl.C:652


Other than a 30 second look at the code telling me this crash is due
to old_cursor being a dud and not due to dEPM() as such.  Possibly an
uninitialised cursor or at least an un-updated cursor for the LyXText
of the minipage.  I couldn't find anything obvious in a 5 minute
search.  Back to paid work now.

> > preamble) when the first line of a buffer only contained error boxes
>
> this is bug #194 right ?

Yes.

> There is also still bug #129, I think that's an update problem...
> (and maybe related to bug #243)

After J�rgen's fix to insettext that involved a static_cast<> that
should have been a 0.  And JMarc's recent fix to insettext that also
involved fixing a static_cast<> (which was casting to the wrong type)
which fixed some update problems I'd suggest an audit of all
static_cast<>s.  At least in the recent inset classes which would
include minipage and tabular amongst others.

Allan. (ARRae)


Reply via email to