diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 30238c319a..b305b68bdf 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1059,7 +1059,7 @@ private: }; uint num_children; ///< the number of subentries belonging to this entry. uint count; ///< sum of counts of all children or amount of cargo for this entry. - CargoDataSet *children; ///< the children of this entry. + std::unique_ptr children; ///< the children of this entry. }; CargoDataEntry::CargoDataEntry() : @@ -1067,7 +1067,7 @@ CargoDataEntry::CargoDataEntry() : station(INVALID_STATION), num_children(0), count(0), - children(new CargoDataSet(CargoSorter(CargoSortType::CargoID))) + children(std::make_unique(CargoSorter(CargoSortType::CargoID))) {} CargoDataEntry::CargoDataEntry(CargoID cargo, uint count, CargoDataEntry *parent) : @@ -1075,7 +1075,7 @@ CargoDataEntry::CargoDataEntry(CargoID cargo, uint count, CargoDataEntry *parent cargo(cargo), num_children(0), count(count), - children(new CargoDataSet) + children(std::make_unique()) {} CargoDataEntry::CargoDataEntry(StationID station, uint count, CargoDataEntry *parent) : @@ -1083,7 +1083,7 @@ CargoDataEntry::CargoDataEntry(StationID station, uint count, CargoDataEntry *pa station(station), num_children(0), count(count), - children(new CargoDataSet) + children(std::make_unique()) {} CargoDataEntry::CargoDataEntry(StationID station) : @@ -1105,7 +1105,6 @@ CargoDataEntry::CargoDataEntry(CargoID cargo) : CargoDataEntry::~CargoDataEntry() { this->Clear(); - delete this->children; } /** @@ -1183,9 +1182,7 @@ void CargoDataEntry::IncrementSize() void CargoDataEntry::Resort(CargoSortType type, SortOrder order) { - CargoDataSet *new_subs = new CargoDataSet(this->children->begin(), this->children->end(), CargoSorter(type, order)); - delete this->children; - this->children = new_subs; + this->children = std::make_unique(this->children->begin(), this->children->end(), CargoSorter(type, order)); } CargoDataEntry *CargoDataEntry::Retrieve(CargoDataSet::iterator i) const