Commit ebb5a5b0 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Fixed crash when moving media.

parent 3a75a92c
......@@ -165,7 +165,6 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position
QPointF oldPos = item->pos();
QGraphicsItem* oldParent = item->parentItem();
// Check for vertical collisions
item->setParentItem( m_layout->itemAt( track )->graphicsItem() );
bool continueSearch = true;
......@@ -182,13 +181,14 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position
itemCollision = true;
if ( currentItem->pos().y() < position.y() )
{
if ( track < 0 )
if ( track < 1 )
{
item->setParentItem( oldParent );
continueSearch = false;
break;
}
track -= 1;
Q_ASSERT( m_layout->itemAt( track )->graphicsItem() != NULL );
item->setParentItem( m_layout->itemAt( track )->graphicsItem() );
}
else if ( currentItem->pos().y() > position.y() )
......@@ -200,6 +200,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position
break;
}
track += 1;
Q_ASSERT( m_layout->itemAt( track )->graphicsItem() != NULL );
item->setParentItem( m_layout->itemAt( track )->graphicsItem() );
}
}
......@@ -207,7 +208,6 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position
if ( !itemCollision )
continueSearch = false;
}
// Check for horizontal collisions
mappedXPos = qMax( mappedXPos, (qreal)0 );
item->setPos( mappedXPos, 0 );
......@@ -219,7 +219,8 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position
{
// Collision with an item of the same type
// Restoring original position (horizontal)
item->setPos( oldPos );
if ( oldPos.isNull() == false )
item->setPos( oldPos );
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment