Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix crash dragging clip when timeline preview is enabled

parent c6d155d7
......@@ -664,3 +664,4 @@ QPair<QStringList, QStringList> PreviewManager::previewChunks() const
}
return {renderedChunks, dirtyChunks};
}
......@@ -86,6 +86,9 @@ public:
int workingPreview;
/** @brief Returns the list of existing chunks */
QPair<QStringList, QStringList> previewChunks() const;
bool hasOverlayTrack() const;
bool hasPreviewTrack() const;
int addedTracks() const;
private:
TimelineController *m_controller;
......
......@@ -61,7 +61,7 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
, m_timelineEffectsEnabled(true)
, m_id(getNextId())
, m_temporarySelectionGroup(-1)
, m_overlayTrackIndex(-1)
, m_overlayTrackCount(-1)
{
// Create black background track
m_blackClip->set("id", "black_track");
......@@ -100,8 +100,8 @@ int TimelineModel::getTracksCount() const
{
READ_LOCK();
int count = m_tractor->count();
if (m_overlayTrackIndex > -1) {
count --;
if (m_overlayTrackCount > -1) {
count -= m_overlayTrackCount;
}
Q_ASSERT(count >= 0);
// don't count the black background track
......
......@@ -593,7 +593,7 @@ protected:
int m_temporarySelectionGroup;
// The index of the temporary overlay track in tractor, or -1 if not connected
int m_overlayTrackIndex;
int m_overlayTrackCount;
// what follows are some virtual function that corresponds to the QML. They are implemented in TimelineItemModel
protected:
......
......@@ -664,3 +664,26 @@ QPair<QStringList, QStringList> PreviewManager::previewChunks() const
}
return {renderedChunks, dirtyChunks};
}
bool PreviewManager::hasOverlayTrack() const
{
return m_overlayTrack != nullptr;
}
bool PreviewManager::hasPreviewTrack() const
{
return m_previewTrack != nullptr;
}
int PreviewManager::addedTracks() const
{
if (m_previewTrack) {
if (m_overlayTrack) {
return 2;
}
return 1;
} else if (m_overlayTrack) {
return 1;
}
return -1;
}
......@@ -86,6 +86,9 @@ public:
int workingPreview;
/** @brief Returns the list of existing chunks */
QPair<QStringList, QStringList> previewChunks() const;
bool hasOverlayTrack() const;
bool hasPreviewTrack() const;
int addedTracks() const;
private:
TimelineController *m_controller;
......
......@@ -700,7 +700,7 @@ void TimelineController::setHeaderWidth(int width)
bool TimelineController::createSplitOverlay(Mlt::Filter *filter)
{
if (m_model->m_overlayTrackIndex > -1) {
if (m_timelinePreview && m_timelinePreview->hasOverlayTrack()) {
return true;
}
int clipId = getCurrentItem();
......@@ -743,19 +743,20 @@ bool TimelineController::createSplitOverlay(Mlt::Filter *filter)
if (!m_timelinePreview) {
initializePreview();
}
m_model->m_overlayTrackIndex = m_timelinePreview->setOverlayTrack(overlay);
m_timelinePreview->setOverlayTrack(overlay);
m_model->m_overlayTrackCount = m_timelinePreview->addedTracks();
return true;
}
void TimelineController::removeSplitOverlay()
{
if (m_model->m_overlayTrackIndex == -1) {
if (m_timelinePreview && !m_timelinePreview->hasOverlayTrack()) {
return;
}
// disconnect
m_timelinePreview->removeOverlayTrack();
m_model->m_overlayTrackIndex = -1;
m_model->m_overlayTrackCount = m_timelinePreview->addedTracks();
}
void TimelineController::addPreviewRange(bool add)
......@@ -786,6 +787,7 @@ void TimelineController::startPreviewRender()
m_timelinePreview->buildPreviewTrack();
qDebug()<<"// STARTING PREVIEW TRACK";
m_usePreview = true;
m_model->m_overlayTrackCount = m_timelinePreview->addedTracks();
}
m_timelinePreview->startPreviewRender();
}
......@@ -835,6 +837,7 @@ void TimelineController::disablePreview(bool disable)
if (disable) {
m_timelinePreview->deletePreviewTrack();
m_usePreview = false;
m_model->m_overlayTrackCount = m_timelinePreview->addedTracks();
} else {
if (!m_usePreview) {
if (!m_timelinePreview->buildPreviewTrack()) {
......@@ -847,6 +850,7 @@ void TimelineController::disablePreview(bool disable)
m_usePreview = true;
}
}
m_model->m_overlayTrackCount = m_timelinePreview->addedTracks();
}
QVariantList TimelineController::dirtyChunks() const
......
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