mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-04-21 12:27:27 +03:00
Fix dynamic allocation of IconButton instances
Previously, IconButton instances to be added to button boxes were allocated with new, but never freed with delete. unique_ptr makes sure the buttons will be freed along with the button box that owns them, or when code calls ButtonBox::clear. The destructor of ButtonBox has been made redundant by this change, so it's gone.
This commit is contained in:
committed by
Maarten ter Huurne
parent
004c41e2ef
commit
891525aa94
@@ -29,6 +29,8 @@
|
||||
|
||||
using std::string;
|
||||
using std::stringstream;
|
||||
using std::unique_ptr;
|
||||
using std::move;
|
||||
|
||||
constexpr unsigned int COMPONENT_WIDTH = 28;
|
||||
|
||||
@@ -228,14 +230,14 @@ void MenuSettingRGBA::updateButtonBox()
|
||||
{
|
||||
buttonBox.clear();
|
||||
if (edit) {
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png"));
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"]));
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png"));
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"]));
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"]));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"])));
|
||||
} else {
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png"));
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]));
|
||||
buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"]));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png")));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"])));
|
||||
buttonBox.add(unique_ptr<IconButton>(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"])));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user