Commit 9fee60cd authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

fix crash on document open.

Related to #1571
parent bdd6a8dc
......@@ -370,10 +370,11 @@ void KdenliveDoc::initializeProperties(bool newDocument)
}
}
const QStringList KdenliveDoc::guidesCategories() const
const QStringList KdenliveDoc::guidesCategories()
{
if (!m_documentProperties.contains(QStringLiteral("guidesCategories")) || m_documentProperties.value(QStringLiteral("guidesCategories")).isEmpty()) {
return getDefaultGuideCategories();
const QString defaultCategories = getDefaultGuideCategories().join(QLatin1Char('\n'));
m_documentProperties[QStringLiteral("guidesCategories")] = defaultCategories;
}
return m_documentProperties.value(QStringLiteral("guidesCategories")).split(QLatin1Char('\n'));
}
......@@ -1548,8 +1549,7 @@ void KdenliveDoc::loadDocumentProperties()
if (!profileFound) {
qDebug() << "ERROR, no matching profile found";
}
const QStringList guideCategories = m_documentProperties.value(QStringLiteral("guidesCategories")).split(QLatin1Char('\n'));
m_guideModel->loadCategories(guideCategories);
m_guideModel->loadCategories(guidesCategories());
updateProjectProfile(false);
}
......
......@@ -216,7 +216,7 @@ public:
/** @brief Ensure we don't have leftover preview chunks (created after last save */
void cleanupTimelinePreview(const QDateTime &documentDate);
/** @brief Returns the guides categories for the project in format {name:index:#color} */
const QStringList guidesCategories() const;
const QStringList guidesCategories();
/** @brief Set the guides categories for the project in format {name:index:#color} */
void updateGuideCategories(const QStringList &categories, const QMap<int, int> remapCategories = {});
/** @brief Setup a filter to visible guides */
......
......@@ -339,6 +339,10 @@ void GuidesList::setModel(std::weak_ptr<MarkerListModel> model, std::shared_ptr<
void GuidesList::rebuildCategories()
{
if (pCore->markerTypes.isEmpty()) {
// Categories are not ready, abort
return;
}
QPixmap pixmap(32, 32);
// Cleanup default marker category menu
QMenu *markerDefaultMenu = default_category->menu();
......
Supports Markdown
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