fix(widget): harden TimelineAndTrackView teardown and TimeScaledObject limits

- TimelineAndTrackView: disconnect the scrollbar sync connections in the
  destructor. Child views reset their scene during destruction, which can
  re-emit QScrollBar::valueChanged into a half-destroyed object and trip
  Qt's assertObjectType abort.
- TimeScaledObject: keep minimum <= maximum when setting scale limits so
  set_scale()'s std::clamp is never called with inverted limits (UB).
  Setting the maximum below the minimum now pulls the minimum down, and
  vice versa, matching QAbstractSlider conventions.
This commit is contained in:
2026-08-05 14:53:04 +08:00
parent 774eda75fe
commit 7b6042168a
3 changed files with 24 additions and 0 deletions
+12
View File
@@ -116,6 +116,12 @@ void TimeScaledObject::set_maximum_scale(const double &max)
{
max_scale_ = max;
// Keep min <= max so the clamp in set_scale() is never called with
// inverted limits (undefined behavior)
if (min_scale_ > max_scale_) {
min_scale_ = max_scale_;
}
if (get_scale() > max_scale_) {
set_scale(max_scale_);
}
@@ -125,6 +131,12 @@ void TimeScaledObject::set_minimum_scale(const double &min)
{
min_scale_ = min;
// Keep min <= max so the clamp in set_scale() is never called with
// inverted limits (undefined behavior)
if (max_scale_ < min_scale_) {
max_scale_ = min_scale_;
}
if (get_scale() < min_scale_) {
set_scale(min_scale_);
}