Fix crash after extract / zone lift

parent a505751e
......@@ -821,6 +821,7 @@ bool TimelineModel::requestClipDeletion(int clipId, Fun &undo, Fun &redo)
return true;
};
if (operation()) {
emit removeFromSelection(clipId);
UPDATE_UNDO_REDO(operation, reverse, undo, redo);
return true;
}
......@@ -849,6 +850,7 @@ bool TimelineModel::requestCompositionDeletion(int compositionId, Fun &undo, Fun
return true;
};
if (operation()) {
emit removeFromSelection(compositionId);
UPDATE_UNDO_REDO(operation, reverse, undo, redo);
return true;
}
......
......@@ -646,6 +646,8 @@ signals:
void invalidateZone(int in, int out);
/* @brief signal triggered when a track duration changed (insertion/deletion) */
void durationUpdated();
/* @brief an item was deleted, make sure it is removed from selection */
void removeFromSelection(int id);
protected:
std::unique_ptr<Mlt::Tractor> m_tractor;
......
......@@ -281,12 +281,6 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool fin
Q_ASSERT(!m_playlists[target_track].is_blank(target_clip));
auto prod = m_playlists[target_track].replace_with_blank(target_clip);
if (prod != nullptr) {
if (finalMove && !audioOnly && !isAudioTrack()) {
if (auto ptr = m_parent.lock()) {
// qDebug() << "/// INVALIDATE CLIP ON DELETE!!!!!!";
ptr->invalidateZone(old_in, old_out);
}
}
m_playlists[target_track].consolidate_blanks();
m_allClips[clipId]->setCurrentTrackId(-1);
m_allClips.erase(clipId);
......@@ -295,9 +289,14 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool fin
if (auto ptr = m_parent.lock()) {
ptr->m_snaps->removePoint(old_in);
ptr->m_snaps->removePoint(old_out);
if (finalMove && target_clip >= m_playlists[target_track].count()) {
// deleted last clip in playlist
ptr->updateDuration();
if (finalMove) {
if (!audioOnly && !isAudioTrack()) {
ptr->invalidateZone(old_in, old_out);
}
if (target_clip >= m_playlists[target_track].count()) {
// deleted last clip in playlist
ptr->updateDuration();
}
}
if (!audioOnly && !isHidden() && !isAudioTrack()) {
// only refresh monitor if not an audio track and not hidden
......
......@@ -84,6 +84,7 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
connect(m_model.get(), &TimelineItemModel::requestMonitorRefresh, [&]() { pCore->requestMonitorRefresh(); });
connect(m_model.get(), &TimelineModel::invalidateZone, this, &TimelineController::invalidateZone, Qt::DirectConnection);
connect(m_model.get(), &TimelineModel::durationUpdated, this, &TimelineController::checkDuration);
connect(m_model.get(), &TimelineModel::removeFromSelection, this, &TimelineController::slotUpdateSelection);
}
void TimelineController::setTargetTracks(QPair<int, int> targets)
......@@ -407,6 +408,14 @@ void TimelineController::deleteSelectedClips()
emit selectionChanged();
}
void TimelineController::slotUpdateSelection(int itemId)
{
if (m_selection.selectedItems.contains(itemId)) {
m_selection.selectedItems.removeAll(itemId);
emit selectionChanged();
}
}
void TimelineController::copyItem()
{
int clipId = -1;
......
......@@ -392,6 +392,9 @@ public slots:
void invalidateZone(int in, int out);
void checkDuration();
private slots:
void slotUpdateSelection(int itemId);
private:
QQuickItem *m_root;
KActionCollection *m_actionCollection;
......
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