[vlmc-devel] commit: TracksView/AbstractGraphicsMediaItem: Fixing signedness warnings. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sun Aug 29 17:23:41 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Aug 29 17:17:33 2010 +0200| [fb8e8f02aba793d8908e0097de8f0239d492f4b8] | committer: Hugo Beauzée-Luyssen
TracksView/AbstractGraphicsMediaItem: Fixing signedness warnings.
When a trackId is stored, we should use a signed type, as it can be
initialized in some error cases. My apologies to etix :)
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=fb8e8f02aba793d8908e0097de8f0239d492f4b8
---
src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 17 +++++++++--------
src/Gui/timeline/AbstractGraphicsMediaItem.h | 2 +-
src/Gui/timeline/TracksView.cpp | 18 ++++++++++++------
src/Gui/timeline/TracksView.h | 8 ++++----
4 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index cf9ba6a..0e5f67d 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -106,7 +106,7 @@ void AbstractGraphicsMediaItem::setHeight( qint64 height )
m_height = height;
}
-quint32 AbstractGraphicsMediaItem::trackNumber()
+qint32 AbstractGraphicsMediaItem::trackNumber()
{
if ( parentItem() )
{
@@ -114,9 +114,7 @@ quint32 AbstractGraphicsMediaItem::trackNumber()
if ( graphicsTrack )
return graphicsTrack->trackNumber();
}
- //FIXME We should probably return a negative number here (using a signed type!)
- qWarning( "Things can go wrong beyond that point!" );
- return 0;
+ return -1;
}
void AbstractGraphicsMediaItem::setTrack( GraphicsTrack* track )
@@ -189,17 +187,18 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent
scene()->askRemoveSelectedItems();
else if ( selectedAction == muteAction )
{
-
+ qint32 trackId = trackNumber();
+ Q_ASSERT( trackId >= 0 );
if ( ( m_muted = muteAction->isChecked() ) )
{
tracksView()->m_mainWorkflow->muteClip( uuid(),
- trackNumber(),
+ trackId,
mediaType() );
}
else
{
tracksView()->m_mainWorkflow->unmuteClip( uuid(),
- trackNumber(),
+ trackId,
mediaType() );
}
}
@@ -222,8 +221,10 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent
if ( item1->mediaType() != mediaType() )
{
+ qint32 item1TrackId = item1->trackNumber();
+ Q_ASSERT( item1TrackId >= 0 );
item1->group( this );
- tracksView()->moveMediaItem( item1, item1->trackNumber(), startPos() );
+ tracksView()->moveMediaItem( item1, item1TrackId , startPos() );
track()->trackWorkflow()->moveClip( item1->clipHelper()->uuid(), startPos() );
}
}
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index e1f1863..9d58d52 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -88,7 +88,7 @@ public:
void ungroup();
/// Return the current track of the item
- quint32 trackNumber();
+ qint32 trackNumber();
/// Set the item's parent track
void setTrack( GraphicsTrack* track );
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index a9aad0a..fab8c57 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -231,7 +231,7 @@ TracksView::addMediaItem( TrackWorkflow *tw, ClipHelper *ch, qint64 start )
//already be created (by the drag and drop operation)
if ( m_clipsLoaded.contains( ch->uuid() ) )
return ;
- quint32 track = tw->trackId();
+ qint32 track = tw->trackId();
Workflow::TrackType trackType = tw->type();
// If there is not enough tracks to insert
@@ -385,7 +385,7 @@ TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, QPoint position )
}
void
-TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, quint32 track, qint64 time )
+TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, qint32 track, qint64 time )
{
// Add missing tracks
if ( item->mediaType() == Workflow::AudioTrack )
@@ -480,7 +480,7 @@ TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, quint32 track, qint6
}
ItemPosition
-TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64 time )
+TracksView::findPosition( AbstractGraphicsMediaItem *item, qint32 track, qint64 time )
{
// Create a fake item for computing collisions
@@ -502,9 +502,12 @@ TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64
AbstractGraphicsMediaItem *currentItem = dynamic_cast<AbstractGraphicsMediaItem*>( colliding.at( i ) );
if ( currentItem && currentItem != item )
{
+ qint32 trackId = currentItem->trackNumber();
+ Q_ASSERT( trackId >= 0 );
+
// Collision with an item of the same type
itemCollision = true;
- if ( currentItem->trackNumber() > track )
+ if ( trackId > track )
{
if ( track < 1 )
{
@@ -514,7 +517,7 @@ TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64
}
track -= 1;
}
- else if ( currentItem->trackNumber() <= track )
+ else if ( trackId <= track )
{
int higherTrack = 0;
if ( item->mediaType() == Workflow::VideoTrack )
@@ -790,8 +793,11 @@ TracksView::mouseMoveEvent( QMouseEvent *event )
QPointF itemPos = m_actionItem->mapToScene( 0, 0 );
QPointF itemNewSize = mapToScene( event->pos() ) - itemPos;
+ qint32 trackId = m_actionItem->trackNumber();
+ Q_ASSERT( trackId >= 0 );
+
//FIXME: BEGIN UGLY
- GraphicsTrack *track = getTrack( m_actionItem->mediaType(), m_actionItem->trackNumber() );
+ GraphicsTrack *track = getTrack( m_actionItem->mediaType(), trackId );
Q_ASSERT( track );
QPointF collidePos = track->sceneBoundingRect().topRight();
diff --git a/src/Gui/timeline/TracksView.h b/src/Gui/timeline/TracksView.h
index 392fdee..2840a78 100644
--- a/src/Gui/timeline/TracksView.h
+++ b/src/Gui/timeline/TracksView.h
@@ -306,9 +306,9 @@ private:
* \param time The new position (in frames) of the item.
* \sa moveMediaItem( const QUuid& uuid, unsigned int track, qint64 time );
*/
- void moveMediaItem( AbstractGraphicsMediaItem *item, quint32 track, qint64 time );
+ void moveMediaItem( AbstractGraphicsMediaItem *item, qint32 track, qint64 time );
- ItemPosition findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64 time );
+ ItemPosition findPosition( AbstractGraphicsMediaItem *item, qint32 track, qint64 time );
/**
* \brief Return a pointer to the specified track.
@@ -322,8 +322,8 @@ private:
int m_projectDuration;
GraphicsCursorItem *m_cursorLine;
QGraphicsLinearLayout *m_layout;
- quint32 m_numVideoTrack;
- quint32 m_numAudioTrack;
+ qint32 m_numVideoTrack;
+ qint32 m_numAudioTrack;
MainWorkflow *m_mainWorkflow;
GraphicsMovieItem *m_dragVideoItem;
GraphicsAudioItem *m_dragAudioItem;
More information about the Vlmc-devel
mailing list