Review IdleRegister
(#4892)
This turns `IdleRegister::add()` into a template function to make the provided function pointers type safe. It also adds a `delete_data` parameter to manage the provided data pointer even in `destroy()`.
This commit is contained in:
@@ -255,18 +255,19 @@ void XTransProcess::checkBoxToggled (CheckBox* c, CheckValue newval)
|
||||
void XTransProcess::autoContrastChanged (double autoContrast)
|
||||
{
|
||||
struct Data {
|
||||
XTransProcess *me;
|
||||
XTransProcess* self;
|
||||
double autoContrast;
|
||||
};
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
XTransProcess *me = d->me;
|
||||
me->disableListener();
|
||||
me->dualDemosaicContrast->setValue(d->autoContrast);
|
||||
me->enableListener();
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, autoContrast });
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
XTransProcess* self = data->self;
|
||||
self->disableListener();
|
||||
self->dualDemosaicContrast->setValue(data->autoContrast);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add<Data>(func, new Data{this, autoContrast}, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user