]> git.lyx.org Git - features.git/commitdiff
* src/insets/InsetLabel.cpp:
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 3 Mar 2008 08:19:36 +0000 (08:19 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 3 Mar 2008 08:19:36 +0000 (08:19 +0000)
- minor fixes to the label validation.

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

src/insets/InsetLabel.cpp

index 5f4753b66f53fb3ec3e94fd7b72a2727e8b278de..606474b5d586c4453900fe9c4ab7798389b6beb5 100644 (file)
@@ -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<docstring>(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());