Codechange: Avoid emplace_back(new()) into a unique_ptr. (#11384)
This could theoretically leave an unmanaged pointer in certain circumstances, and directly using make_unique shows intent.
This commit is contained in:
@@ -392,7 +392,7 @@ struct NewGRFParametersWindow : public Window {
|
||||
|
||||
DropDownList list;
|
||||
for (uint32_t i = par_info.min_value; i <= par_info.max_value; i++) {
|
||||
list.emplace_back(new DropDownListStringItem(GetGRFStringFromGRFText(par_info.value_names.find(i)->second), i, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(GetGRFStringFromGRFText(par_info.value_names.find(i)->second), i, false));
|
||||
}
|
||||
|
||||
ShowDropDownListAt(this, std::move(list), old_val, WID_NP_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
|
||||
@@ -952,10 +952,10 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
DropDownList list;
|
||||
|
||||
/* Add 'None' option for clearing list */
|
||||
list.emplace_back(new DropDownListStringItem(STR_NONE, -1, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, -1, false));
|
||||
|
||||
for (uint i = 0; i < this->grf_presets.size(); i++) {
|
||||
list.emplace_back(new DropDownListStringItem(this->grf_presets[i], i, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(this->grf_presets[i], i, false));
|
||||
}
|
||||
|
||||
this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
||||
|
Reference in New Issue
Block a user