]> git.lyx.org Git - features.git/commitdiff
Deal with the part of #7872 involving changing branch activation
authorRichard Heck <rgheck@comcast.net>
Fri, 2 Dec 2011 21:21:37 +0000 (21:21 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 2 Dec 2011 21:21:37 +0000 (21:21 +0000)
from the context menu. As mentioned in the FIXME, we cannot now
handle the case where the branches are held in a master buffer.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40334 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetBranch.cpp

index ef4074889b962e8cfa7c9b714155967689e81754..6ab2fb79e73e5712a08c3face65b7bafc933eb6c 100644 (file)
@@ -127,19 +127,26 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_BRANCH_ACTIVATE:
        case LFUN_BRANCH_DEACTIVATE: {
                Buffer * buf = const_cast<Buffer *>(buffer().masterBuffer());
-               BranchList & branchlist = buf->params().branchlist();
-               Branch * our_branch = branchlist.find(params_.branch);
-               if (!our_branch) {
+               // is the branch in our master buffer?
+               bool branch_in_master = (buf != &buffer());
+
+               Branch * our_branch = buf->params().branchlist().find(params_.branch);
+               if (branch_in_master && !our_branch) {
                        // child only?
                        our_branch = buffer().params().branchlist().find(params_.branch);
                        if (!our_branch)
                                break;
-                       buf = &buffer();
+                       branch_in_master = false;
                }
                bool const activate = (cmd.action() == LFUN_BRANCH_ACTIVATE);
                if (our_branch->isSelected() != activate) {
+                       // FIXME If the branch is in the master document, we cannot
+                       // call recordUndo..., becuase the master may be hidden, and
+                       // the code presently assumes that hidden documents can never
+                       // be dirty. See GuiView::closeBufferAll(), for example.
+                       if (!branch_in_master)
+                               buffer().undo().recordUndoFullDocument(cur);
                        our_branch->setSelected(activate);
-                       buf->markDirty();
                        cur.forceBufferUpdate();
                }
                break;