[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
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#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)
|
if(category->size() == 0)
|
||||||
addFirstModel();
|
addFirstModel();
|
||||||
|
|||||||
@@ -70,10 +70,7 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,
|
|||||||
menu->setWaitHandler([=]() {
|
menu->setWaitHandler([=]() {
|
||||||
int16_t val = getMovedSource(vmin);
|
int16_t val = getMovedSource(vmin);
|
||||||
if (val) {
|
if (val) {
|
||||||
if (setValue) {
|
fillMenu(menu, val);
|
||||||
setValue(val);
|
|
||||||
}
|
|
||||||
this->fillMenu(menu);
|
|
||||||
}
|
}
|
||||||
#if defined(AUTOSWITCH)
|
#if defined(AUTOSWITCH)
|
||||||
else {
|
else {
|
||||||
@@ -81,8 +78,7 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,
|
|||||||
if (swtch && !IS_SWITCH_MULTIPOS(swtch)) {
|
if (swtch && !IS_SWITCH_MULTIPOS(swtch)) {
|
||||||
val = switchToMix(swtch);
|
val = switchToMix(swtch);
|
||||||
if (val && (val >= vmin) && (val <= vmax)) {
|
if (val && (val >= vmin) && (val <= vmax)) {
|
||||||
if (setValue) setValue(val);
|
fillMenu(menu, val);
|
||||||
this->fillMenu(menu);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,10 +97,8 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,
|
|||||||
setAvailableHandler([](int v){ return isSourceAvailable(v); });
|
setAvailableHandler([](int v){ return isSourceAvailable(v); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceChoice::fillMenu(Menu *menu,
|
void SourceChoice::fillMenu(Menu *menu, int16_t value, const FilterFct& filter)
|
||||||
const std::function<bool(int16_t)> &filter)
|
|
||||||
{
|
{
|
||||||
auto value = getValue();
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int current = 0;
|
int current = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class SourceChoice : public ChoiceEx
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void fillMenu(Menu* menu,
|
typedef std::function<bool(int16_t)> FilterFct;
|
||||||
const std::function<bool(int16_t)>& condition = nullptr);
|
void fillMenu(Menu* menu, int16_t value, const FilterFct& condition = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SOURCECHOICE_H_
|
#endif // _SOURCECHOICE_H_
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ SwitchChoice::SwitchChoice(FormGroup* parent, const rect_t& rect, int vmin,
|
|||||||
val = swtch;
|
val = swtch;
|
||||||
}
|
}
|
||||||
if (val && (!isValueAvailable || isValueAvailable(val))) {
|
if (val && (!isValueAvailable || isValueAvailable(val))) {
|
||||||
if (setValue) setValue(val);
|
fillMenu(menu, val);
|
||||||
this->fillMenu(menu);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -88,9 +87,8 @@ SwitchChoice::SwitchChoice(FormGroup* parent, const rect_t& rect, int vmin,
|
|||||||
setAvailableHandler(isSwitchAvailableInMixes);
|
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 count = 0;
|
||||||
int current = 0;
|
int current = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class SwitchChoice : public ChoiceEx
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
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_
|
#endif // _SWITCHCHOICE_H_
|
||||||
|
|||||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: 253bc6a897...a0e72dc0c2
Reference in New Issue
Block a user