Re: Updating Buffer::embeddedFiles

2008-03-28 Thread rgheck
Abdelrazak Younes wrote: [snip, snip, snip] Just return early if there's nothing to do. i.e. no performance penalty. OK. I'm going to put this message in my special saved messages bit in case we end up needing this more global approach. rh

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread Abdelrazak Younes
rgheck wrote: Abdelrazak Younes wrote: Bo, Richard, This all business seems very complicated. May I suggest that you use the same technique as for labels and refs? I am talking about initView()/updateLabels()/addToToc(). Don't be mislead by the method names, those should be renamed to: * i

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread rgheck
Abdelrazak Younes wrote: Bo, Richard, This all business seems very complicated. May I suggest that you use the same technique as for labels and refs? I am talking about initView()/updateLabels()/addToToc(). Don't be mislead by the method names, those should be renamed to: * initView(): init

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread rgheck
Bo Peng wrote: I don't really understand this. The registered file will get its enabled status when it's constructed: EmbeddedFile::EmbeddedFile(std::string const & file, std::string const & inzipName, bool embed, Buffer const & buf) : DocFileName("", false), inzip_name_(inzipName)

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread Bo Peng
> I don't really understand this. The registered file will get its enabled > status when it's constructed: > EmbeddedFile::EmbeddedFile(std::string const & file, > std::string const & inzipName, bool embed, Buffer const & buf) > : DocFileName("", false), inzip_name_(inzipName), inset

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread Bo Peng
> > This is wrong. Because buffer_->embeddedFiles(), unless an update() is > > called, > > > updateBibfilesCache() calls EmbeddedFileList::enable(), which calls > update(). This is what the other question was about, really. > > +} > The vector tells us what files we have, and

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread rgheck
Bo Peng wrote: On Thu, Mar 27, 2008 at 9:47 PM, Bo Peng <[EMAIL PROTECTED]> wrote: I am reading your patch and hopefully can make it > work. void InsetBibtex::registerEmbeddedFiles(EmbeddedFileList & files) const { - if (bibfiles_.empty()) - createBibFi

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread Bo Peng
> OK, that's helpful by way of explanation. But here's where I was getting > the crash: You have an existing InsetBibtex, embedded, and then you > change the bibfiles. Now you try to save. Boom, because the newly chosen > bibfiles haven't been copied and, when the exception is thrown, LyX > tr

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread rgheck
Bo Peng wrote: I am reading your patch and hopefully can make it work. + // Make sure we are up to date. + buffer_->updateBibfilesCache(); + EmbeddedFileList & efl = buffer_->embeddedFiles(); + vector const files = getFiles(); +

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread rgheck
Bo Peng wrote: It seems to me that it would be a good idea, in general, if we were to do that after, say, InsetInclude's parameters were changed. I saw some crashes with InsetBibtex that were related to my not updating this structure. E.g., I changed the bibfiles and then tried to save, but t

Re: Updating Buffer::embeddedFiles

2008-03-28 Thread Abdelrazak Younes
Bo Peng wrote: On Thu, Mar 27, 2008 at 9:59 PM, Bo Peng <[EMAIL PROTECTED]> wrote: On Thu, Mar 27, 2008 at 9:47 PM, Bo Peng <[EMAIL PROTECTED]> wrote: > > I am reading your patch and hopefully can make it > > work. > +EmbeddedFile const * EmbeddedFileList::findFile(std::string const & fi

Re: Updating Buffer::embeddedFiles

2008-03-27 Thread Bo Peng
On Thu, Mar 27, 2008 at 9:59 PM, Bo Peng <[EMAIL PROTECTED]> wrote: > On Thu, Mar 27, 2008 at 9:47 PM, Bo Peng <[EMAIL PROTECTED]> wrote: > > > I am reading your patch and hopefully can make it > > > work. > > +EmbeddedFile const * EmbeddedFileList::findFile(std::string const & filename) con

Re: Updating Buffer::embeddedFiles

2008-03-27 Thread Bo Peng
On Thu, Mar 27, 2008 at 9:47 PM, Bo Peng <[EMAIL PROTECTED]> wrote: > > I am reading your patch and hopefully can make it > > work. > void InsetBibtex::registerEmbeddedFiles(EmbeddedFileList & files) const { - if (bibfiles_.empty()) - createBibFiles(params()["bibfiles"], pa

Re: Updating Buffer::embeddedFiles

2008-03-27 Thread Bo Peng
> I am reading your patch and hopefully can make it > work. + // Make sure we are up to date. + buffer_->updateBibfilesCache(); + EmbeddedFileList & efl = buffer_->embeddedFiles(); + vector const files = getFiles(); + vector::c

Re: Updating Buffer::embeddedFiles

2008-03-27 Thread Bo Peng
> It seems to me that it would be a good idea, in general, if we were to > do that after, say, InsetInclude's parameters were changed. I saw some > crashes with InsetBibtex that were related to my not updating this > structure. E.g., I changed the bibfiles and then tried to save, but they > ha

Updating Buffer::embeddedFiles

2008-03-27 Thread rgheck
Bo, It seems to me that it would be a good idea, in general, if we were to do that after, say, InsetInclude's parameters were changed. I saw some crashes with InsetBibtex that were related to my not updating this structure. E.g., I changed the bibfiles and then tried to save, but they hadn't