Commit 10a263fd authored by Nicolas Carion's avatar Nicolas Carion
Browse files

Don't invalidate preview on objects not inserted yet. Closes #64

parent 8918134c
...@@ -202,7 +202,7 @@ int TimelineModel::getCompositionTrackId(int compoId) const ...@@ -202,7 +202,7 @@ int TimelineModel::getCompositionTrackId(int compoId) const
int TimelineModel::getItemTrackId(int itemId) const int TimelineModel::getItemTrackId(int itemId) const
{ {
READ_LOCK(); READ_LOCK();
Q_ASSERT(isClip(itemId) || isComposition(itemId)); Q_ASSERT(isItem(itemId));
if (isComposition(itemId)) { if (isComposition(itemId)) {
return getCompositionTrackId(itemId); return getCompositionTrackId(itemId);
} }
...@@ -1087,7 +1087,7 @@ bool TimelineModel::requestItemDeletion(int itemId, bool logUndo) ...@@ -1087,7 +1087,7 @@ bool TimelineModel::requestItemDeletion(int itemId, bool logUndo)
{ {
QWriteLocker locker(&m_lock); QWriteLocker locker(&m_lock);
TRACE(itemId, logUndo); TRACE(itemId, logUndo);
Q_ASSERT(isClip(itemId) || isComposition(itemId)); Q_ASSERT(isItem(itemId));
QString actionLabel; QString actionLabel;
if (m_groups->isInGroup(itemId)) { if (m_groups->isInGroup(itemId)) {
actionLabel = i18n("Remove group"); actionLabel = i18n("Remove group");
...@@ -1315,7 +1315,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i ...@@ -1315,7 +1315,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
{ {
QWriteLocker locker(&m_lock); QWriteLocker locker(&m_lock);
Q_ASSERT(m_allGroups.count(groupId) > 0); Q_ASSERT(m_allGroups.count(groupId) > 0);
Q_ASSERT(isClip(itemId) || isComposition(itemId)); Q_ASSERT(isItem(itemId));
if (getGroupElements(groupId).count(itemId) == 0) { if (getGroupElements(groupId).count(itemId) == 0) {
// this group doesn't contain the clip, abort // this group doesn't contain the clip, abort
return false; return false;
...@@ -1522,7 +1522,7 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU ...@@ -1522,7 +1522,7 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
} }
QWriteLocker locker(&m_lock); QWriteLocker locker(&m_lock);
TRACE(itemId, size, right, logUndo, snapDistance, allowSingleResize); TRACE(itemId, size, right, logUndo, snapDistance, allowSingleResize);
Q_ASSERT(isClip(itemId) || isComposition(itemId)); Q_ASSERT(isItem(itemId));
if (size <= 0) { if (size <= 0) {
TRACE_RES(-1); TRACE_RES(-1);
return -1; return -1;
...@@ -1624,7 +1624,7 @@ bool TimelineModel::requestItemResize(int itemId, int size, bool right, bool log ...@@ -1624,7 +1624,7 @@ bool TimelineModel::requestItemResize(int itemId, int size, bool right, bool log
Fun local_undo = []() { return true; }; Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; }; Fun local_redo = []() { return true; };
Fun update_model = [itemId, right, logUndo, this]() { Fun update_model = [itemId, right, logUndo, this]() {
Q_ASSERT(isClip(itemId) || isComposition(itemId)); Q_ASSERT(isItem(itemId));
if (getItemTrackId(itemId) != -1) { if (getItemTrackId(itemId) != -1) {
qDebug() << "++++++++++\nRESIZING ITEM: " << itemId << "\n+++++++"; qDebug() << "++++++++++\nRESIZING ITEM: " << itemId << "\n+++++++";
QModelIndex modelIndex = isClip(itemId) ? makeClipIndexFromID(itemId) : makeCompositionIndexFromID(itemId); QModelIndex modelIndex = isClip(itemId) ? makeClipIndexFromID(itemId) : makeCompositionIndexFromID(itemId);
...@@ -2038,6 +2038,11 @@ bool TimelineModel::isComposition(int id) const ...@@ -2038,6 +2038,11 @@ bool TimelineModel::isComposition(int id) const
return m_allCompositions.count(id) > 0; return m_allCompositions.count(id) > 0;
} }
bool TimelineModel::isItem(int id) const
{
return isClip(id) || isComposition(id);
}
bool TimelineModel::isTrack(int id) const bool TimelineModel::isTrack(int id) const
{ {
return m_iteratorTable.count(id) > 0; return m_iteratorTable.count(id) > 0;
......
...@@ -220,6 +220,9 @@ public: ...@@ -220,6 +220,9 @@ public:
/* @brief Helper function that returns true if the given ID corresponds to a composition */ /* @brief Helper function that returns true if the given ID corresponds to a composition */
Q_INVOKABLE bool isComposition(int id) const; Q_INVOKABLE bool isComposition(int id) const;
/* @brief Helper function that returns true if the given ID corresponds to a timeline item (composition or clip) */
Q_INVOKABLE bool isItem(int id) const;
/* @brief Helper function that returns true if the given ID corresponds to a track */ /* @brief Helper function that returns true if the given ID corresponds to a track */
Q_INVOKABLE bool isTrack(int id) const; Q_INVOKABLE bool isTrack(int id) const;
......
...@@ -1249,7 +1249,7 @@ void TimelineController::removeSpace(int trackId, int frame, bool affectAllTrack ...@@ -1249,7 +1249,7 @@ void TimelineController::removeSpace(int trackId, int frame, bool affectAllTrack
void TimelineController::invalidateItem(int cid) void TimelineController::invalidateItem(int cid)
{ {
if (!m_timelinePreview || m_model->getItemTrackId(cid) == -1) { if (!m_timelinePreview || !m_model->isItem(cid) || m_model->getItemTrackId(cid) == -1) {
return; return;
} }
int start = m_model->getItemPosition(cid); int start = m_model->getItemPosition(cid);
......
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