}
+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)
{
/// \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;
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])