Richard Heck wrote:
Abdelrazak Younes wrote:
Richard Heck wrote:
Idea for fix: Since the buffer_func.cpp version of loadLyXFile() is called from LyXView::loadLyXFile(), anyway, all the child doc stuff could be moved there. But I don't know this code terribly well. Abdel?
Very good analysis Richard! The solution is to use the LFUN instead of using loadLyXFile from buffer_funcs.cpp. This should fix the problem.
Do you mean to call LFUN_BUFFER_CHILD_OPEN from InsetInclude?

Yes, see just posted patch.

The problem with doing it that way, and a more general problem, actually---you'd get the same problem if you could somehow call LyXFunc::loadLyXFile() directly---is that this will reset the buffer.

Right, this is a minor inconvenience indeed.

I.e., focus will switch to the new buffer, which is not what we want for these automatic loads. I think that's basically why loadLyXFile() is being called directly: to skip all that stuff. But we end up skipping too much. But it still seems right to call the LyXView version one way or another.

I don't know what to do here. One option would be to add another flag to LyXView::loadLyXFile() and in BufferView::loadLyXFile(), something like "bool setFocus = true", and then we'd do something like this in the latter:
 if (setFocus)
   setBuffer(b);
and in the former:
     bool const loaded =
       work_area_->bufferView().loadLyXFile(filename, setFocus);
But then if we're calling this via an LFUN, we'll need a new LFUN to do it with, or else add a flag somehow to LFUN_BUFFER_CHILD_OPEN and make appropriate changes there. Is there a style for such flags? We can't use, say, "|" as a separator, because that could occur in a filename. So could anything else. So I'm not sure how to proceed there. So maybe a new LFUN, LFUN_BUFFER_CHILD_AUTO_OPEN (?) is needed.

Thoughts?

I don't like the idea of a new LFUN so what about switching back to the parent Buffer in loadIfNeeded() instead? The side effect is that you will see the child documents loaded one by one but at the end the focus will come back to the master document. What do you think?

Abdel.

Reply via email to