From 90feb482db6e36f2071a0775f085300b9468f165 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 19 Feb 2009 21:33:07 +0000 Subject: [PATCH] Fix bug 5787-part_2 (Labels in Listings Children Don't Update Properly). It was still possible to set the label of an included Program Listing to an already existing label (if there was no label specified yet). See also: http://www.lyx.org/trac/changeset/28556 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28564 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetInclude.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 1814c235e3..c09d272f47 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -241,24 +241,28 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) InsetListingsParams new_params(to_utf8(p["lstparams"])); docstring const new_label = from_utf8(new_params.getParamValue("label")); - docstring old_label; - if (label_) - old_label = label_->getParam("name"); + if (new_label.empty()) { delete label_; label_ = 0; - } else if (label_ && old_label != new_label) { - label_->updateCommand(new_label); - // the label might have been adapted (duplicate) - if (new_label != label_->getParam("name")) { - new_params.addParam("label", - "{" + to_utf8(label_->getParam("name")) + "}"); - p["lstparams"] = from_utf8(new_params.params()); + } else { + docstring old_label; + if (label_) + old_label = label_->getParam("name"); + else { + label_ = createLabel(new_label); + label_->setBuffer(buffer()); + } + + if (new_label != old_label) { + label_->updateCommand(new_label); + // the label might have been adapted (duplicate) + if (new_label != label_->getParam("name")) { + new_params.addParam("label", "{" + + to_utf8(label_->getParam("name")) + "}", true); + p["lstparams"] = from_utf8(new_params.params()); + } } - } else if (old_label != new_label) { - label_ = createLabel(new_label); - label_->setBuffer(buffer()); - label_->initView(); } } setParams(p); -- 2.39.2