From: Abdelrazak Younes Date: Sun, 26 Nov 2006 16:39:39 +0000 (+0000) Subject: * BufferList: new begin() and end() methods. X-Git-Tag: 1.6.10~11743 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=0dae88fca68636c487a8ab4102778868cf18ad53;p=features.git * BufferList: new begin() and end() methods. * LyX::exec(): in non-GUI mode, execute batch commands on all buffers. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16068 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/bufferlist.C b/src/bufferlist.C index 5dd594e8cd..ed824f93c4 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -72,6 +72,30 @@ bool BufferList::empty() const } +BufferList::iterator BufferList::begin() +{ + return bstore.begin(); +} + + +BufferList::const_iterator BufferList::begin() const +{ + return bstore.begin(); +} + + +BufferList::iterator BufferList::end() +{ + return bstore.end(); +} + + +BufferList::const_iterator BufferList::end() const +{ + return bstore.end(); +} + + bool BufferList::quitWriteBuffer(Buffer * buf) { BOOST_ASSERT(buf); diff --git a/src/bufferlist.h b/src/bufferlist.h index 4debd75e87..161f95b7f5 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -28,9 +28,19 @@ class OutputParams; * and deletions of new ones. */ class BufferList : boost::noncopyable { +public: + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; + public: BufferList(); + iterator begin(); + const_iterator begin() const; + + iterator end(); + const_iterator end() const; + /// write all buffers, asking the user, returns false if cancelled bool quitWriteAll(); diff --git a/src/lyx_main.C b/src/lyx_main.C index 4a4bd42c38..90d98fd03d 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -336,17 +336,24 @@ int LyX::exec(int & argc, char * argv[]) prepareExit(); return exit_status; } - Buffer * last_loaded = pimpl_->buffer_list_.last(); - if (batch_command.empty() || !last_loaded) { + + if (batch_command.empty() || pimpl_->buffer_list_.empty()) { prepareExit(); return EXIT_SUCCESS; } - // try to dispatch to last loaded buffer first - bool success = false; - last_loaded->dispatch(batch_command, &success); + BufferList::iterator begin = pimpl_->buffer_list_.begin(); + BufferList::iterator end = pimpl_->buffer_list_.end(); + + bool final_success = false; + for (BufferList::iterator I = begin; I != end; ++I) { + Buffer * buf = *I; + bool success = false; + buf->dispatch(batch_command, &success); + final_success |= success; + } prepareExit(); - return !success; + return !final_success; } // Force adding of font path _before_ Application is initialized