}
+bool Inset::isBufferValid() const
+{
+ return buffer_
+ && (isBufferLoaded() || buffer_->isClone());
+}
+
+
docstring Inset::name() const
{
return from_ascii("unknown");
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.
/**
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]);
// 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);