]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetert.C
handle missing layout gracefully when reading and writing lyx files
[lyx.git] / src / insets / insetert.C
index 2f8ab8b9177c94fe71ab9c18d110899541edaba1..415879dbdd2204640439ccf434fc723ccfd0612c 100644 (file)
@@ -623,6 +623,7 @@ void InsetERT::set_latex_font(BufferView * /* bv */)
 }
 
 
+// attention this function can be called with bv == 0
 void InsetERT::status(BufferView * bv, ERTStatus const st) const
 {
        if (st != status_) {
@@ -630,7 +631,9 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
                need_update = FULL;
                switch (st) {
                case Inlined:
-                       inset.setUpdateStatus(bv, InsetText::INIT);
+#warning Another gross hack. (Lgb)
+                       if (bv)
+                               inset.setUpdateStatus(bv, InsetText::INIT);
                        break;
                case Open:
                        collapsed_ = false;
@@ -672,12 +675,14 @@ void InsetERT::close(BufferView * bv) const
 }
 
 
-string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,float &) const
+string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,
+                                                 float &) const
 {
        bv->unlockInset(const_cast<InsetERT *>(this));
        return string();
 }
 
+
 void InsetERT::getDrawFont(LyXFont & font) const
 {
 #ifndef INHERIT_LANG
@@ -693,11 +698,15 @@ void InsetERT::getDrawFont(LyXFont & font) const
 
 int InsetERT::getMaxWidth(BufferView * bv, UpdatableInset const * in) const
 {
-       unsigned int w = InsetCollapsable::getMaxWidth(bv, in);
+       int w = InsetCollapsable::getMaxWidth(bv, in);
        if (status_ != Inlined || w < 0)
                return w;
        LyXText * text = inset.getLyXText(bv);
-       if (text->width < w && !text->firstRow()->next())
+       int rw = text->firstRow()->width();
+       if (!rw)
+               rw = w;
+       rw += 40;
+       if (!text->firstRow()->next() && rw < w)
                return -1;
        return w;
 }