]> git.lyx.org Git - features.git/commitdiff
Introduce isBufferValid() method now, that returns true also for cloned
authorRichard Heck <rgheck@comcast.net>
Mon, 8 Mar 2010 19:07:05 +0000 (19:07 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 8 Mar 2010 19:07:05 +0000 (19:07 +0000)
Buffers. Use it, as well.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33679 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetQuotes.cpp
src/mathed/InsetMathHull.cpp

index 5df7d417207ac075e0bbb07290c1735c3148bef4..96634c87aa1ac360b527cb2a41a39ec00a40cff2 100644 (file)
@@ -204,6 +204,13 @@ bool Inset::isBufferLoaded() const
 }
 
 
+bool Inset::isBufferValid() const
+{
+       return buffer_ 
+               && (isBufferLoaded() || buffer_->isClone());
+}
+
+
 docstring Inset::name() const
 {
        return from_ascii("unknown");
index 50c05645ee85192c7082d71a2afa67f4d08412c4..22604a73de1e2e783b50d8ae30b60ad837707df1 100644 (file)
@@ -109,8 +109,11 @@ public:
        virtual Buffer const & buffer() const;
        /// Returns true if buffer_ actually points to a Buffer that has
        /// been loaded into LyX and is still open. Note that this will
-       /// always return false for cloned Buffers. 
+       /// always return false for cloned Buffers. If you want to allow
+       /// for the case of cloned Buffers, use isBufferValid().
        bool isBufferLoaded() const;
+       /// Returns true if this is a loaded buffer or a cloned buffer.
+       bool isBufferValid() const;
 
        /// initialize view for this inset.
        /**
index cf8a941ddaab6f24089daae83626d19196057149..9fd534b2b6f5e847b1843a0e69efbe0d71403d55 100644 (file)
@@ -185,7 +185,8 @@ void InsetQuotes::parseString(string const & s)
 
 docstring InsetQuotes::displayString() const
 {
-       Language const * loclang = isBufferLoaded() ? buffer().params().language : 0;
+       Language const * loclang = 
+               isBufferValid() ? buffer().params().language : 0;
        int const index = quote_index[side_][language_];
        docstring retdisp = docstring(1, display_quote_char[times_][index]);
 
index 88147a48eda5c4fe1d3e595cf37766ec816daaa9..62a28ec4c99005711f938a808d22c37a6517018d 100644 (file)
@@ -471,7 +471,7 @@ static docstring latexString(InsetMathHull const & inset)
        // first time as a whole, and the second time only the inner math.
        // In this last case inset.buffer() would be invalid.
        static Encoding const * encoding = 0;
-       if (inset.isBufferLoaded())
+       if (inset.isBufferValid())
                encoding = &(inset.buffer().params().encoding());
        WriteStream wi(ls, false, true, WriteStream::wsPreview, encoding);
        inset.write(wi);