On 10/03/2017 03:54 PM, Jean-Marc Lasgouttes wrote:
> Le 03/10/17 à 21:43, Richard Heck a écrit :
>
>> The crucial thing here seems to be that it's a "menu" inset. That
>> triggers a menu search, which calls getStatus, which ends up accessing
>> the Cursor, which is now out of date. So we end up here:
>
> A different solution would be to avoid calling updateInfo() when
> parsing an info inset. This should be done later in updateBuffer()
> anyway.

Yes, I thought of that, too, but I was a bit worried about whether there
might be other side-effects. Also, the fact that we are, really, only
doing this once as things are is striking. Maybe do something safe for
2.3.x and try something more radical in master?

Looking quickly at this, updateInfo() is also called from setInfo(),
which is called by the InsetInfo constructor and by doDispatch(), for
the case of LFUN_INSET_MODIFY. I would think that it should not be
called there, either.

So maybe something like the attached. I have not tested it. If there's a
problem, though, adding a forceBufferUpdate() somewhere should fix it.

Richard

diff --git a/src/factory.cpp b/src/factory.cpp
index 72019cd..3937a9e 100644
--- a/src/factory.cpp
+++ b/src/factory.cpp
@@ -263,7 +263,6 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & 
cmd)
 
                case LFUN_INFO_INSERT: {
                        InsetInfo * inset = new InsetInfo(buf, 
to_utf8(cmd.argument()));
-                       inset->updateInfo();
                        return inset;
                }
 
diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index 42e0f6c..be8ef9f 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -147,7 +147,6 @@ void InsetInfo::read(Lexer & lex)
                        _("Missing \\end_inset at this point."),
                        from_utf8(token));
        }
-       updateInfo();
 }
 
 
@@ -278,7 +277,6 @@ void InsetInfo::setInfo(string const & name)
        string type;
        name_ = trim(split(name, type, ' '));
        type_ = nameTranslator().find(type);
-       updateInfo();
 }
 
 
@@ -295,7 +293,7 @@ void InsetInfo::setText(docstring const & str)
 }
 
 
-void InsetInfo::updateInfo()
+void InsetInfo::updateBuffer(ParIterator const & /*it*/, UpdateType /* utype*/)
 {
        BufferParams const & bp = buffer().params();
 
diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h
index 96ba22c..006b052 100644
--- a/src/insets/InsetInfo.h
+++ b/src/insets/InsetInfo.h
@@ -127,8 +127,8 @@ public:
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
        void setInfo(std::string const & info);
-       /// update info_ and text
-       void updateInfo();
+       ///
+       void updateBuffer(ParIterator const & /*it*/, UpdateType /* utype*/);
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///

Reply via email to