Commit 9353f7fa authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix crash closing project with locked tracks. Fixes #177

parent fc81e165
Pipeline #3363 passed with stage
in 18 minutes and 40 seconds
......@@ -53,6 +53,7 @@ the Free Software Foundation, either version 3 of the License, or
ProjectManager::ProjectManager(QObject *parent)
: QObject(parent)
, m_mainTimelineModel(nullptr)
{
m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), pCore->window()->actionCollection());
......@@ -239,6 +240,9 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
}
}
pCore->window()->getMainTimeline()->controller()->clipActions.clear();
if (m_mainTimelineModel) {
m_mainTimelineModel->prepareClose();
}
if (!quit && !qApp->isSavingSession()) {
m_autoSaveTimer.stop();
if (m_project) {
......
......@@ -117,6 +117,7 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
, m_videoTarget(-1)
, m_editMode(TimelineMode::NormalEdit)
, m_blockRefresh(false)
, m_closing(false)
{
// Create black background track
m_blackClip->set("id", "black_track");
......@@ -130,6 +131,17 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
TRACE_CONSTR(this);
}
void TimelineModel::prepareClose()
{
Please register or sign in to reply
// Unlock all tracks to allow delting clip from tracks
m_closing = true;
auto it = m_allTracks.begin();
while (it != m_allTracks.end()) {
(*it)->setProperty(QStringLiteral("kdenlive:locked_track"), (char*) nullptr);
++it;
}
}
TimelineModel::~TimelineModel()
{
std::vector<int> all_ids;
......@@ -1342,7 +1354,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
int p2 = m_allClips[clipId2]->getPosition();
return delta_pos > 0 ? p2 <= p1 : p1 <= p2;
});
// Sort compositions. We need to delete in the move direction from top to bottom
std::vector<int> sorted_compositions(all_compositions.begin(), all_compositions.end());
std::sort(sorted_compositions.begin(), sorted_compositions.end(), [this, delta_track, delta_pos](int clipId1, int clipId2) {
......@@ -2092,6 +2104,9 @@ bool TimelineModel::isGroup(int id) const
void TimelineModel::updateDuration()
{
if (m_closing) {
return;
}
int current = m_blackClip->get_playtime() - TimelineModel::seekDuration;
int duration = 0;
for (const auto &tck : m_iteratorTable) {
......
......@@ -632,6 +632,9 @@ public:
/** @brief Returns a set containing all the items in the selection */
std::unordered_set<int> getCurrentSelection() const;
/** @brief Do some cleanup before closing */
void prepareClose();
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.
......@@ -775,6 +778,7 @@ protected:
int m_videoTarget;
// Timeline editing mode
TimelineMode::EditMode m_editMode;
bool m_closing;
// what follows are some virtual function that corresponds to the QML. They are implemented in TimelineItemModel
protected:
......
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