Free cookie consent management tool by TermsFeed Policy Generator

Opened 8 years ago

Closed 8 years ago

#2575 closed defect (done)

ObservableList's AddRange enumerates multiple times

Reported by: abeham Owned by: abeham
Priority: medium Milestone: HeuristicLab 3.3.14
Component: Collections Version: 3.3.13
Keywords: Cc:

Description

It enumerates it a total of three times which may produce three different collections.

    public void AddRange(IEnumerable<T> collection) {
      int capacity = list.Capacity;
      int index = list.Count;
      list.AddRange(collection); // HERE
      List<IndexedItem<T>> items = new List<IndexedItem<T>>();
      foreach (T item in collection) { // HERE
        items.Add(new IndexedItem<T>(index, item));
        index++;
      }
      if (items.Count > 0) {
        OnItemsAdded(items);
        OnItemsAdded(collection); // HERE
        if (list.Capacity != capacity)
          OnPropertyChanged("Capacity");
        OnPropertyChanged("Item[]");
        OnPropertyChanged("Count");
      }
    }

Change History (4)

comment:1 Changed 8 years ago by abeham

  • Owner set to abeham
  • Status changed from new to accepted

r13597: fixed multiple enumeration of collection in ObservableCollection and ObservableList

comment:2 Changed 8 years ago by abeham

  • Owner changed from abeham to mkommend
  • Status changed from accepted to reviewing

comment:3 Changed 8 years ago by mkommend

  • Owner changed from mkommend to abeham
  • Status changed from reviewing to readytorelease

Reviewed r13597.

comment:4 Changed 8 years ago by mkommend

  • Resolution set to done
  • Status changed from readytorelease to closed

r13886: Merged r13597 into stable.

Note: See TracTickets for help on using tickets.