From d188a36fc2c8e10831d857a446991a21032dceae Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 28 Dec 2017 14:41:47 -0500 Subject: [PATCH] Fix bug #10835. 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 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 0740fb4c91..d949de1b3a 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -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: {