summaryrefslogtreecommitdiff
path: root/src/widgets/dropdown_type.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2019-04-02 21:31:24 +0200
committerMichael Lutz <michi@icosahedron.de>2019-04-09 22:45:15 +0200
commitc7b9987d081ae4e0103309b18c93deecc395dec9 (patch)
treee5b1f9553d6399e2eed9c05a2d91673205f9c912 /src/widgets/dropdown_type.h
parentd3e113eb5f618ce0174fa0dfa2591cb96e999350 (diff)
downloadopenttd-c7b9987d081ae4e0103309b18c93deecc395dec9.tar.xz
Codechange: Switch DropDownList to directly use std::vector, thus making AutoDeleteSmallVector obsolete.
DropDownListItem are strongly managed using std::unique_ptr to ensure leak-free handling. Appropriate use of move-semantics make intent a lot clearer than parameter comments and allows the compiler to generate copy-free code for most situations.
Diffstat (limited to 'src/widgets/dropdown_type.h')
-rw-r--r--src/widgets/dropdown_type.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h
index bf8638a92..26c699f16 100644
--- a/src/widgets/dropdown_type.h
+++ b/src/widgets/dropdown_type.h
@@ -49,7 +49,7 @@ public:
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override;
virtual StringID String() const { return this->string; }
- static int CDECL NatSortFunc(const DropDownListItem * const *first, const DropDownListItem * const *second);
+ static int NatSortFunc(std::unique_ptr<const DropDownListItem> const &first, std::unique_ptr<const DropDownListItem> const &second);
};
/**
@@ -98,10 +98,10 @@ public:
/**
* A drop down list is a collection of drop down list items.
*/
-typedef AutoDeleteSmallVector<const DropDownListItem *> DropDownList;
+typedef std::vector<std::unique_ptr<const DropDownListItem>> DropDownList;
-void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false);
+void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false);
-void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
+void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
#endif /* WIDGETS_DROPDOWN_TYPE_H */