Add null checks for timebase in TimeScaledObject and fix background color assignment in ViewerDisplayWidget

This commit is contained in:
2025-11-24 10:33:38 +08:00
parent 2c4d235da6
commit f317e0e173
3 changed files with 14 additions and 1 deletions
+1
View File
@@ -107,6 +107,7 @@ list(APPEND OLIVE_INCLUDE_DIRS ${OPENEXR_INCLUDES})
list(APPEND OLIVE_LIBRARIES olivecore)
list(APPEND OLIVE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/core/include)
# Link Qt
set(QT_LIBRARIES
Core
+12
View File
@@ -58,6 +58,9 @@ const double &TimeScaledObject::timebase_dbl() const
rational TimeScaledObject::SceneToTime(const double &x, const double &x_scale,
const rational &timebase, bool round)
{
if (timebase.isNull()) {
return rational();
}
double unscaled_time = x / x_scale / timebase.toDouble();
// Adjust screen point by scale and timebase
@@ -87,16 +90,25 @@ rational TimeScaledObject::SceneToTimeNoGrid(const double &x,
double TimeScaledObject::TimeToScene(const rational &time) const
{
if (timebase_.isNull()) {
return 0.0;
}
return time.toDouble() * scale_;
}
rational TimeScaledObject::SceneToTime(const double &x, bool round) const
{
if (timebase_.isNull()) {
return rational();
}
return SceneToTime(x, scale_, timebase_, round);
}
rational TimeScaledObject::SceneToTimeNoGrid(const double &x) const
{
if (timebase_.isNull()) {
return rational::fromDouble(x / scale_);
}
return SceneToTimeNoGrid(x, scale_);
}
+1 -1
View File
@@ -374,7 +374,7 @@ bool ViewerDisplayWidget::eventFilter(QObject *o, QEvent *e)
void ViewerDisplayWidget::OnPaint()
{
// Clear background to empty
QColor bg_color = show_widget_background_ ? palette().window().color() :
QColor bg_color = show_widget_background_ ? palette().window().color() :
Qt::black;
renderer()->ClearDestination(nullptr, bg_color.redF(), bg_color.greenF(),
bg_color.blueF());