From 8a6b77bfe12d06b2fb41e3ce9c17f036b28cb8da Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 8 Mar 2010 19:07:05 +0000 Subject: [PATCH] Introduce isBufferValid() method now, that returns true also for cloned 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 | 7 +++++++ src/insets/Inset.h | 5 ++++- src/insets/InsetQuotes.cpp | 3 ++- src/mathed/InsetMathHull.cpp | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 5df7d41720..96634c87aa 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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"); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 50c05645ee..22604a73de 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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. /** diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index cf8a941dda..9fd534b2b6 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -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]); diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 88147a48ed..62a28ec4c9 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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); -- 2.39.2