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:
Flössie
2018-10-28 13:12:01 +01:00
parent 7038104a20
commit 5906329485
27 changed files with 708 additions and 697 deletions

View File

@@ -689,24 +689,24 @@ void ColorToning::setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool
void ColorToning::autoColorTonChanged(int satthres, int satprot)
{
struct Data {
ColorToning *me;
int satthres;
int satprot;
struct Data {
ColorToning *self;
int satthres;
int satprot;
};
const auto func =
[](Data* data) -> bool
{
ColorToning* const self = data->self;
self->disableListener();
self->satProtectionThreshold->setValue(data->satthres);
self->saturatedOpacity->setValue(data->satprot);
self->enableListener();
return false;
};
const auto func = [](gpointer data) -> gboolean {
Data *d = static_cast<Data *>(data);
ColorToning *me = d->me;
me->disableListener();
me->satProtectionThreshold->setValue(d->satthres);
me->saturatedOpacity->setValue(d->satprot);
me->enableListener ();
delete d;
return FALSE;
};
idle_register.add(func, new Data { this, satthres, satprot });
idle_register.add<Data>(func, new Data{this, satthres, satprot}, true);
}
void ColorToning::adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop)