Ignore:
Timestamp:
2019-05-11T22:23:33+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17698 - don't merge single checks into immediate following checkgroup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java

    r14153 r15072  
    131131        parser.mapOnStart("roles", Roles.class);
    132132        parser.map("role", Role.class);
    133         parser.map("checkgroup", CheckGroup.class);
     133        parser.mapBoth("checkgroup", CheckGroup.class);
    134134        parser.map("check", Check.class);
    135135        parser.map("combo", Combo.class);
     
    167167        XmlObjectParser parser = buildParser();
    168168
     169        /** to detect end of {@code <checkgroup>} */
     170        CheckGroup lastcheckgroup = null;
    169171        /** to detect end of {@code <group>} */
    170172        TaggingPresetMenu lastmenu = null;
     
    281283                        lastrole.roles.add((Role) o);
    282284                    } else if (o instanceof Check) {
    283                         checks.add((Check) o);
     285                        if (lastcheckgroup != null) {
     286                            checks.add((Check) o);
     287                        } else {
     288                            all.getLast().data.add((TaggingPresetItem) o);
     289                        }
    284290                    } else if (o instanceof ComboMultiSelect.PresetListEntry) {
    285291                        listEntries.add((ComboMultiSelect.PresetListEntry) o);
    286292                    } else if (o instanceof CheckGroup) {
    287                         all.getLast().data.add((TaggingPresetItem) o);
    288                         // Make sure list of checks is empty to avoid adding checks several times
    289                         // when used in chunks (fix #10801)
    290                         ((CheckGroup) o).checks.clear();
    291                         ((CheckGroup) o).checks.addAll(checks);
    292                         checks.clear();
     293                        CheckGroup cg = (CheckGroup) o;
     294                        if (cg == lastcheckgroup) {
     295                            lastcheckgroup = null;
     296                            all.getLast().data.add(cg);
     297                            // Make sure list of checks is empty to avoid adding checks several times
     298                            // when used in chunks (fix #10801)
     299                            cg.checks.clear();
     300                            cg.checks.addAll(checks);
     301                            checks.clear();
     302                        } else {
     303                            lastcheckgroup = cg;
     304                        }
    293305                    } else {
    294306                        if (!checks.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.