]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #10835.
authorRichard Heck <rgheck@lyx.org>
Thu, 28 Dec 2017 19:41:47 +0000 (14:41 -0500)
committerRichard Heck <rgheck@lyx.org>
Fri, 29 Dec 2017 21:09:15 +0000 (16:09 -0500)
VCS InsetInfos were broken by the switch at 2e934fc5f8 to using
updateBuffer to handle them. But we do not really want to go through
that routine in a clone, not for those insets, whose contents we
want to be the same as in the original Buffer.

Also fixes some issues noted in discussion of this bug: Failure to
update after context menu switch; failure to re-calculate shortcuts,
which can change.

src/insets/InsetInfo.cpp

index 0740fb4c91560231d88dd7c037afecb546df676b..d949de1b3a344a94a7a720e4b7978a1fc42eda64 100644 (file)
@@ -247,6 +247,7 @@ void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY:
                cur.recordUndo();
                setInfo(to_utf8(cmd.argument()));
+               cur.forceBufferUpdate();
                initialized_ = false;
                break;
 
@@ -296,6 +297,14 @@ void InsetInfo::setText(docstring const & str)
 
 
 void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
+       // If the Buffer is a clone, then we neither need nor want to do any
+       // of what follows. We want, rather, just to inherit how things were
+       // in the original Buffer. This is especially important for VCS.
+       // Otherwise, we could in principle have different settings here
+       // than in the Buffer we were exporting.
+       if (buffer().isClone())
+               return;
+
        BufferParams const & bp = buffer().params();
 
        switch (type_) {
@@ -305,11 +314,7 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                break;
        case SHORTCUT_INFO:
        case SHORTCUTS_INFO: {
-               // only need to do this once.
-               if (initialized_)
-                       break;
-               // and we will not keep trying if we fail
-               initialized_ = true;
+               // shortcuts can change, so we need to re-do this each time
                FuncRequest const func = lyxaction.lookupFunc(name_);
                if (func.action() == LFUN_UNKNOWN_ACTION) {
                        error("Unknown action %1$s");
@@ -328,7 +333,7 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                break;
        }
        case LYXRC_INFO: {
-               // this information could actually change, if the preferences are changed,
+               // this information could change, if the preferences are changed,
                // so we will recalculate each time through.
                ostringstream oss;
                if (name_.empty()) {
@@ -369,16 +374,13 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                break;
 
        case TEXTCLASS_INFO: {
-               // only need to do this once.
-               if (initialized_)
-                       break;
-               // name_ is the class name
+               // the TextClass can change
                LayoutFileList const & list = LayoutFileList::get();
                bool available = false;
+               // name_ is the class name
                if (list.haveClass(name_))
                        available = list[name_].isTeXClassAvailable();
                setText(available ? _("yes") : _("no"));
-               initialized_ = true;
                break;
        }
        case MENU_INFO: {