Commit 27844e35 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix crash closing document with grouped subtitles

parent 3a77973e
......@@ -1670,7 +1670,7 @@ void Bin::setMonitor(Monitor *monitor)
});
}
void Bin::setDocument(KdenliveDoc *project)
void Bin::cleanDocument()
{
blockSignals(true);
if (m_proxyModel) {
......@@ -1684,6 +1684,10 @@ void Bin::setDocument(KdenliveDoc *project)
m_itemModel->clean();
delete m_itemView;
m_itemView = nullptr;
}
void Bin::setDocument(KdenliveDoc *project)
{
m_doc = project;
m_infoLabel->slotSetJobCount(0);
int iconHeight = QFontInfo(font()).pixelSize() * 3.5;
......@@ -4105,9 +4109,9 @@ void Bin::setCurrent(const std::shared_ptr<AbstractProjectItem> &item)
}
}
void Bin::cleanup()
void Bin::cleanupUnused()
{
m_itemModel->requestCleanup();
m_itemModel->requestCleanupUnused();
}
std::shared_ptr<EffectStackModel> Bin::getClipEffectStack(int itemId)
......
......@@ -178,6 +178,8 @@ public:
/** @brief Sets the document for the bin and initialize some stuff */
void setDocument(KdenliveDoc *project);
/** @brief Delete all project related data, to be called before setDocument */
void cleanDocument();
/** @brief Create a clip item from its xml description */
void createClip(const QDomElement &xml);
......@@ -298,7 +300,7 @@ public:
QList<int> getUsedClipIds();
// TODO refac: remove this and call directly the function in ProjectItemModel
void cleanup();
void cleanupUnused();
void selectAll();
private slots:
......
......@@ -853,7 +853,7 @@ bool ProjectItemModel::requestRenameFolder(std::shared_ptr<AbstractProjectItem>
return res;
}
bool ProjectItemModel::requestCleanup()
bool ProjectItemModel::requestCleanupUnused()
{
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
......
......@@ -185,7 +185,7 @@ public:
bool requestRenameFolder(std::shared_ptr<AbstractProjectItem> folder, const QString &name);
/* @brief Request that the unused clips are deleted */
bool requestCleanup();
bool requestCleanupUnused();
/* @brief Retrieves the next id available for attribution to a folder */
int getFreeFolderId();
......
......@@ -2149,7 +2149,7 @@ void MainWindow::slotCleanProject()
KMessageBox::Cancel) {
return;
}
pCore->bin()->cleanup();
pCore->bin()->cleanupUnused();
}
void MainWindow::slotUpdateMousePosition(int pos)
......
......@@ -218,6 +218,7 @@ void ProjectManager::newFile(QString profileName, bool showProjectSettings)
}
bool openBackup;
m_notesPlugin->clear();
pCore->bin()->cleanDocument();
KdenliveDoc *doc = new KdenliveDoc(QUrl(), projectFolder, pCore->window()->m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, audioChannels, &openBackup, pCore->window());
doc->m_autosave = new KAutoSaveFile(startFile, doc);
ThumbnailCache::get()->clearCache();
......@@ -269,16 +270,21 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
pCore->jobManager()->slotCancelJobs();
disconnect(pCore->window()->getMainTimeline()->controller(), &TimelineController::durationChanged, this, &ProjectManager::adjustProjectDuration);
pCore->window()->getMainTimeline()->controller()->clipActions.clear();
if (!quit && !qApp->isSavingSession()) {
m_autoSaveTimer.stop();
if (m_project) {
pCore->jobManager()->slotCancelJobs();
pCore->bin()->abortOperations();
}
}
pCore->window()->getMainTimeline()->controller()->prepareClose();
pCore->bin()->cleanDocument();
pCore->window()->resetSubtitles();
if (m_mainTimelineModel) {
m_mainTimelineModel->prepareClose();
}
if (!quit && !qApp->isSavingSession()) {
m_autoSaveTimer.stop();
if (m_project) {
pCore->jobManager()->slotCancelJobs();
pCore->bin()->abortOperations();
pCore->monitorManager()->clipMonitor()->slotOpenClip(nullptr);
emit pCore->window()->clearAssetPanel();
delete m_project;
......
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