Fix track red background on undo track deletion

parent 052e7b00
Pipeline #3043 passed with stage
in 13 minutes and 34 seconds
......@@ -112,6 +112,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
qDebug() << "ERROR: Unexpected item in the timeline";
}
}
timeline->_resetView();
// Loading compositions
QScopedPointer<Mlt::Service> service(tractor.producer());
......
......@@ -1781,7 +1781,7 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &
TRACE(position, id, trackName, audioTrack);
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool result = requestTrackInsertion(position, id, trackName, audioTrack, undo, redo);
bool result = requestTrackInsertion(position, id, trackName, audioTrack, undo, redo, true);
if (result) {
PUSH_UNDO(undo, redo, i18n("Insert Track"));
}
......@@ -1802,11 +1802,17 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &
id = trackId;
Fun local_undo = deregisterTrack_lambda(trackId, true);
TrackModel::construct(shared_from_this(), trackId, position, trackName, audioTrack);
if (updateView) {
_resetView();
}
auto track = getTrackById(trackId);
Fun local_redo = [track, position, updateView, this]() {
// We capture a shared_ptr to the track, which means that as long as this undo object lives, the track object is not deleted. To insert it back it is
// sufficient to register it.
registerTrack(track, position, updateView);
registerTrack(track, position, true);
if (updateView) {
_resetView();
}
return true;
};
UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
......@@ -1864,6 +1870,7 @@ bool TimelineModel::requestTrackDeletion(int trackId, Fun &undo, Fun &redo)
// We capture a shared_ptr to the track, which means that as long as this undo object lives, the track object is not deleted. To insert it back it is
// sufficient to register it.
registerTrack(track, old_position);
_resetView();
return true;
};
if (operation()) {
......@@ -1875,7 +1882,7 @@ bool TimelineModel::requestTrackDeletion(int trackId, Fun &undo, Fun &redo)
return false;
}
void TimelineModel::registerTrack(std::shared_ptr<TrackModel> track, int pos, bool doInsert, bool reloadView)
void TimelineModel::registerTrack(std::shared_ptr<TrackModel> track, int pos, bool doInsert)
{
// qDebug() << "REGISTER TRACK" << track->getId() << pos;
int id = track->getId();
......@@ -1898,10 +1905,6 @@ void TimelineModel::registerTrack(std::shared_ptr<TrackModel> track, int pos, bo
// it now contains the iterator to the inserted element, we store it
Q_ASSERT(m_iteratorTable.count(id) == 0); // check that id is not used (shouldn't happen)
m_iteratorTable[id] = it;
if (reloadView) {
// don't reload view on each track load on project opening
_resetView();
}
}
void TimelineModel::registerClip(const std::shared_ptr<ClipModel> &clip, bool registerProducer)
......
......@@ -636,7 +636,7 @@ protected:
/* @brief Register a new track. This is a call-back meant to be called from TrackModel
@param pos indicates the number of the track we are adding. If this is -1, then we add at the end.
*/
void registerTrack(std::shared_ptr<TrackModel> track, int pos = -1, bool doInsert = true, bool reloadView = true);
void registerTrack(std::shared_ptr<TrackModel> track, int pos = -1, bool doInsert = true);
/* @brief Register a new clip. This is a call-back meant to be called from ClipModel
*/
......
......@@ -514,7 +514,6 @@ void TimelineController::addTrack(int tid)
m_model->requestTrackInsertion(mirrorPos, newTid2, d->trackName(), true);
}
m_model->buildTrackCompositing(true);
m_model->_resetView();
if (audioRecTrack) {
m_model->setTrackProperty(newTid, "kdenlive:audio_rec", QStringLiteral("1"));
}
......
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