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
This commit is contained in:
Vincent van Ravesteijn 2009-10-29 22:06:27 +00:00
parent cd15ffd9a9
commit 5d9fdda299
2 changed files with 11 additions and 12 deletions

View File

@ -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);
}

View File

@ -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;
}