mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
Buffer methods for dealing with recursive includes.
This commit is contained in:
parent
aa794a8806
commit
9319144703
@ -297,6 +297,8 @@ public:
|
||||
///
|
||||
CloneList_ptr clone_list_;
|
||||
|
||||
///
|
||||
std::list<Buffer const *> include_list_;
|
||||
private:
|
||||
/// So we can force access via the accessors.
|
||||
mutable Buffer const * parent_buffer;
|
||||
@ -5591,4 +5593,55 @@ void Buffer::clearExternalModification() const
|
||||
}
|
||||
|
||||
|
||||
void Buffer::pushIncludedBuffer(Buffer const * buf) const
|
||||
{
|
||||
masterBuffer()->d->include_list_.push_back(buf);
|
||||
if (lyxerr.debugging(Debug::FILES)) {
|
||||
LYXERR0("Pushed. Stack now:");
|
||||
if (masterBuffer()->d->include_list_.empty())
|
||||
LYXERR0("EMPTY!");
|
||||
else
|
||||
for (auto const & b : masterBuffer()->d->include_list_)
|
||||
LYXERR0(b->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Buffer::popIncludedBuffer() const
|
||||
{
|
||||
masterBuffer()->d->include_list_.pop_back();
|
||||
if (lyxerr.debugging(Debug::FILES)) {
|
||||
LYXERR0("Popped. Stack now:");
|
||||
if (masterBuffer()->d->include_list_.empty())
|
||||
LYXERR0("EMPTY!");
|
||||
else
|
||||
for (auto const & b : masterBuffer()->d->include_list_)
|
||||
LYXERR0(b->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Buffer::isBufferIncluded(Buffer const * buf) const
|
||||
{
|
||||
if (!buf)
|
||||
return false;
|
||||
if (lyxerr.debugging(Debug::FILES)) {
|
||||
LYXERR0("Checking for " << buf->fileName() << ". Stack now:");
|
||||
if (masterBuffer()->d->include_list_.empty())
|
||||
LYXERR0("EMPTY!");
|
||||
else
|
||||
for (auto const & b : masterBuffer()->d->include_list_)
|
||||
LYXERR0(b->fileName());
|
||||
}
|
||||
list<Buffer const *> const & blist = masterBuffer()->d->include_list_;
|
||||
return find(blist.begin(), blist.end(), buf) != blist.end();
|
||||
}
|
||||
|
||||
|
||||
void Buffer::clearIncludeList() const
|
||||
{
|
||||
LYXERR(Debug::FILES, "Clearing include list for " << fileName());
|
||||
d->include_list_.clear();
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -783,6 +783,13 @@ public:
|
||||
///
|
||||
support::FileName getBibfilePath(docstring const & bibid) const;
|
||||
|
||||
/// routines for dealing with possible self-inclusion
|
||||
void pushIncludedBuffer(Buffer const * buf) const;
|
||||
void popIncludedBuffer() const;
|
||||
bool isBufferIncluded(Buffer const * buf) const;
|
||||
private:
|
||||
void clearIncludeList() const;
|
||||
|
||||
private:
|
||||
friend class MarkAsExporting;
|
||||
/// mark the buffer as busy exporting something, or not
|
||||
|
Loading…
Reference in New Issue
Block a user