]> git.lyx.org Git - lyx.git/blobdiff - src/bufferlist.C
In for a penny, in for a pound. Consistent use of // -*- C++ -*-
[lyx.git] / src / bufferlist.C
index f00374aea42cc032304ab7b2b054cc7acbe5bd49..ecfcb4945aee23100197efc12214d222191c1b52 100644 (file)
@@ -4,9 +4,9 @@
  *           LyX, The Document Word Processor
  *
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team. 
+ *           Copyright 1995-2001 The LyX Team. 
  *
- *           This file is Copyright 1996-2000
+ *           This file is Copyright 1996-2001
  *           Lars Gullik Bjønnes
  *
  * ====================================================== 
@@ -54,6 +54,7 @@ extern BufferView * current_view;
 
 void BufferStorage::release(Buffer * buf)
 {
+       lyx::Assert(buf);
        Container::iterator it = find(container.begin(), container.end(), buf);
        if (it != container.end()) {
                // Make sure that we don't store a LyXText in
@@ -168,6 +169,8 @@ void BufferList::resize()
 
 bool BufferList::close(Buffer * buf)
 {
+       lyx::Assert(buf);
+       
        // CHECK
        // Trace back why we need to use buf->getUser here.
        // Perhaps slight rewrite is in order? (Lgb)
@@ -223,7 +226,7 @@ vector<string> const BufferList::getFileNames() const
 {
        vector<string> nvec;
        std::copy(bstore.begin(), bstore.end(),
-                 back_inserter_fun(nvec, &Buffer::fileName));
+                 lyx::back_inserter_fun(nvec, &Buffer::fileName));
        return nvec;
 }
 
@@ -244,7 +247,9 @@ Buffer * BufferList::getBuffer(unsigned int choice)
 
 int BufferList::unlockInset(UpdatableInset * inset)
 {
-       if (!inset) return 1;
+       lyx::Assert(inset);
+       
+       //if (!inset) return 1;
        for (BufferStorage::iterator it = bstore.begin();
             it != bstore.end(); ++it) {
                if ((*it)->getUser()
@@ -276,12 +281,17 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
 void BufferList::emergencyWriteAll()
 {
        for_each(bstore.begin(), bstore.end(),
-                class_fun(*this, &BufferList::emergencyWrite));
+                lyx::class_fun(*this, &BufferList::emergencyWrite));
 }
 
 
 void BufferList::emergencyWrite(Buffer * buf) 
 {
+       // assert(buf) // this is not good since C assert takes an int
+                      // and a pointer is a long (JMarc)
+       assert(buf != 0); // use c assert to avoid a loop
+
+       
        // No need to save if the buffer has not changed.
        if (buf->isLyxClean()) return;
        
@@ -405,12 +415,15 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
 bool BufferList::exists(string const & s) const
 {
        return find_if(bstore.begin(), bstore.end(),
-                      compare_memfun(&Buffer::fileName, s)) != bstore.end();
+                      lyx::compare_memfun(&Buffer::fileName, s))
+               != bstore.end();
 }
 
 
 bool BufferList::isLoaded(Buffer const * b) const
 {
+       lyx::Assert(b);
+       
        BufferStorage::const_iterator cit =
                find(bstore.begin(), bstore.end(), b);
        return cit != bstore.end();
@@ -421,7 +434,7 @@ Buffer * BufferList::getBuffer(string const & s)
 {
        BufferStorage::iterator it =
                find_if(bstore.begin(), bstore.end(),
-                       compare_memfun(&Buffer::fileName, s));
+                       lyx::compare_memfun(&Buffer::fileName, s));
        return it != bstore.end() ? (*it) : 0;
 }