On 03/09/2010 08:04 AM, Abdelrazak Younes wrote:
On 03/09/2010 01:05 PM, rgheck wrote:
On 03/09/2010 03:38 AM, Abdelrazak Younes wrote:
On 03/08/2010 08:07 PM, [email protected] wrote:
Author: rgheck
Date: Mon Mar 8 20:07:05 2010
New Revision: 33679
URL: http://www.lyx.org/trac/changeset/33679
Log:
Introduce isBufferValid() method now, that returns true also for
cloned
Buffers. Use it, as well.
I don't understand the need for this. I mean, we shouldn't be
needing this method. If we need the buffer then the buffer must be
set, period. So I would just access buffer() and fixes upward the
cases where buffer_ is not properly set.
It's less the check for buffer_ than it is for the Buffer actually
being loaded. There are, or at least used to be, cases where a Buffer
got unloaded when some other file still had pointers to it. This
could happen now, I'd guess, if you opened a new file that included
the same child as an existing master. The parent gets reset. The old
master still has pointers to that child. Now close the new file and
its child.
Sure, the old master still has pointers to that child but those are
valid as long as the child is alive. The bug would be that the child
is allowed to be closed at the first place. When closing a file we
need to make sure that it is not the child of some other document than
its current master.
This is another way to handle the same problem. I think I was one of the
people who put this kind of test in a while ago, as one way to handle
it. I think this was before we had hidden buffers, etc, and children
routinely got closed independently. It seemed easier just to do the
check in loadIfNeeded()---i.e., to do the check when we needed to
know---rather than to try to find out if some document somewhere had a
pointer to a Buffer that was being closed. Now, it probably wouldn't be
that hard to do it right, since we do have access to the child position
info (though that is kind of a mess, too, as you've noted).
rh
rh