From: Vincent van Ravesteijn Date: Thu, 29 Oct 2009 22:06:27 +0000 (+0000) Subject: Move the call to LFUN_SET_COLOR from the handling of LFUN_BRANCH_ADD_INSERT to LFUN_B... X-Git-Tag: 2.0.0~5266 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5d9fdda29914bd8af4e903bb9e897d30b22fabd0;p=features.git Move the call to LFUN_SET_COLOR from the handling of LFUN_BRANCH_ADD_INSERT to LFUN_BRANCH_ADD. Now, the sequence "branch-add A" + "branch-insert A" doesn't result in an undefined branch Inset in the document. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31792 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 11c9231bb6..b42f14d028 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1857,21 +1857,25 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr) break; case LFUN_BRANCH_ADD: { - BranchList & branchList = params().branchlist(); - docstring const branchName = func.argument(); - if (branchName.empty()) { + docstring const branch_name = func.argument(); + if (branch_name.empty()) { dispatched = false; break; } - Branch * branch = branchList.find(branchName); + BranchList & branch_list = params().branchlist(); + Branch * branch = branch_list.find(branch_name); if (branch) { - LYXERR0("Branch " << branchName << " does already exist."); + LYXERR0("Branch " << branch_name << " already exists."); dr.setError(true); docstring const msg = - bformat(_("Branch \"%1$s\" does already exist."), branchName); + bformat(_("Branch \"%1$s\" already exists."), branch_name); dr.setMessage(msg); } else { - branchList.add(branchName); + branch_list.add(branch_name); + branch = branch_list.find(branch_name); + string const x11hexname = X11hexname(branch->color()); + docstring const str = branch_name + ' ' + from_ascii(x11hexname); + lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str)); dr.setError(false); dr.update(Update::Force); } diff --git a/src/BufferView.cpp b/src/BufferView.cpp index d07a7d9cac..4b055a9235 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1800,11 +1800,6 @@ bool BufferView::dispatch(FuncRequest const & cmd) Alert::warning(_("Branch already exists"), drtmp.message()); break; } - BranchList & branch_list = buffer_.params().branchlist(); - Branch const * branch = branch_list.find(branch_name); - string const x11hexname = X11hexname(branch->color()); - docstring const str = branch_name + ' ' + from_ascii(x11hexname); - lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str)); lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name)); break; }