tomm...@lyx.org schreef:
Author: tommaso
Date: Tue Sep  8 03:29:07 2009
New Revision: 31340
URL: http://www.lyx.org/trac/changeset/31340


Tommaso,

Would you please post this kind of patches before committing. I thought we have been very clear by now. Don't be surprised when I start reverting your commits when I don't like them.

Log:
Added isInternal() method, mapped temporarily on check about ".internal" 
filename extension (minimum impact on current code).
Replaced various replica of such check with the invocation of the new method.
TocBackend now does not call addToToc() for internal buffers.
Modified:
   lyx-devel/trunk/src/Buffer.cpp
   lyx-devel/trunk/src/Buffer.h
   lyx-devel/trunk/src/BufferList.cpp
   lyx-devel/trunk/src/TocBackend.cpp

Modified: lyx-devel/trunk/src/Buffer.cpp
==============================================================================
--- lyx-devel/trunk/src/Buffer.cpp      Tue Sep  8 01:58:56 2009        (r31339)
+++ lyx-devel/trunk/src/Buffer.cpp      Tue Sep  8 03:29:07 2009        (r31340)
@@ -312,7 +312,7 @@
        // GuiView already destroyed
        gui_ = 0;
- if (d->unnamed && d->filename.extension() == "internal") {
+       if (isInternal()) {
                // No need to do additional cleanups for internal buffer.
                delete d;
                return;
@@ -2040,6 +2040,17 @@
 }
+/// \note
+/// Don't check unnamed, here: isInternal() is used in
+/// newBuffer(), where the unnamed flag has not been set by anyone
+/// yet. Also, for an internal buffer, there should be no need for
+/// retrieving fileName() nor for checking if it is unnamed or not.

Why are you putting implementation details as a doxygen (?) comment outside the function. It looks like this can be in the function itself and we probably don't want this to end up in the documentation. If it doesn't end up in the documentation, then it's not needed.

Besides, I think this comment is not necessary. Why would anybody want to check for unnamed ? An internal buffer is always unnamed.

+bool Buffer::isInternal() const
+{
+       return fileName().extension() == "internal";
+}
+
+
 // FIXME: this function should be moved to buffer_pimpl.C
 void Buffer::markDirty()
 {

Modified: lyx-devel/trunk/src/Buffer.h
==============================================================================
--- lyx-devel/trunk/src/Buffer.h        Tue Sep  8 01:58:56 2009        (r31339)
+++ lyx-devel/trunk/src/Buffer.h        Tue Sep  8 03:29:07 2009        (r31340)
@@ -262,9 +262,16 @@
        ///
        void setUnnamed(bool flag = true);
- ///
+       /// Whether or not a filename has been assigned to this buffer
        bool isUnnamed() const;
+ /// Whether or not this buffer is internal.
+       ///
+       /// An internal buffer does not contain a real document, but some 
auxiliary text segment.
+       /// It is not associated with a filename, it is never saved, thus it 
does not need to be
+       /// automatically saved, nor it needs to trigger any "do you want to save 
?" question.
I think this is again a bit overdone on the comment.

+       bool isInternal() const;
+
        /// Mark this buffer as dirty.
        void markDirty();
Modified: lyx-devel/trunk/src/BufferList.cpp
==============================================================================
--- lyx-devel/trunk/src/BufferList.cpp  Tue Sep  8 01:58:56 2009        (r31339)
+++ lyx-devel/trunk/src/BufferList.cpp  Tue Sep  8 03:29:07 2009        (r31340)
@@ -119,7 +119,7 @@
                }
        }
        tmpbuf->params().useClassDefaults();
-       if (tmpbuf->fileName().extension() == "internal") {
+       if (tmpbuf->isInternal()) {
                binternal.push_back(tmpbuf.get());
        } else {
                LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size());

Modified: lyx-devel/trunk/src/TocBackend.cpp
==============================================================================
--- lyx-devel/trunk/src/TocBackend.cpp  Tue Sep  8 01:58:56 2009        (r31339)
+++ lyx-devel/trunk/src/TocBackend.cpp  Tue Sep  8 03:29:07 2009        (r31340)
@@ -163,8 +163,10 @@
 void TocBackend::update()
 {
        tocs_.clear();
-       DocIterator dit;
-       buffer_->inset().addToToc(dit);
+       if (! buffer_->isInternal()) {
Please stick to our conventions. We never use a space after the !.
+               DocIterator dit;
+               buffer_->inset().addToToc(dit);
+       }
 }

This shouldn't maybe be part of this commit, but a commit at its own, because you're now changing functionality. And again, I don't like the ad hoc way of working here. buffer_ is a member of the TocBackend class. So, everywhere in the TocBackend class we can freely do things on an internal buffer, but suddenly here we do care about whether it's internal or not.

I would make sure that buffer_ is _never_ an internal buffer.

Vincent

Reply via email to