Timeline: Check members of TimelineRenderer for sanity before using them

We have seen that occasionally the Qt Quick scene can resize to strange
dimensions, including negative width, which will cause equally strange
results if we than get stray mouse events.

Also, we need to take care not to access the model or the zoom control
before they're initialized.

Change-Id: Idf137bf7d16806dcf18e0d3f7be2b42e07e724c3
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-04-13 16:34:15 +02:00
parent f3492700ea
commit f9ae887ae7

View File

@@ -110,7 +110,7 @@ QSGNode *TimelineRenderer::updatePaintNode(QSGNode *node, UpdatePaintNodeData *u
Q_D(TimelineRenderer);
Q_UNUSED(updatePaintNodeData)
if (!d->model || d->model->hidden() || d->model->isEmpty() ||
if (!d->model || d->model->hidden() || d->model->isEmpty() || !d->zoomer ||
d->zoomer->windowDuration() <= 0) {
delete node;
return 0;
@@ -181,7 +181,7 @@ void TimelineRenderer::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(TimelineRenderer);
Q_UNUSED(event);
if (!d->model->isEmpty())
if (d->model && !d->model->isEmpty())
d->manageClicked();
}
@@ -222,6 +222,9 @@ void TimelineRenderer::TimelineRendererPrivate::manageClicked()
void TimelineRenderer::TimelineRendererPrivate::manageHovered(int mouseX, int mouseY)
{
Q_Q(TimelineRenderer);
if (!zoomer || !model || q->width() < 1)
return;
qint64 duration = zoomer->windowDuration();
if (duration <= 0)
return;