From: Jürgen Spitzmüller Date: Mon, 3 Mar 2008 08:19:36 +0000 (+0000) Subject: * src/insets/InsetLabel.cpp: X-Git-Tag: 1.6.10~5934 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=eef138f77b0d771ea4ba1d52a3ebf3463b545948;p=features.git * src/insets/InsetLabel.cpp: - minor fixes to the label validation. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23406 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 5f4753b66f..606474b5d5 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -53,11 +53,19 @@ void InsetLabel::update(docstring const & new_label) { docstring const old_label = getParam("name"); docstring label = new_label; - int i = 0; + int i = 1; while (buffer().insetLabel(label)) { label = new_label + '-' + convert(i); ++i; } + + if (label != new_label) { + // Warn the user that the label has been changed to something else. + frontend::Alert::warning(_("Label names must be unique!"), + bformat(_("The label %1$s already exists,\n" + "it will been changed to %2$s."), new_label, label)); + } + setParam("name", label); Buffer::References const & refs = buffer().references(old_label); @@ -66,12 +74,6 @@ void InsetLabel::update(docstring const & new_label) for (; it != end; ++it) it->first->setParam("reference", label); - if (label != new_label) { - // Warn the user that the label has been changed to something else. - frontend::Alert::warning(_("Label names must be unique!"), - bformat(_("The label %1$s already exists,\n" - "it will been changed to %2$s."), new_label, label)); - } // We need an update of the Buffer reference cache. This is achieved by // updateLabel(). lyx::updateLabels(buffer());