Jean-Marc Lasgouttes wrote:

> Georg> It works if the cursor is in a new empty paragraph. It tries to
> Georg> eat all available memory (and more) if the cursor is inside a
> Georg> section.
> 
> I cannot see that. Could you give directions?

I tried again and I see now that it does work with small documents. I tried
to insert
http://wiki.lyx.org/uploads/LyX/LyXMathebefehle/LyXMathebefehle.lyx into
itself (actually into the first section "Einleitung"), and that takes about
2GB of memory (estimated from xosview. 2 GB is more than I have in my box,
therefore I first thought of an endless loop). With my patch the memory
consumption is not visible in xosview.

> Georg> Unavailable layouts are parsed as errors and not converted as
> Georg> in cut and paste.
> 
> To what should they be converted? Could you give an example?

To standard. Look at pasteSelectionHelper() and SwitchBetweenClasses() in
CutAndPaste.C. I think that some of these things should also happen for
file->insert:

- layout changes
- adjustment of character styles (did not try that)
- document language

and maybe more. Insertion in ERT is disabled, so we don't need to care about
that.

> Georg> The only drawback I could find is that it inserts an additional
> Georg> paragraph if the inserted file contains more than one
> Georg> paragraph.
> 
> Here is for reference the patch I came up with when trying the
> cut-and-paste scheme. I gave up when I realized I would have to create
> a dummy BufferView to make it work.

What is wrong with a dummy BufferView? Or did you mean something else with
very bad hacks?

> I really do not think that your patch is acceptable for inclusion. It
> introduces very bad hacks, with little perspective of removing them
> later (the cursor code really needs to have a bufferview). I see you
> had to fix some random code to make it work, how do we know there is
> not a problem waiting somewhere else?

Of course I don't know. Concerning the fix in coordOffset I am not sure
whether it should not be included anyway, or can anybody guarantee that
getPos is always called with an iterator that is in the coordcache?
I believe that my patch triggers this because the new document has never
been drawn. Actually I don't understand why getPos is called at all.

> I really think the patch I sent is much cleaner. I would like to see
> if we can fix the issues you found.

It is probably possible to fix it, but the big problem that I see with your
patch is that you are ignoring the buffer parameters of the file and read
it as if it was a part of the document into which it gets inserted. I am
not sure if the patch is still as clean as it is now if these are not
ignored, but used and the necessary adjustments like in
pasteSelectionHelper() and SwitchBetweenClasses() are done.
The advantage of my patch is that it uses the existing cut and paste code
and that it will automatically benefit from future changes to that code.


Georg

Reply via email to