Let /home/you/a.lyx be a master file that includes, by relative path, b.lyx, which of course lives then at /home/you/b.lyx. Say we open a.lyx; then b.lyx is opened, too, of course.

Now save a.lyx to /tmp/a.lyx. Then the InsetInclude in a.lyx still points to the buffer with b.lyx in it, even though it is now not at the right location. As a result, we get the crash in bug 6554: The inset thinks its file is loaded, but if you try to look it up by filename, you get nothing.

Possibly worse, the buffer with b.lyx in it still thinks that the buffer with a.lyx in it is its master buffer, which it kind of is but really isn't. I'd assume weird things can happen for this reason.

Finally, suppose the user makes some changes to both buffers, closes LyX, and re-opens. All of a sudden (from his point of view), the included file is gone.

It seems to me that all of this has to be handled when we Save As. I'd suggest that we check each InsetInclude. If it is referenced by a relative path, then we should offer to save it to a new relative path. If the user agrees, all is well. I think. If not, then (a) the associated Buffer's master should be set to 0 and (b) the InsetInclude should have its child_buffer_ pointer invalidated.

There are surely similar issues that can arise when when a child document is saved to a new location. In this case, its master should be cleared and we will need to invalidate the child_buffer_ pointer, again.

Seem right?

rh

Reply via email to