]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathHull.cpp
index 1ee6e3f4eb09f77355250d8903d0f23856e06ea0..15096fb9918f7426764708908ec01a8ee8279b84 100644 (file)
@@ -483,10 +483,10 @@ void InsetMathHull::addPreview(graphics::PreviewLoader & ploader) const
 bool InsetMathHull::notifyCursorLeaves(Cursor const & /*old*/, Cursor & cur)
 {
        if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
-               Buffer const & buffer = cur.buffer();
+               Buffer const * buffer = cur.buffer();
                docstring const snippet = latexString(*this);
-               preview_->addPreview(snippet, buffer);
-               preview_->startLoading(buffer);
+               preview_->addPreview(snippet, *buffer);
+               preview_->startLoading(*buffer);
                cur.updateFlags(Update::Force);
        }
        return false;
@@ -511,9 +511,10 @@ void InsetMathHull::label(row_type row, docstring const & label)
                        label_[row] = dummy_pointer;
                        // We need an update of the Buffer reference cache.
                        // This is achieved by updateLabels().
-                       lyx::updateLabels(buffer());
-               } else
+                       buffer().updateLabels();
+               } else {
                        label_[row]->updateCommand(label);
+               }
                return;
        }
        InsetCommandParams p(LABEL_CODE);
@@ -530,9 +531,14 @@ void InsetMathHull::numbered(row_type row, bool num)
        if (nonum_[row] && label_[row]) {
                delete label_[row];
                label_[row] = 0;
+               if (!buffer_) {
+                       // The buffer is set at the end of readInset.
+                       // When parsing the inset, buffer_ is 0.
+                       return;
+               }
                // We need an update of the Buffer reference cache.
                // This is achieved by updateLabels().
-               lyx::updateLabels(buffer());
+               buffer().updateLabels();
        }
 }
 
@@ -545,21 +551,21 @@ bool InsetMathHull::numbered(row_type row) const
 
 bool InsetMathHull::ams() const
 {
-       return
-               type_ == hullAlign ||
-               type_ == hullFlAlign ||
-               type_ == hullMultline ||
-               type_ == hullGather ||
-               type_ == hullAlignAt ||
-               type_ == hullXAlignAt ||
-               type_ == hullXXAlignAt;
+       return type_ == hullAlign
+               || type_ == hullFlAlign
+               || type_ == hullMultline
+               || type_ == hullGather
+               || type_ == hullAlignAt
+               || type_ == hullXAlignAt
+               || type_ == hullXXAlignAt;
 }
 
 
 Inset::DisplayType InsetMathHull::display() const
 {
-       return (type_ != hullSimple && type_ != hullNone
-               && type_ != hullRegexp) ? AlignCenter : Inline;
+       if (type_ == hullSimple || type_ == hullNone || type_ == hullRegexp)
+               return Inline;
+       return AlignCenter;
 }
 
 bool InsetMathHull::numberedType() const