This patch does not compile... but it shows some stuff I worked on
some year ago...

Is it a worthy goal?

? Config
? buffer-1.diff
? work-1.diff
Index: boost/boost/shared_ptr.hpp
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/boost/boost/shared_ptr.hpp,v
retrieving revision 1.7
diff -u -p -r1.7 shared_ptr.hpp
--- boost/boost/shared_ptr.hpp	5 Feb 2004 09:14:14 -0000	1.7
+++ boost/boost/shared_ptr.hpp	22 Jul 2004 22:58:04 -0000
@@ -254,7 +254,7 @@ public:
         BOOST_ASSERT(px != 0);
         return px;
     }
-    
+
     T * get() const // never throws
     {
         return px;
@@ -271,13 +271,13 @@ public:
 
 #elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
     typedef T * (this_type::*unspecified_bool_type)() const;
-    
+
     operator unspecified_bool_type() const // never throws
     {
         return px == 0? 0: &this_type::get;
     }
 
-#else 
+#else
 
     typedef T * this_type::*unspecified_bool_type;
 
@@ -433,7 +433,7 @@ using std::basic_ostream;
 template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y> const & p)
 # else
 template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p)
-# endif 
+# endif
 {
     os << p.get();
     return os;
@@ -467,7 +467,7 @@ template<class D, class T> D * get_delet
 
 #ifdef BOOST_MSVC
 # pragma warning(pop)
-#endif    
+#endif
 
 #endif  // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
 
Index: boost/boost/weak_ptr.hpp
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/boost/boost/weak_ptr.hpp,v
retrieving revision 1.3
diff -u -p -r1.3 weak_ptr.hpp
--- boost/boost/weak_ptr.hpp	3 Mar 2003 15:53:40 -0000	1.3
+++ boost/boost/weak_ptr.hpp	22 Jul 2004 22:58:04 -0000
@@ -188,6 +188,6 @@ template<class T> shared_ptr<T> make_sha
 
 #ifdef BOOST_MSVC
 # pragma warning(pop)
-#endif    
+#endif
 
 #endif  // #ifndef BOOST_WEAK_PTR_HPP_INCLUDED
Index: po/POTFILES.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/po/POTFILES.in,v
retrieving revision 1.391
diff -u -p -r1.391 POTFILES.in
--- po/POTFILES.in	26 May 2004 20:26:09 -0000	1.391
+++ po/POTFILES.in	22 Jul 2004 22:58:04 -0000
@@ -10,6 +10,7 @@ src/buffer.C
 src/buffer_funcs.C
 src/bufferlist.C
 src/bufferparams.C
+src/bufferview_funcs.C
 src/converter.C
 src/debug.C
 src/exporter.C
@@ -25,6 +26,7 @@ src/frontends/controllers/ControlLog.C
 src/frontends/controllers/ControlPrefs.C
 src/frontends/controllers/ControlPrint.C
 src/frontends/controllers/ControlSpellchecker.C
+src/frontends/controllers/ControlThesaurus.C
 src/frontends/controllers/biblio.C
 src/frontends/controllers/character.C
 src/frontends/controllers/frnt_lang.C
Index: src/BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.251
diff -u -p -r1.251 BufferView.C
--- src/BufferView.C	28 Apr 2004 17:22:00 -0000	1.251
+++ src/BufferView.C	22 Jul 2004 22:58:04 -0000
@@ -82,9 +82,9 @@ void BufferView::unsetXSel()
 }
 
 
-Buffer * BufferView::buffer() const
+boost::shared_ptr<Buffer> BufferView::buffer() const
 {
-	return pimpl_->buffer_;
+	return pimpl_->buffer_.lock();
 }
 
 
@@ -106,9 +106,9 @@ Painter & BufferView::painter() const
 }
 
 
-void BufferView::setBuffer(Buffer * b)
+void BufferView::buffer(boost::shared_ptr<Buffer> b)
 {
-	pimpl_->setBuffer(b);
+	pimpl_->buffer(b);
 }
 
 
@@ -134,7 +134,7 @@ void BufferView::reload()
 
 void BufferView::resize()
 {
-	if (pimpl_->buffer_)
+	if (!pimpl_->buffer_.expired())
 		pimpl_->resizeCurrentBuffer();
 }
 
Index: src/BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.176
diff -u -p -r1.176 BufferView.h
--- src/BufferView.h	28 Apr 2004 17:22:01 -0000	1.176
+++ src/BufferView.h	22 Jul 2004 22:58:04 -0000
@@ -19,6 +19,8 @@
 
 #include <boost/utility.hpp>
 
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
 #include <string>
 
 class Buffer;
@@ -59,9 +61,9 @@ public:
 	~BufferView();
 
 	/// set the buffer we are viewing
-	void setBuffer(Buffer * b);
+	void buffer(boost::shared_ptr<Buffer> b);
 	/// return the buffer being viewed
-	Buffer * buffer() const;
+	boost::shared_ptr<Buffer> buffer() const;
 
 	/// return the painter object for drawing onto the view
 	Painter & painter() const;
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.548
diff -u -p -r1.548 BufferView_pimpl.C
--- src/BufferView_pimpl.C	5 Jul 2004 14:34:50 -0000	1.548
+++ src/BufferView_pimpl.C	22 Jul 2004 22:58:04 -0000
@@ -83,6 +83,8 @@ using lyx::support::MakeDisplayPath;
 using lyx::support::strToUnsignedInt;
 using lyx::support::system_lyxdir;
 
+using boost::shared_ptr;
+
 using std::endl;
 using std::istringstream;
 using std::make_pair;
@@ -116,7 +118,7 @@ boost::signals::connection lostcon;
 
 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
 			 int width, int height)
-	: bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
+	: bv_(&bv), owner_(owner), cursor_timeout(400),
 	  using_xterm_cursor(false), cursor_(bv)
 {
 	xsel_cache_.set = false;
@@ -186,10 +188,6 @@ void BufferView::Pimpl::connectBuffer(Bu
 	readonlyConnection_ =
 		buf.readonly.connect(
 			boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
-
-	closingConnection_ =
-		buf.closing.connect(
-			boost::bind(&BufferView::Pimpl::setBuffer, this, (Buffer *)0));
 }
 
 
@@ -208,7 +206,7 @@ void BufferView::Pimpl::disconnectBuffer
 void BufferView::Pimpl::newFile(string const & filename, string const & tname,
 	bool isNamed)
 {
-	setBuffer(::newFile(filename, tname, isNamed));
+	buffer(::newFile(filename, tname, isNamed));
 }
 
 
@@ -233,7 +231,7 @@ bool BufferView::Pimpl::loadLyXFile(stri
 			text, 0, 1,  _("&Revert"), _("&Switch to document"));
 
 		if (ret != 0) {
-			setBuffer(bufferlist.getBuffer(s));
+			buffer(bufferlist.getBuffer(s));
 			return true;
 		}
 		// FIXME: should be LFUN_REVERT
@@ -242,7 +240,7 @@ bool BufferView::Pimpl::loadLyXFile(stri
 		// Fall through to new load. (Asger)
 	}
 
-	Buffer * b;
+	shared_ptr<Buffer> b;
 
 	if (found) {
 		b = bufferlist.newBuffer(s);
@@ -264,7 +262,7 @@ bool BufferView::Pimpl::loadLyXFile(stri
 			return false;
 	}
 
-	setBuffer(b);
+	buffer(b);
 	bv_->showErrorList(_("Parse"));
 
 	if (tolastfiles)
@@ -304,11 +302,11 @@ int BufferView::Pimpl::top_y() const
 }
 
 
-void BufferView::Pimpl::setBuffer(Buffer * b)
+void BufferView::Pimpl::buffer(shared_ptr<Buffer> b)
 {
 	lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
 			    << b << ')' << endl;
-	if (buffer_)
+	if (buffer_.lock())
 		disconnectBuffer();
 
 	// set current buffer
@@ -322,13 +320,13 @@ void BufferView::Pimpl::setBuffer(Buffer
 	if (quitting)
 		return;
 
-	if (buffer_) {
-		lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
-		connectBuffer(*buffer_);
+	if (buffer_.lock()) {
+		lyxerr[Debug::INFO] << "Buffer addr: " << buffer_.lock().get() << endl;
+		connectBuffer(*buffer_.lock());
 
-		cursor_.push(buffer_->inset());
+		cursor_.push(buffer_.lock()->inset());
 		cursor_.resetAnchor();
-		buffer_->text().init(bv_);
+		buffer_.lock()->text().init(bv_);
 
 		// If we don't have a text object for this, we make one
 		//if (bv_->text() == 0)
@@ -353,12 +351,12 @@ void BufferView::Pimpl::setBuffer(Buffer
 	owner_->updateWindowTitle();
 
 	// This is done after the layout combox has been populated
-	if (buffer_)
+	if (!buffer_.expired())
 		owner_->setLayout(cursor_.paragraph().layout()->name());
-		
 
-	if (buffer_ && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
-		lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
+
+	if (!buffer_.expired() && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
+		lyx::graphics::Previews::get().generateBufferPreviews(*buffer_.lock());
 }
 
 
@@ -380,7 +378,7 @@ bool BufferView::Pimpl::fitCursor()
 void BufferView::Pimpl::redoCurrentBuffer()
 {
 	lyxerr[Debug::DEBUG] << "BufferView::redoCurrentBuffer" << endl;
-	if (buffer_ && bv_->text()) {
+	if (buffer_.lock() && bv_->text()) {
 		resizeCurrentBuffer();
 		updateScrollbar();
 		owner_->updateLayoutChoice();
@@ -435,7 +433,7 @@ void BufferView::Pimpl::scrollDocView(in
 {
 	lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
 
-	if (!buffer_)
+	if (buffer_.expired())
 		return;
 
 	screen().hideCursor();
@@ -465,7 +463,7 @@ void BufferView::Pimpl::scrollDocView(in
 
 void BufferView::Pimpl::scroll(int lines)
 {
-	if (!buffer_)
+	if (buffer_.expired())
 		return;
 
 	LyXText const * t = bv_->text();
@@ -554,7 +552,7 @@ void BufferView::Pimpl::workAreaResize()
 	work_area_width = workarea().workWidth();
 	work_area_height = workarea().workHeight();
 
-	if (buffer_ && widthChange) {
+	if (!buffer_.expired() && widthChange) {
 		// The visible LyXView need a resize
 		resizeCurrentBuffer();
 	}
@@ -574,13 +572,13 @@ void BufferView::Pimpl::update()
 	// fix cursor coordinate cache in case something went wrong
 
 	// check needed to survive LyX startup
-	if (buffer_) {
+	if (!buffer_.expired()) {
 		// update macro store
-		buffer_->buildMacros();
+		buffer_.lock()->buildMacros();
 
 		// update all 'visible' paragraphs
 		lyx::par_type beg, end;
-		getParsInRange(buffer_->paragraphs(),
+		getParsInRange(buffer_.lock()->paragraphs(),
 			       top_y(), top_y() + workarea().workHeight(),
 			       beg, end);
 		bv_->text()->redoParagraphs(beg, end);
@@ -596,7 +594,7 @@ void BufferView::Pimpl::update()
 // Callback for cursor timer
 void BufferView::Pimpl::cursorToggle()
 {
-	if (buffer_) {
+	if (!buffer_.expired()) {
 		screen().toggleCursor(*bv_);
 
 		// Use this opportunity to deal with any child processes that
@@ -613,7 +611,7 @@ void BufferView::Pimpl::cursorToggle()
 
 bool BufferView::Pimpl::available() const
 {
-	return buffer_ && bv_->text();
+	return !buffer_.expired() && bv_->text();
 }
 
 
@@ -638,7 +636,7 @@ void BufferView::Pimpl::savePosition(uns
 	if (i >= saved_positions_num)
 		return;
 	BOOST_ASSERT(bv_->cursor().inTexted());
-	saved_positions[i] = Position(buffer_->fileName(),
+	saved_positions[i] = Position(buffer_.lock()->fileName(),
 				      bv_->cursor().paragraph().id(),
 				      bv_->cursor().pos());
 	if (i > 0)
@@ -655,8 +653,8 @@ void BufferView::Pimpl::restorePosition(
 
 	bv_->cursor().clearSelection();
 
-	if (fname != buffer_->fileName()) {
-		Buffer * b = 0;
+	if (fname != buffer_.lock()->fileName()) {
+		shared_ptr<Buffer> b;
 		if (bufferlist.exists(fname))
 			b = bufferlist.getBuffer(fname);
 		else {
@@ -664,11 +662,11 @@ void BufferView::Pimpl::restorePosition(
 			::loadLyXFile(b, fname); // don't ask, just load it
 		}
 		if (b)
-			setBuffer(b);
+			buffer(b);
 	}
 
-	ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
-	if (par == buffer_->par_iterator_end())
+	ParIterator par = buffer_.lock()->getParFromID(saved_positions[i].par_id);
+	if (par == buffer_.lock()->par_iterator_end())
 		return;
 
 	bv_->text()->setCursor(bv_->cursor(), par.pit(),
@@ -804,7 +802,7 @@ void BufferView::Pimpl::MenuInsertLyXFil
 
 void BufferView::Pimpl::trackChanges()
 {
-	Buffer * buf = bv_->buffer();
+	shared_ptr<Buffer> buf = bv_->buffer();
 	bool const tracking = buf->params().tracking_changes;
 
 	if (!tracking) {
@@ -918,7 +916,7 @@ bool BufferView::Pimpl::workAreaDispatch
 
 FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
 {
-	Buffer * buf = bv_->buffer();
+	shared_ptr<Buffer> buf = bv_->buffer();
 
 	FuncStatus flag;
 
Index: src/BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.123
diff -u -p -r1.123 BufferView_pimpl.h
--- src/BufferView_pimpl.h	28 Apr 2004 17:22:02 -0000	1.123
+++ src/BufferView_pimpl.h	22 Jul 2004 22:58:04 -0000
@@ -30,7 +30,7 @@
 #include "support/types.h"
 
 #include <boost/scoped_ptr.hpp>
-#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
 #include <boost/signals/trackable.hpp>
 
 
@@ -52,7 +52,7 @@ struct BufferView::Pimpl : public boost:
 	/// return the screen for this bview
 	LyXScreen & screen() const;
 	///
-	void setBuffer(Buffer * buf);
+	void buffer(boost::shared_ptr<Buffer>);
 	/// Return true if the cursor was fitted.
 	bool fitCursor();
 	///
@@ -146,7 +146,7 @@ private:
 	///
 	LyXView * owner_;
 	///
-	Buffer * buffer_;
+	boost::weak_ptr<Buffer> buffer_;
 	///
 	boost::scoped_ptr<LyXScreen> screen_;
 	///
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.578
diff -u -p -r1.578 buffer.C
--- src/buffer.C	1 Jul 2004 14:40:59 -0000	1.578
+++ src/buffer.C	22 Jul 2004 22:58:05 -0000
@@ -115,6 +115,8 @@ using lyx::support::trim;
 
 namespace os = lyx::support::os;
 
+using boost::shared_ptr;
+
 using std::endl;
 using std::for_each;
 using std::make_pair;
@@ -1078,7 +1080,7 @@ void Buffer::makeDocBookFile(string cons
 			    << "\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\"";;
 		else
 			ofs << " PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\"";
-		
+
 		string preamble = params().preamble;
 		string const name = runparams.nice ? ChangeExtension(pimpl_->filename, ".sgml")
 			 : fname;
@@ -1495,7 +1497,7 @@ Buffer const * Buffer::getMasterBuffer()
 {
 	if (!params().parentname.empty()
 	    && bufferlist.exists(params().parentname)) {
-		Buffer const * buf = bufferlist.getBuffer(params().parentname);
+		shared_ptr<Buffer const> buf = bufferlist.getBuffer(params().parentname);
 		if (buf)
 			return buf->getMasterBuffer();
 	}
Index: src/buffer_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.C,v
retrieving revision 1.19
diff -u -p -r1.19 buffer_funcs.C
--- src/buffer_funcs.C	26 Mar 2004 17:49:08 -0000	1.19
+++ src/buffer_funcs.C	22 Jul 2004 22:58:05 -0000
@@ -40,14 +40,15 @@ using lyx::support::OnlyFilename;
 using lyx::support::OnlyPath;
 using lyx::support::unlink;
 
-using std::string;
+using boost::shared_ptr;
 
+using std::string;
 
 extern BufferList bufferlist;
 
 namespace {
 
-bool readFile(Buffer * b, string const & s)
+bool readFile(shared_ptr<Buffer> b, string const & s)
 {
 	// File information about normal file
 	FileInfo fileN(s);
@@ -120,7 +121,7 @@ bool readFile(Buffer * b, string const &
 
 
 
-bool loadLyXFile(Buffer * b, string const & s)
+bool loadLyXFile(shared_ptr<Buffer> b, string const & s)
 {
 	switch (IsFileWriteable(s)) {
 	case 0:
@@ -155,11 +156,12 @@ bool loadLyXFile(Buffer * b, string cons
 }
 
 
-Buffer * newFile(string const & filename, string const & templatename,
+shared_ptr<Buffer> newFile(string const & filename,
+			   string const & templatename,
 		 bool isNamed)
 {
 	// get a free buffer
-	Buffer * b = bufferlist.newBuffer(filename);
+	shared_ptr<Buffer> b = bufferlist.newBuffer(filename);
 
 	string tname;
 	// use defaults.lyx as a default template if it exists.
Index: src/buffer_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.h,v
retrieving revision 1.8
diff -u -p -r1.8 buffer_funcs.h
--- src/buffer_funcs.h	6 Oct 2003 15:42:06 -0000	1.8
+++ src/buffer_funcs.h	22 Jul 2004 22:58:05 -0000
@@ -12,8 +12,9 @@
 #ifndef BUFFER_FUNCS_H
 #define BUFFER_FUNCS_H
 
-#include <string>
+#include <boost/shared_ptr.hpp>
 
+#include <string>
 
 class Buffer;
 class TeXErrors;
@@ -23,13 +24,15 @@ class ErrorList;
  *  Loads a LyX file \c filename into \c Buffer
  *  and \return success status.
  */
-bool loadLyXFile(Buffer *, std::string const & filename);
+bool loadLyXFile(boost::shared_ptr<Buffer>, std::string const & filename);
+
 
 /* Make a new file (buffer) with name \c filename based on a template
  * named \c templatename
  */
-Buffer * newFile(std::string const & filename, std::string const & templatename,
-		 bool isNamed = false);
+boost::shared_ptr<Buffer> newFile(std::string const & filename,
+				  std::string const & templatename,
+				  bool isNamed = false);
 
 ///return the format of the buffer on a string
 std::string const BufferFormat(Buffer const & buffer);
Index: src/bufferlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v
retrieving revision 1.141
diff -u -p -r1.141 bufferlist.C
--- src/bufferlist.C	25 Mar 2004 09:16:15 -0000	1.141
+++ src/bufferlist.C	22 Jul 2004 22:58:05 -0000
@@ -50,6 +50,7 @@ using std::for_each;
 using std::string;
 using std::vector;
 
+using boost::shared_ptr;
 
 BufferList::BufferList()
 {}
@@ -61,7 +62,7 @@ bool BufferList::empty() const
 }
 
 
-bool BufferList::quitWriteBuffer(Buffer * buf)
+bool BufferList::quitWriteBuffer(shared_ptr<Buffer> buf)
 {
 	string file;
 	if (buf->isUnnamed())
@@ -81,9 +82,9 @@ bool BufferList::quitWriteBuffer(Buffer 
 		bool succeeded;
 
 		if (buf->isUnnamed())
-			succeeded = WriteAs(buf);
+			succeeded = WriteAs(buf.get());
 		else
-			succeeded = MenuWrite(buf);
+			succeeded = MenuWrite(buf.get());
 
 		if (!succeeded)
 			return false;
@@ -118,26 +119,24 @@ bool BufferList::quitWriteAll()
 }
 
 
-void BufferList::release(Buffer * buf)
+void BufferList::release(shared_ptr<Buffer> buf)
 {
 	BOOST_ASSERT(buf);
 	BufferStorage::iterator it = find(bstore.begin(), bstore.end(), buf);
 	if (it != bstore.end()) {
-		Buffer * tmp = (*it);
 		bstore.erase(it);
-		delete tmp;
 	}
 }
 
 
-Buffer * BufferList::newBuffer(string const & s, bool ronly)
+shared_ptr<Buffer> BufferList::newBuffer(string const & s, bool ronly)
 {
-	auto_ptr<Buffer> tmpbuf(new Buffer(s, ronly));
+	shared_ptr<Buffer> tmpbuf(new Buffer(s, ronly));
 	tmpbuf->params().useClassDefaults();
 	lyxerr[Debug::INFO] << "Assigning to buffer "
 			    << bstore.size() << endl;
-	bstore.push_back(tmpbuf.get());
-	return tmpbuf.release();
+	bstore.push_back(tmpbuf);
+	return tmpbuf;
 }
 
 
@@ -149,7 +148,7 @@ void BufferList::closeAll()
 }
 
 
-bool BufferList::close(Buffer * buf, bool ask)
+bool BufferList::close(shared_ptr<Buffer> buf, bool ask)
 {
 	BOOST_ASSERT(buf);
 
@@ -172,7 +171,7 @@ bool BufferList::close(Buffer * buf, boo
 
 	if (ret == 0) {
 		if (buf->isUnnamed()) {
-			if (!WriteAs(buf))
+			if (!WriteAs(buf.get()))
 				return false;
 		} else if (buf->save()) {
 			LyX::ref().lastfiles().newFile(buf->fileName());
@@ -195,24 +194,32 @@ bool BufferList::close(Buffer * buf, boo
 vector<string> const BufferList::getFileNames() const
 {
 	vector<string> nvec;
+#if 0
 	std::copy(bstore.begin(), bstore.end(),
 		  lyx::back_inserter_fun(nvec, &Buffer::fileName));
+#else
+	BufferStorage::const_iterator cit = bstore.begin();
+	BufferStorage::const_iterator end = bstore.end();
+	for (; cit != end; ++cit) {
+		nvec.push_back((*cit)->fileName());
+	}
+#endif
 	return nvec;
 }
 
 
-Buffer * BufferList::first()
+shared_ptr<Buffer> BufferList::first()
 {
 	if (bstore.empty())
-		return 0;
+		return shared_ptr<Buffer>();
 	return bstore.front();
 }
 
 
-Buffer * BufferList::getBuffer(unsigned int choice)
+shared_ptr<Buffer> BufferList::getBuffer(unsigned int choice)
 {
 	if (choice >= bstore.size())
-		return 0;
+		return shared_ptr<Buffer>();
 	return bstore[choice];
 }
 
@@ -242,7 +249,7 @@ void BufferList::emergencyWriteAll()
 }
 
 
-void BufferList::emergencyWrite(Buffer * buf)
+void BufferList::emergencyWrite(shared_ptr<Buffer> buf)
 {
 	// assert(buf) // this is not good since C assert takes an int
 		       // and a pointer is a long (JMarc)
@@ -302,13 +309,23 @@ void BufferList::emergencyWrite(Buffer *
 
 bool BufferList::exists(string const & s) const
 {
+#if 0
 	return find_if(bstore.begin(), bstore.end(),
 		       lyx::compare_memfun(&Buffer::fileName, s))
 		!= bstore.end();
+#else
+	BufferStorage::const_iterator cit = bstore.begin();
+	BufferStorage::const_iterator end = bstore.end();
+	for (; cit != end; ++cit) {
+		if ((*cit)->fileName() == s)
+			return true;
+	}
+	return false;
+#endif
 }
 
 
-bool BufferList::isLoaded(Buffer const * b) const
+bool BufferList::isLoaded(shared_ptr<Buffer> b) const
 {
 	BOOST_ASSERT(b);
 	BufferStorage::const_iterator cit =
@@ -317,23 +334,32 @@ bool BufferList::isLoaded(Buffer const *
 }
 
 
-Buffer * BufferList::getBuffer(string const & s)
+shared_ptr<Buffer> BufferList::getBuffer(string const & s)
 {
+#if 0
 	BufferStorage::iterator it =
 		find_if(bstore.begin(), bstore.end(),
 			lyx::compare_memfun(&Buffer::fileName, s));
-	return it != bstore.end() ? (*it) : 0;
+#else
+	BufferStorage::iterator it = bstore.begin();
+	BufferStorage::iterator end = bstore.end();
+	for (; it != end; ++it) {
+		if ((*it)->fileName() == s)
+			break;
+	}
+#endif
+	return it != bstore.end() ? (*it) : shared_ptr<Buffer>();
 }
 
 
-Buffer * BufferList::getBufferFromTmp(string const & s)
+shared_ptr<Buffer> BufferList::getBufferFromTmp(string const & s)
 {
 	BufferStorage::iterator it = bstore.begin();
 	BufferStorage::iterator end = bstore.end();
 	for (; it < end; ++it)
 		if (prefixIs(s, (*it)->temppath()))
 			return *it;
-	return 0;
+	return shared_ptr<Buffer>();
 }
 
 
Index: src/bufferlist.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.h,v
retrieving revision 1.47
diff -u -p -r1.47 bufferlist.h
--- src/bufferlist.h	5 Nov 2003 12:06:03 -0000	1.47
+++ src/bufferlist.h	22 Jul 2004 22:58:05 -0000
@@ -13,6 +13,7 @@
 #define BUFFER_LIST_H
 
 #include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
 
 #include <string>
 #include <vector>
@@ -32,10 +33,10 @@ public:
 	bool quitWriteAll();
 
 	/// create a new buffer
-	Buffer * newBuffer(std::string const & s, bool ronly = false);
+	boost::shared_ptr<Buffer> newBuffer(std::string const & s, bool ronly = false);
 
 	/// delete a buffer
-	void release(Buffer * b);
+	void release(boost::shared_ptr<Buffer> b);
 
 	/// Close all open buffers.
 	void closeAll();
@@ -50,41 +51,41 @@ public:
 	void emergencyWriteAll();
 
 	/// close buffer. Returns false if cancelled by user
-	bool close(Buffer * buf, bool ask);
+	bool close(boost::shared_ptr<Buffer> buf, bool ask);
 
 	/// return true if no buffers loaded
 	bool empty() const;
 
 	/// return head of buffer list if any
-	Buffer * first();
+	boost::shared_ptr<Buffer> first();
 
 	/// returns true if the buffer exists already
 	bool exists(std::string const &) const;
 
 	/// returns true if the buffer is loaded
-	bool isLoaded(Buffer const * b) const;
+	bool isLoaded(boost::shared_ptr<Buffer> b) const;
 
 	/// returns a pointer to the buffer with the given name.
-	Buffer * getBuffer(std::string const &);
+	boost::shared_ptr<Buffer> getBuffer(std::string const &);
 	/// returns a pointer to the buffer with the given number.
-	Buffer * getBuffer(unsigned int);
+	boost::shared_ptr<Buffer> getBuffer(unsigned int);
 	/// returns a pointer to the buffer whose temppath matches the string
-	Buffer * BufferList::getBufferFromTmp(std::string const &);
+	boost::shared_ptr<Buffer> getBufferFromTmp(std::string const &);
 
 	/// reset current author for all buffers
 	void setCurrentAuthor(std::string const & name, std::string const & email);
 
 private:
 	/// ask to save a buffer on quit, returns false if should cancel
-	bool quitWriteBuffer(Buffer * buf);
+	bool quitWriteBuffer(boost::shared_ptr<Buffer> buf);
 
-	typedef std::vector<Buffer *> BufferStorage;
+	typedef std::vector<boost::shared_ptr<Buffer> > BufferStorage;
 
 	/// storage of all buffers
 	BufferStorage bstore;
 
 	/// save emergency file for the given buffer
-	void emergencyWrite(Buffer * buf);
+	void emergencyWrite(boost::shared_ptr<Buffer> buf);
 };
 
 #endif // BUFFERLIST_H
Index: src/bufferview_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v
retrieving revision 1.141
diff -u -p -r1.141 bufferview_funcs.C
--- src/bufferview_funcs.C	28 Mar 2004 22:00:21 -0000	1.141
+++ src/bufferview_funcs.C	22 Jul 2004 22:58:05 -0000
@@ -39,6 +39,8 @@
 
 using lyx::support::bformat;
 
+using boost::shared_ptr;
+
 using std::istringstream;
 using std::ostringstream;
 using std::string;
Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.186
diff -u -p -r1.186 lyx_main.C
--- src/lyx_main.C	13 Apr 2004 13:10:33 -0000	1.186
+++ src/lyx_main.C	22 Jul 2004 22:58:05 -0000
@@ -76,6 +76,8 @@ using lyx::support::user_lyxdir;
 using lyx::support::os::getTmpDir;
 using lyx::support::os::setTmpDir;
 
+using boost::shared_ptr;
+
 using std::endl;
 using std::string;
 using std::vector;
@@ -223,7 +225,7 @@ void LyX::priv_exec(int & argc, char * a
 		lyxerr[Debug::INIT] << "About to handle -x '"
 		       << batch_command << '\'' << endl;
 
-		Buffer * last_loaded = 0;
+		shared_ptr<Buffer> last_loaded;
 
 		vector<string>::const_iterator it = files.begin();
 		vector<string>::const_iterator end = files.end();
@@ -235,7 +237,7 @@ void LyX::priv_exec(int & argc, char * a
 			if (s.empty()) {
 				last_loaded = newFile(*it, string(), true);
 			} else {
-				Buffer * buf = bufferlist.newBuffer(s, false);
+				shared_ptr<Buffer> buf = bufferlist.newBuffer(s, false);
 				buf->error.connect(boost::bind(&LyX::printError, this, _1));
 				if (loadLyXFile(buf, s))
 					last_loaded = buf;
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.621
diff -u -p -r1.621 lyxfunc.C
--- src/lyxfunc.C	2 Jul 2004 10:03:22 -0000	1.621
+++ src/lyxfunc.C	22 Jul 2004 22:58:05 -0000
@@ -122,14 +122,16 @@ using lyx::support::user_lyxdir;
 using lyx::support::prefixIs;
 using lyx::support::os::getTmpDir;
 
+namespace biblio = lyx::biblio;
+
+using boost::shared_ptr;
+
 using std::endl;
 using std::make_pair;
 using std::pair;
 using std::string;
 using std::istringstream;
 
-namespace biblio = lyx::biblio;
-
 
 extern BufferList bufferlist;
 extern LyXServer * lyxserver;
@@ -271,7 +273,7 @@ FuncStatus LyXFunc::getStatus(FuncReques
 {
 	//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
 	FuncStatus flag;
-	Buffer * buf = owner->buffer();
+	shared_ptr<Buffer> buf = owner->buffer();
 	LCursor & cur = view()->cursor();
 
 	if (cmd.action == LFUN_NOACTION) {
@@ -299,7 +301,7 @@ FuncStatus LyXFunc::getStatus(FuncReques
 
 	// the default error message if we disable the command
 	setStatusMessage(N_("Command disabled"));
-	if (!flag.enabled()) 
+	if (!flag.enabled())
 		return flag;
 
 	// Check whether we need a buffer
@@ -686,14 +688,14 @@ void LyXFunc::dispatch(FuncRequest const
 				string const str = bformat(_("Saving document %1$s..."),
 					 MakeDisplayPath(owner->buffer()->fileName()));
 				owner->message(str);
-				MenuWrite(owner->buffer());
+				MenuWrite(owner->buffer().get());
 				owner->message(str + _(" done."));
 			} else
-				WriteAs(owner->buffer());
+				WriteAs(owner->buffer().get());
 			break;
 
 		case LFUN_WRITEAS:
-			WriteAs(owner->buffer(), argument);
+			WriteAs(owner->buffer().get(), argument);
 			break;
 
 		case LFUN_MENURELOAD: {
@@ -709,17 +711,17 @@ void LyXFunc::dispatch(FuncRequest const
 		}
 
 		case LFUN_UPDATE:
-			Exporter::Export(owner->buffer(), argument, true);
+			Exporter::Export(owner->buffer().get(), argument, true);
 			view()->showErrorList(BufferFormat(*owner->buffer()));
 			break;
 
 		case LFUN_PREVIEW:
-			Exporter::Preview(owner->buffer(), argument);
+			Exporter::Preview(owner->buffer().get(), argument);
 			view()->showErrorList(BufferFormat(*owner->buffer()));
 			break;
 
 		case LFUN_BUILDPROG:
-			Exporter::Export(owner->buffer(), "program", true);
+			Exporter::Export(owner->buffer().get(), "program", true);
 			view()->showErrorList(_("Build"));
 			break;
 
@@ -732,7 +734,7 @@ void LyXFunc::dispatch(FuncRequest const
 			if (argument == "custom")
 				owner->getDialogs().show("sendto");
 			else {
-				Exporter::Export(owner->buffer(), argument, false);
+				Exporter::Export(owner->buffer().get(), argument, false);
 				view()->showErrorList(BufferFormat(*owner->buffer()));
 			}
 			break;
@@ -748,7 +750,7 @@ void LyXFunc::dispatch(FuncRequest const
 				break;
 			}
 
-			Buffer * buffer = owner->buffer();
+			shared_ptr<Buffer> buffer = owner->buffer();
 
 			// The name of the file created by the conversion process
 			string filename;
@@ -765,7 +767,7 @@ void LyXFunc::dispatch(FuncRequest const
 					break;
 
 			} else {
-				Exporter::Export(buffer, format_name, true,
+				Exporter::Export(buffer.get(), format_name, true,
 						 filename);
 			}
 
@@ -799,9 +801,9 @@ void LyXFunc::dispatch(FuncRequest const
 				break;
 			}
 
-			Buffer * buffer = owner->buffer();
+			shared_ptr<Buffer> buffer = owner->buffer();
 
-			if (!Exporter::Export(buffer, "dvi", true)) {
+			if (!Exporter::Export(buffer.get(), "dvi", true)) {
 				showPrintError(buffer->fileName());
 				break;
 			}
@@ -954,7 +956,7 @@ void LyXFunc::dispatch(FuncRequest const
 
 		// --- buffers ----------------------------------------
 		case LFUN_SWITCHBUFFER:
-			view()->setBuffer(bufferlist.getBuffer(argument));
+			view()->buffer(bufferlist.getBuffer(argument));
 			break;
 
 		case LFUN_FILE_NEW:
@@ -994,14 +996,14 @@ void LyXFunc::dispatch(FuncRequest const
 			if (prefixIs(file_name, getTmpDir())) {
 				// Needed by inverse dvi search. If it is a file
 				// in tmpdir, call the apropriated function
-				view()->setBuffer(bufferlist.getBufferFromTmp(file_name));
+				view()->buffer(bufferlist.getBufferFromTmp(file_name));
 			} else {
 				// Must replace extension of the file to be .lyx
 				// and get full path
 				string const s = ChangeExtension(file_name, ".lyx");
 				// Either change buffer or load the file
 				if (bufferlist.exists(s)) {
-					view()->setBuffer(bufferlist.getBuffer(s));
+					view()->buffer(bufferlist.getBuffer(s));
 				} else {
 					view()->loadLyXFile(s);
 				}
@@ -1159,7 +1161,7 @@ void LyXFunc::dispatch(FuncRequest const
 			view()->savePosition(0);
 			string const parentfilename = owner->buffer()->fileName();
 			if (bufferlist.exists(filename))
-				view()->setBuffer(bufferlist.getBuffer(filename));
+				view()->buffer(bufferlist.getBuffer(filename));
 			else
 				view()->loadLyXFile(filename);
 			// Set the parent name of the child document.
@@ -1348,7 +1350,7 @@ void LyXFunc::dispatch(FuncRequest const
 		}
 
 		case LFUN_TEXTCLASS_APPLY: {
-			Buffer * buffer = owner->buffer();
+			shared_ptr<Buffer> buffer = owner->buffer();
 
 			lyx::textclass_type const old_class =
 				buffer->params().textclass;
@@ -1692,7 +1694,7 @@ void LyXFunc::closeBuffer()
 			// since there's no current buffer
 			owner->getDialogs().hideBufferDependent();
 		} else {
-			view()->setBuffer(bufferlist.first());
+			view()->buffer(bufferlist.first());
 		}
 	}
 }
Index: src/rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.127
diff -u -p -r1.127 rowpainter.C
--- src/rowpainter.C	20 Apr 2004 08:51:10 -0000	1.127
+++ src/rowpainter.C	22 Jul 2004 22:58:06 -0000
@@ -42,6 +42,8 @@
 using lyx::pos_type;
 using lyx::par_type;
 
+using boost::shared_ptr;
+
 using std::endl;
 using std::max;
 using std::string;
Index: src/tabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tabular.C,v
retrieving revision 1.207
diff -u -p -r1.207 tabular.C
--- src/tabular.C	25 Mar 2004 09:16:21 -0000	1.207
+++ src/tabular.C	22 Jul 2004 22:58:06 -0000
@@ -1365,7 +1365,7 @@ LyXTabular::cellstruct & LyXTabular::cel
 }
 
 
-void LyXTabular::setMultiColumn(Buffer * buffer, int cell, int number)
+void LyXTabular::setMultiColumn(Buffer const & buffer, int cell, int number)
 {
 	cellstruct & cs = cellinfo_of_cell(cell);
 	cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
@@ -2283,9 +2283,9 @@ int LyXTabular::docbook(Buffer const & b
 		++ret;
 	}
 
-	//+---------------------------------------------------------------------
-	//+                      the single row and columns (cells)            +
-	//+---------------------------------------------------------------------
+	//+--------------------------------------------------------------------
+	//+                     the single row and columns (cells)            +
+	//+--------------------------------------------------------------------
 
 	os << "<tbody>\n";
 	++ret;
@@ -2296,9 +2296,9 @@ int LyXTabular::docbook(Buffer const & b
 	}
 	os << "</tbody>\n";
 	++ret;
-	//+---------------------------------------------------------------------
-	//+                      the closing of the tabular                    +
-	//+---------------------------------------------------------------------
+	//+--------------------------------------------------------------------
+	//+                     the closing of the tabular                    +
+	//+--------------------------------------------------------------------
 
 	os << "</tgroup>";
 	++ret;
Index: src/tabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tabular.h,v
retrieving revision 1.89
diff -u -p -r1.89 tabular.h
--- src/tabular.h	25 Mar 2004 09:16:23 -0000	1.89
+++ src/tabular.h	22 Jul 2004 22:58:06 -0000
@@ -292,7 +292,7 @@ public:
 	///
 	bool isMultiColumnReal(int cell) const;
 	///
-	void setMultiColumn(Buffer *, int cell, int number);
+	void setMultiColumn(Buffer const &, int cell, int number);
 	///
 	int unsetMultiColumn(int cell); // returns number of new cells
 	///
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.575
diff -u -p -r1.575 text2.C
--- src/text2.C	2 Jul 2004 10:11:14 -0000	1.575
+++ src/text2.C	22 Jul 2004 22:58:07 -0000
@@ -64,7 +64,13 @@ using lyx::par_type;
 using lyx::pos_type;
 using lyx::support::bformat;
 
+using boost::shared_ptr;
+
+using std::vector;
+using std::copy;
 using std::endl;
+using std::find;
+using std::pair;
 using std::ostringstream;
 using std::string;
 
Index: src/undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.54
diff -u -p -r1.54 undo.C
--- src/undo.C	18 Apr 2004 19:41:40 -0000	1.54
+++ src/undo.C	22 Jul 2004 22:58:07 -0000
@@ -27,10 +27,11 @@
 
 #include <algorithm>
 
-using std::advance;
-
 using lyx::par_type;
 
+using boost::shared_ptr;
+
+using std::advance;
 using std::endl;
 
 
@@ -209,7 +210,7 @@ bool textRedo(BufferView & bv)
 void recordUndo(Undo::undo_kind kind,
 	LCursor & cur, par_type first, par_type last)
 {
-	Buffer * buf = cur.bv().buffer();
+	shared_ptr<Buffer> buf = cur.bv().buffer();
 	recordUndo(kind, cur, first, last, buf->undostack());
 	buf->redostack().clear();
 	lyxerr << "undostack:\n";
Index: src/frontends/LyXView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v
retrieving revision 1.47
diff -u -p -r1.47 LyXView.C
--- src/frontends/LyXView.C	19 May 2004 15:11:30 -0000	1.47
+++ src/frontends/LyXView.C	22 Jul 2004 22:58:07 -0000
@@ -86,7 +86,7 @@ void LyXView::init()
 }
 
 
-Buffer * LyXView::buffer() const
+boost::shared_ptr<Buffer> LyXView::buffer() const
 {
 	return bufferview_->buffer();
 }
@@ -199,7 +199,7 @@ Buffer const * const LyXView::updateInse
 {
 	Buffer const * buffer_ptr = 0;
 	if (inset) {
-		buffer_ptr = bufferview_->buffer();
+		buffer_ptr = bufferview_->buffer().get();
 		bufferview_->update();
 	}
 	return buffer_ptr;
Index: src/frontends/LyXView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.h,v
retrieving revision 1.31
diff -u -p -r1.31 LyXView.h
--- src/frontends/LyXView.h	19 May 2004 15:11:30 -0000	1.31
+++ src/frontends/LyXView.h	22 Jul 2004 22:58:07 -0000
@@ -77,7 +77,7 @@ public:
 	boost::shared_ptr<BufferView> const & view() const;
 
 	/// return the buffer currently shown in this window
-	Buffer * buffer() const;
+	boost::shared_ptr<Buffer> buffer() const;
 
 	/// return the LyX function handler for this view
 	LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
Index: src/frontends/controllers/ControlChanges.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlChanges.C,v
retrieving revision 1.17
diff -u -p -r1.17 ControlChanges.C
--- src/frontends/controllers/ControlChanges.C	19 May 2004 15:11:30 -0000	1.17
+++ src/frontends/controllers/ControlChanges.C	22 Jul 2004 22:58:07 -0000
@@ -37,7 +37,7 @@ ControlChanges::ControlChanges(Dialog & 
 
 bool ControlChanges::find()
 {
-	return find::findNextChange(kernel().bufferview());
+	return find::findNextChange(kernel().bufferview().get());
 }
 
 
@@ -75,14 +75,14 @@ string const ControlChanges::getChangeAu
 void ControlChanges::accept()
 {
 	kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
-	find::findNextChange(kernel().bufferview());
+	find::findNextChange(kernel().bufferview().get());
 }
 
 
 void ControlChanges::reject()
 {
 	kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE));
-	find::findNextChange(kernel().bufferview());
+	find::findNextChange(kernel().bufferview().get());
 }
 
 } // namespace frontend
Index: src/frontends/controllers/ControlRef.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlRef.C,v
retrieving revision 1.31
diff -u -p -r1.31 ControlRef.C
--- src/frontends/controllers/ControlRef.C	19 May 2004 15:11:30 -0000	1.31
+++ src/frontends/controllers/ControlRef.C	22 Jul 2004 22:58:07 -0000
@@ -18,9 +18,10 @@
 
 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
 
+using boost::shared_ptr;
+
 using std::vector;
 using std::string;
-
 
 extern BufferList bufferlist;
 
Index: src/frontends/controllers/Kernel.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Kernel.C,v
retrieving revision 1.11
diff -u -p -r1.11 Kernel.C
--- src/frontends/controllers/Kernel.C	19 May 2004 15:11:31 -0000	1.11
+++ src/frontends/controllers/Kernel.C	22 Jul 2004 22:58:07 -0000
@@ -82,21 +82,9 @@ Kernel::DocTypes Kernel::docType() const
 }
 
 
-void Kernel::redrawGUI() const
+boost::shared_ptr<BufferView> Kernel::bufferview() const
 {
-	lyxview_.getDialogs().redrawGUI();
-}
-
-
-BufferView * Kernel::bufferview()
-{
-	return lyxview_.view().get();
-}
-
-
-BufferView const * Kernel::bufferview() const
-{
-	return lyxview_.view().get();
+	return lyxview_.view();
 }
 
 
Index: src/frontends/controllers/Kernel.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Kernel.h,v
retrieving revision 1.12
diff -u -p -r1.12 Kernel.h
--- src/frontends/controllers/Kernel.h	19 May 2004 15:11:31 -0000	1.12
+++ src/frontends/controllers/Kernel.h	22 Jul 2004 22:58:07 -0000
@@ -12,6 +12,8 @@
 #ifndef KERNEL_H
 #define KERNEL_H
 
+#include <boost/shared_ptr.hpp>
+
 #include <string>
 
 class Buffer;
@@ -95,8 +97,7 @@ public:
 	Buffer & buffer();
 	Buffer const & buffer() const;
 
-	BufferView * bufferview();
-	BufferView const * bufferview() const;
+	boost::shared_ptr<BufferView> bufferview() const;
 	//@}
 
 private:
Index: src/insets/insetcite.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcite.C,v
retrieving revision 1.84
diff -u -p -r1.84 insetcite.C
--- src/insets/insetcite.C	19 May 2004 15:11:37 -0000	1.84
+++ src/insets/insetcite.C	22 Jul 2004 22:58:07 -0000
@@ -334,9 +334,9 @@ int InsetCitation::latex(Buffer const & 
 	biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
 	string const cite_str =
 		biblio::asValidLatexCommand(getCmdName(), cite_engine);
-	
+
 	os << "\\" << cite_str;
-	
+
 	string const before = getSecOptions();
 	string const after  = getOptions();
 	if (!before.empty() && cite_engine != biblio::ENGINE_BASIC)
Index: src/insets/insetinclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v
retrieving revision 1.193
diff -u -p -r1.193 insetinclude.C
--- src/insets/insetinclude.C	1 Jun 2004 13:39:33 -0000	1.193
+++ src/insets/insetinclude.C	22 Jul 2004 22:58:07 -0000
@@ -51,6 +51,8 @@
 #include "support/std_ostream.h"
 #include "support/std_sstream.h"
 
+using boost::shared_ptr;
+
 using lyx::support::AddName;
 using lyx::support::AbsolutePath;
 using lyx::support::bformat;
@@ -294,7 +296,7 @@ bool loadIfNeeded(Buffer const & buffer,
 	if (!IsLyXFilename(included_file))
 		return false;
 
-	Buffer * buf = bufferlist.getBuffer(included_file);
+	shared_ptr<Buffer> buf = bufferlist.getBuffer(included_file);
 	if (!buf) {
 		// the readonly flag can/will be wrong, not anymore I think.
 		FileInfo finfo(included_file);
@@ -306,7 +308,7 @@ bool loadIfNeeded(Buffer const & buffer,
 	}
 	if (buf)
 		buf->setParentName(parentFilename(buffer));
-	return buf != 0;
+	return !!buf;
 }
 
 
@@ -345,7 +347,7 @@ int InsetInclude::latex(Buffer const & b
 	lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
 
 	if (loadIfNeeded(buffer, params_)) {
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+		shared_ptr<Buffer> tmp = bufferlist.getBuffer(included_file);
 
 		if (tmp->params().textclass != m_buffer->params().textclass) {
 			string text = bformat(_("Included file `%1$s'\n"
@@ -442,7 +444,7 @@ int InsetInclude::linuxdoc(Buffer const 
 	string writefile = ChangeExtension(included_file, ".sgml");
 
 	if (loadIfNeeded(buffer, params_)) {
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+		shared_ptr<Buffer> tmp = bufferlist.getBuffer(included_file);
 
 		writefile = MakeAbsPath(FileName(writefile).mangledFilename(),
 		                        buffer.getMasterBuffer()->temppath());
@@ -486,7 +488,7 @@ int InsetInclude::docbook(Buffer const &
 	string writefile = ChangeExtension(included_file, ".sgml");
 
 	if (loadIfNeeded(buffer, params_)) {
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+		shared_ptr<Buffer> tmp = bufferlist.getBuffer(included_file);
 
 		string const mangled = FileName(writefile).mangledFilename();
 		writefile = MakeAbsPath(mangled,
@@ -547,7 +549,7 @@ void InsetInclude::validate(LaTeXFeature
 	// to be loaded:
 	if (loadIfNeeded(buffer, params_)) {
 		// a file got loaded
-		Buffer * const tmp = bufferlist.getBuffer(included_file);
+		shared_ptr<Buffer> const tmp = bufferlist.getBuffer(included_file);
 		if (tmp) {
 			// We must temporarily change features.buffer,
 			// otherwise it would always be the master buffer,
@@ -565,7 +567,7 @@ void InsetInclude::getLabelList(Buffer c
 {
 	if (loadIfNeeded(buffer, params_)) {
 		string const included_file = includedFilename(buffer, params_);
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+		shared_ptr<Buffer> tmp = bufferlist.getBuffer(included_file);
 		tmp->setParentName("");
 		tmp->getLabelList(list);
 		tmp->setParentName(parentFilename(buffer));
@@ -578,7 +580,7 @@ void InsetInclude::fillWithBibKeys(Buffe
 {
 	if (loadIfNeeded(buffer, params_)) {
 		string const included_file = includedFilename(buffer, params_);
-		Buffer * tmp = bufferlist.getBuffer(included_file);
+		shared_ptr<Buffer> tmp = bufferlist.getBuffer(included_file);
 		tmp->setParentName("");
 		tmp->fillWithBibKeys(keys);
 		tmp->setParentName(parentFilename(buffer));
Index: src/insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.593
diff -u -p -r1.593 insettext.C
--- src/insets/insettext.C	29 Apr 2004 09:54:59 -0000	1.593
+++ src/insets/insettext.C	22 Jul 2004 22:58:07 -0000
@@ -118,6 +118,7 @@ void InsetText::clear(bool just_mark_era
 {
 	ParagraphList & pars = paragraphs();
 	if (just_mark_erased) {
+#warning iter
 		ParagraphList::iterator it = pars.begin();
 		ParagraphList::iterator end = pars.end();
 		for (; it != end; ++it)
@@ -493,7 +494,7 @@ LyXText * InsetText::getText(int i) cons
 }
 
 
-void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
+void InsetText::appendParagraphs(Buffer const & buffer, ParagraphList & plist)
 {
 #ifdef WITH_WARNINGS
 #warning FIXME Check if Changes stuff needs changing here. (Lgb)
@@ -503,7 +504,7 @@ void InsetText::appendParagraphs(Buffer 
 	ParagraphList::iterator pit = plist.begin();
 	ParagraphList::iterator ins = paragraphs().insert(paragraphs().end(), *pit);
 	++pit;
-	mergeParagraph(buffer->params(), paragraphs(),
+	mergeParagraph(buffer.params(), paragraphs(),
 		ins - paragraphs().begin() - 1);
 
 	ParagraphList::iterator pend = plist.end();
Index: src/insets/insettext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v
retrieving revision 1.259
diff -u -p -r1.259 insettext.h
--- src/insets/insettext.h	13 Apr 2004 12:47:47 -0000	1.259
+++ src/insets/insettext.h	22 Jul 2004 22:58:07 -0000
@@ -130,7 +130,7 @@ public:
 	void markNew(bool track_changes = false);
 
 	/// append text onto the existing text
-	void appendParagraphs(Buffer * bp, ParagraphList &);
+	void appendParagraphs(Buffer const & bp, ParagraphList &);
 
 	///
 	void addPreview(lyx::graphics::PreviewLoader &) const;
Index: src/mathed/math_extern.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_extern.C,v
retrieving revision 1.66
diff -u -p -r1.66 math_extern.C
--- src/mathed/math_extern.C	30 Jan 2004 11:41:10 -0000	1.66
+++ src/mathed/math_extern.C	22 Jul 2004 22:58:07 -0000
@@ -1095,8 +1095,8 @@ namespace {
 			expr.insert(pos, 1, '*');
 		}
 
-		string full = "latex(" +  extra + '(' + expr + "));";
-		string out = captureOutput("maple -q", header + full + trailer);
+		string const full = "latex(" +  extra + '(' + expr + "));";
+		string const out = captureOutput("maple -q", header + full + trailer);
 
 		// change \_ into _
 
@@ -1115,8 +1115,8 @@ namespace {
 		string expr = os.str();
 		string out;
 
-		lyxerr << "pipe: ar: '" << ar << "'\n"
-		       << "pipe: expr: '" << expr << "'" << endl;
+		lyxerr << "pipe: ar: '" << ar << "'" << endl;
+		lyxerr << "pipe: expr: '" << expr << "'" << endl;
 
 		for (int i = 0; i < 100; ++i) { // at most 100 attempts
 			//
Index: src/mathed/math_xyarrowinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xyarrowinset.C,v
retrieving revision 1.18
diff -u -p -r1.18 math_xyarrowinset.C
--- src/mathed/math_xyarrowinset.C	5 Sep 2003 14:09:58 -0000	1.18
+++ src/mathed/math_xyarrowinset.C	22 Jul 2004 22:58:07 -0000
@@ -57,8 +57,13 @@ MathArray const & MathXYArrowInset::targ
 	//lyxerr << "target: x: " << x << " y: " << y << endl;
 	MathInset::idx_type n = mi_.idx + p->ncols() * y + x;
 	if (n >= p->nargs()) {
+<<<<<<< math_xyarrowinset.C
+		lyxerr << "source: n: " << mi_.idx << endl;
+		lyxerr << "target: n: " << n << " out of range" << endl;
+=======
 		lyxerr << "source: n: " << mi_.idx << "\n"
 		       << "target: n: " << n << " out of range" << endl;
+>>>>>>> 1.16
 		n = 0;
 	}
   return p->cell(n);
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.185
diff -u -p -r1.185 filetools.C
--- src/support/filetools.C	29 Jun 2004 12:55:09 -0000	1.185
+++ src/support/filetools.C	22 Jul 2004 22:58:08 -0000
@@ -335,7 +335,7 @@ i18nLibFileSearch(string const & dir, st
 	string l;
 	lang = split(lang, l, ':');
 	while (!l.empty() && l != "C" && l != "POSIX") {
-		string const tmp = LibFileSearch(dir, 
+		string const tmp = LibFileSearch(dir,
 						 token(l, '_', 0) + '_' + name,
 						 ext);
 		if (!tmp.empty())
Index: src/tex2lyx/math.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/math.C,v
retrieving revision 1.14
diff -u -p -r1.14 math.C
--- src/tex2lyx/math.C	28 Jun 2004 06:53:12 -0000	1.14
+++ src/tex2lyx/math.C	22 Jul 2004 22:58:08 -0000
@@ -16,6 +16,7 @@
 
 #include <iostream>
 
+using std::string;
 using std::cerr;
 using std::endl;
 
Index: src/tex2lyx/preamble.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/preamble.C,v
retrieving revision 1.22
diff -u -p -r1.22 preamble.C
--- src/tex2lyx/preamble.C	28 Jun 2004 06:53:12 -0000	1.22
+++ src/tex2lyx/preamble.C	22 Jul 2004 22:58:08 -0000
@@ -92,7 +92,7 @@ void handle_opt(vector<string> & opts, c
 		return;
 
 	for ( ; *what; ++what) {
-		vector<string>::iterator it = find(opts.begin(), opts.end(), *what);
+		vector<std::string>::iterator it = find(opts.begin(), opts.end(), *what);
 		if (it != opts.end()) {
 			//cerr << "### found option '" << *what << "'\n";
 			target = *what;
@@ -103,7 +103,7 @@ void handle_opt(vector<string> & opts, c
 }
 
 
-void handle_package(string const & name, string const & options)
+void handle_package(std::string const & name, std::string const & options)
 {
 	//cerr << "handle_package: '" << name << "'\n";
 	if (name == "a4wide") {
@@ -243,9 +243,9 @@ LyXTextClass const parse_preamble(Parser
 				p.get_token();
 				star = true;
 			}
-			string const name = p.verbatim_item();
-			string const opts = p.getOpt();
-			string const body = p.verbatim_item();
+			std::string const name = p.verbatim_item();
+			std::string const opts = p.getOpt();
+			std::string const body = p.verbatim_item();
 			// only non-lyxspecific stuff
 			if (   name != "\\noun"
 			    && name != "\\tabularnewline"
@@ -281,22 +281,22 @@ LyXTextClass const parse_preamble(Parser
 		}
 
 		else if (t.cs() == "usepackage") {
-			string const options = p.getArg('[', ']');
-			string const name = p.getArg('{', '}');
+			std::string const options = p.getArg('[', ']');
+			std::string const name = p.getArg('{', '}');
 			if (options.empty() && name.find(',')) {
-				vector<string> vecnames;
+				vector<std::string> vecnames;
 				split(name, vecnames, ',');
-				vector<string>::const_iterator it  = vecnames.begin();
-				vector<string>::const_iterator end = vecnames.end();
+				vector<std::string>::const_iterator it  = vecnames.begin();
+				vector<std::string>::const_iterator end = vecnames.end();
 				for (; it != end; ++it)
-					handle_package(trim(*it), string());
+					handle_package(trim(*it), std::string());
 			} else {
 				handle_package(name, options);
 			}
 		}
 
 		else if (t.cs() == "newenvironment") {
-			string const name = p.getArg('{', '}');
+			std::string const name = p.getArg('{', '}');
 			ostringstream ss;
 			ss << "\\newenvironment{" << name << "}";
 			ss << p.getOpt();
@@ -309,7 +309,7 @@ LyXTextClass const parse_preamble(Parser
 		}
 
 		else if (t.cs() == "def") {
-			string name = p.get_token().cs();
+			std::string name = p.get_token().cs();
 			while (p.next_token().cat() != catBegin)
 				name += p.get_token().asString();
 			h_preamble << "\\def\\" << name << '{' << p.verbatim_item() << "}";
@@ -333,8 +333,8 @@ LyXTextClass const parse_preamble(Parser
 		}
 
 		else if (t.cs() == "setcounter") {
-			string const name = p.getArg('{', '}');
-			string const content = p.getArg('{', '}');
+			std::string const name = p.getArg('{', '}');
+			std::string const content = p.getArg('{', '}');
 			if (name == "secnumdepth")
 				h_secnumdepth = content;
 			else if (name == "tocdepth")
Index: src/tex2lyx/table.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/table.C,v
retrieving revision 1.24
diff -u -p -r1.24 table.C
--- src/tex2lyx/table.C	19 Nov 2003 10:35:50 -0000	1.24
+++ src/tex2lyx/table.C	22 Jul 2004 22:58:08 -0000
@@ -22,6 +22,7 @@
 #include <vector>
 #include <map>
 
+using std::string;
 using std::cerr;
 using std::endl;
 using std::istringstream;
Index: src/tex2lyx/texparser.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/texparser.C,v
retrieving revision 1.25
diff -u -p -r1.25 texparser.C
--- src/tex2lyx/texparser.C	18 Jun 2004 06:47:19 -0000	1.25
+++ src/tex2lyx/texparser.C	22 Jul 2004 22:58:08 -0000
@@ -15,6 +15,7 @@
 #include <iostream>
 #include <sstream>
 
+using std::string;
 using std::cerr;
 using std::endl;
 using std::fill;
Index: src/tex2lyx/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/text.C,v
retrieving revision 1.38
diff -u -p -r1.38 text.C
--- src/tex2lyx/text.C	28 Jun 2004 06:53:12 -0000	1.38
+++ src/tex2lyx/text.C	22 Jul 2004 22:58:08 -0000
@@ -22,6 +22,7 @@
 #include "support/filetools.h"
 
 #include <iostream>
+#include <sstream>
 #include <map>
 #include <sstream>
 #include <vector>
-- 
        Lgb

Reply via email to