mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
fix bug 5833
* Buffer.{cpp, h}: - new method getChildren() that returns included (and sub-included) files * GuiView.cpp (closeEvent): - do not just close dirty child documents. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28712 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0bee8a3b56
commit
d7601a684b
@ -1765,6 +1765,25 @@ DocIterator Buffer::firstChildPosition(Buffer const * child)
|
||||
}
|
||||
|
||||
|
||||
std::vector<Buffer *> Buffer::getChildren() const
|
||||
{
|
||||
std::vector<Buffer *> clist;
|
||||
// loop over children
|
||||
Impl::BufferPositionMap::iterator it = d->children_positions.begin();
|
||||
Impl::BufferPositionMap::iterator end = d->children_positions.end();
|
||||
for (; it != end; ++it) {
|
||||
Buffer * child = const_cast<Buffer *>(it->first);
|
||||
clist.push_back(child);
|
||||
// there might be grandchildren
|
||||
std::vector<Buffer *> glist = child->getChildren();
|
||||
for (vector<Buffer *>::const_iterator git = glist.begin();
|
||||
git != glist.end(); ++git)
|
||||
clist.push_back(*git);
|
||||
}
|
||||
return clist;
|
||||
}
|
||||
|
||||
|
||||
template<typename M>
|
||||
typename M::iterator greatest_below(M & m, typename M::key_type const & x)
|
||||
{
|
||||
|
@ -282,6 +282,9 @@ public:
|
||||
|
||||
/// \return true if \p child is a child of this \c Buffer.
|
||||
bool isChild(Buffer * child) const;
|
||||
|
||||
/// return a vector with all children and grandchildren
|
||||
std::vector<Buffer *> getChildren() const;
|
||||
|
||||
/// Is buffer read-only?
|
||||
bool isReadonly() const;
|
||||
|
@ -533,17 +533,31 @@ void GuiView::closeEvent(QCloseEvent * close_event)
|
||||
while (GuiWorkArea * wa = currentMainWorkArea()) {
|
||||
Buffer * b = &wa->bufferView().buffer();
|
||||
if (b->parent()) {
|
||||
// This is a child document, just close the tab after saving
|
||||
// but keep the file loaded.
|
||||
if (!saveBuffer(*b)) {
|
||||
// This is a child document, just close the tab
|
||||
// after saving but keep the file loaded.
|
||||
if (!closeBuffer(*b, false)) {
|
||||
closing_ = false;
|
||||
close_event->ignore();
|
||||
return;
|
||||
}
|
||||
removeWorkArea(wa);
|
||||
continue;
|
||||
}
|
||||
|
||||
vector<Buffer *> clist = b->getChildren();
|
||||
for (vector<Buffer *>::const_iterator it = clist.begin();
|
||||
it != clist.end(); ++it) {
|
||||
if ((*it)->isClean())
|
||||
continue;
|
||||
Buffer * c = *it;
|
||||
// If a child is dirty, do not close
|
||||
// without user intervention
|
||||
if (!closeBuffer(*c, false)) {
|
||||
closing_ = false;
|
||||
close_event->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QList<int> const ids = guiApp->viewIds();
|
||||
for (int i = 0; i != ids.size(); ++i) {
|
||||
if (id_ == ids[i])
|
||||
|
Loading…
Reference in New Issue
Block a user