[color] do not use setValue() in SourceChoice / SwitchChoice
This potentially deletes the source/switch choice, which then triggers a "use-after-free". Resolves #759
This commit is contained in:
committed by
Peter Feerick
parent
66b523cf88
commit
64a87812bb
@@ -345,7 +345,7 @@ class ModelCategoryPageBody : public FormWindow
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
bool onTouchEnd(coord_t x, coord_t y)
|
||||
bool onTouchEnd(coord_t x, coord_t y) override
|
||||
{
|
||||
if(category->size() == 0)
|
||||
addFirstModel();
|
||||
|
||||
@@ -70,10 +70,7 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,
|
||||
menu->setWaitHandler([=]() {
|
||||
int16_t val = getMovedSource(vmin);
|
||||
if (val) {
|
||||
if (setValue) {
|
||||
setValue(val);
|
||||
}
|
||||
this->fillMenu(menu);
|
||||
fillMenu(menu, val);
|
||||
}
|
||||
#if defined(AUTOSWITCH)
|
||||
else {
|
||||
@@ -81,8 +78,7 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,
|
||||
if (swtch && !IS_SWITCH_MULTIPOS(swtch)) {
|
||||
val = switchToMix(swtch);
|
||||
if (val && (val >= vmin) && (val <= vmax)) {
|
||||
if (setValue) setValue(val);
|
||||
this->fillMenu(menu);
|
||||
fillMenu(menu, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,10 +97,8 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,
|
||||
setAvailableHandler([](int v){ return isSourceAvailable(v); });
|
||||
}
|
||||
|
||||
void SourceChoice::fillMenu(Menu *menu,
|
||||
const std::function<bool(int16_t)> &filter)
|
||||
void SourceChoice::fillMenu(Menu *menu, int16_t value, const FilterFct& filter)
|
||||
{
|
||||
auto value = getValue();
|
||||
int count = 0;
|
||||
int current = 0;
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ class SourceChoice : public ChoiceEx
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void fillMenu(Menu* menu,
|
||||
const std::function<bool(int16_t)>& condition = nullptr);
|
||||
typedef std::function<bool(int16_t)> FilterFct;
|
||||
void fillMenu(Menu* menu, int16_t value, const FilterFct& condition = nullptr);
|
||||
};
|
||||
|
||||
#endif // _SOURCECHOICE_H_
|
||||
|
||||
@@ -62,8 +62,7 @@ SwitchChoice::SwitchChoice(FormGroup* parent, const rect_t& rect, int vmin,
|
||||
val = swtch;
|
||||
}
|
||||
if (val && (!isValueAvailable || isValueAvailable(val))) {
|
||||
if (setValue) setValue(val);
|
||||
this->fillMenu(menu);
|
||||
fillMenu(menu, val);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -88,9 +87,8 @@ SwitchChoice::SwitchChoice(FormGroup* parent, const rect_t& rect, int vmin,
|
||||
setAvailableHandler(isSwitchAvailableInMixes);
|
||||
}
|
||||
|
||||
void SwitchChoice::fillMenu(Menu* menu, std::function<bool(int16_t)> filter)
|
||||
void SwitchChoice::fillMenu(Menu* menu, int16_t value, const FilterFct& filter)
|
||||
{
|
||||
auto value = getValue();
|
||||
int count = 0;
|
||||
int current = 0;
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ class SwitchChoice : public ChoiceEx
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void fillMenu(Menu* menu, std::function<bool(int16_t)> condition = nullptr);
|
||||
typedef std::function<bool(int16_t)> FilterFct;
|
||||
void fillMenu(Menu* menu, int16_t value, const FilterFct& filter = nullptr);
|
||||
};
|
||||
|
||||
#endif // _SWITCHCHOICE_H_
|
||||
|
||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: 253bc6a897...a0e72dc0c2
Reference in New Issue
Block a user