Do not store direct references to original bindable

`DifficultyAdjustSettingsControl` and its inner `SliderControl` were
holding different references to `DifficultyBindable`s from the
difficulty adjust mod, therefore leading to bindings being lost to the
framework-side automatic unbind logic if the mod was toggled off and
back on in rapid succession.

Resolve by adding a shadowed implementation of `GetBoundCopy()` and
using it to isolate the controls from the mod bindable.
This commit is contained in:
Bartłomiej Dach 2021-07-11 15:12:46 +02:00
parent 79d546afa2
commit 32b4f5fbd6
2 changed files with 13 additions and 2 deletions

View File

@ -41,10 +41,10 @@ namespace osu.Game.Rulesets.Mods
{
// Intercept and extract the internal number bindable from DifficultyBindable.
// This will provide bounds and precision specifications for the slider bar.
difficultyBindable = (DifficultyBindable)value;
difficultyBindable = ((DifficultyBindable)value).GetBoundCopy();
sliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber);
base.Current = value;
base.Current = difficultyBindable;
}
}

View File

@ -92,5 +92,16 @@ namespace osu.Game.Rulesets.Mods
{
CurrentNumber.MaxValue = ExtendedLimits.Value && extendedMaxValue != null ? extendedMaxValue.Value : maxValue;
}
public new DifficultyBindable GetBoundCopy() => new DifficultyBindable
{
BindTarget = this,
CurrentNumber = { BindTarget = CurrentNumber },
ExtendedLimits = { BindTarget = ExtendedLimits },
ReadCurrentFromDifficulty = ReadCurrentFromDifficulty,
// the following is only safe as long as these values are effectively constants.
MaxValue = maxValue,
ExtendedMaxValue = extendedMaxValue
};
}
}