Fix crash when opening a new document with different fps, fix new project...

Fix crash when opening a new document with different fps, fix new project dialog showing wrong default profile
parent e8d71cb3
......@@ -50,7 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KToolBar>
#include <KColorScheme>
#include <KMessageBox>
#include <KMessageBox>
#include <KXMLGUIFactory>
#include <QDialogButtonBox>
......@@ -853,6 +852,7 @@ void Bin::setDocument(KdenliveDoc* project)
{
// Remove clip from Bin's monitor
if (m_doc) emit openClip(NULL);
m_infoMessage->hide();
setEnabled(false);
// Cleanup previous project
......@@ -3052,7 +3052,7 @@ bool Bin::isEmpty() const
void Bin::reloadAllProducers()
{
if (m_rootFolder == NULL || m_rootFolder->isEmpty()) return;
if (m_rootFolder == NULL || m_rootFolder->isEmpty() || !isEnabled()) return;
QList <ProjectClip*> clipList = m_rootFolder->childClips();
emit openClip(NULL);
foreach(ProjectClip *clip, clipList) {
......
......@@ -246,7 +246,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
m_url.clear();
m_profile = ProfilesDialog::getVideoProfile(profileName);
m_document = createEmptyDocument(tracks.x(), tracks.y());
updateProjectProfile();
updateProjectProfile(false);
}
// Ask to create the project directory if it does not exist
......@@ -1539,10 +1539,10 @@ void KdenliveDoc::loadDocumentProperties()
if (!list.isEmpty()) {
m_profile = ProfilesDialog::getVideoProfileFromXml(list.at(0).toElement());
}
updateProjectProfile();
updateProjectProfile(false);
}
void KdenliveDoc::updateProjectProfile()
void KdenliveDoc::updateProjectProfile(bool reloadProducers)
{
KdenliveSettings::setProject_display_ratio((double) m_profile.display_aspect_num / m_profile.display_aspect_den);
double fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
......@@ -1553,6 +1553,7 @@ void KdenliveDoc::updateProjectProfile()
m_timecode.setFormat(fps);
KdenliveSettings::setCurrent_profile(m_profile.path);
pCore->monitorManager()->resetProfiles(m_profile, m_timecode);
if (!reloadProducers) return;
if (fpsChanged) {
pCore->bin()->reloadAllProducers();
}
......@@ -1562,7 +1563,7 @@ void KdenliveDoc::updateProjectProfile()
void KdenliveDoc::resetProfile()
{
m_profile = ProfilesDialog::getVideoProfile(KdenliveSettings::current_profile());
updateProjectProfile();
updateProjectProfile(true);
emit docModified(true);
}
......@@ -1576,7 +1577,7 @@ void KdenliveDoc::switchProfile(MltVideoProfile profile, const QString &id, cons
QMap< QString, QString > profileProperties = ProfilesDialog::getSettingsFromFile(matchingProfile);
m_profile.path = matchingProfile;
m_profile.description = profileProperties.value("description");
updateProjectProfile();
updateProjectProfile(true);
pCore->bin()->displayMessage(i18n("Switched to clip profile: %1", m_profile.description), KMessageWidget::Information);
emit docModified(true);
} else {
......@@ -1585,7 +1586,7 @@ void KdenliveDoc::switchProfile(MltVideoProfile profile, const QString &id, cons
m_profile = profile;
m_profile.description = QString("%1x%2 %3fps").arg(profile.width).arg(profile.height).arg(QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2));
ProfilesDialog::saveProfile(m_profile);
updateProjectProfile();
updateProjectProfile(true);
pCore->bin()->displayMessage(i18n("Switched to clip profile: %1", m_profile.description), KMessageWidget::Information);
emit docModified(true);
}
......
......@@ -198,7 +198,7 @@ private:
/** @brief Load document properties from the xml file */
void loadDocumentProperties();
/** @brief update document properties to reflect a change in the current profile */
void updateProjectProfile();
void updateProjectProfile(bool reloadProducers = false);
public slots:
void slotCreateTextTemplateClip(const QString &group, const QString &groupId, QUrl path);
......
......@@ -65,7 +65,9 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
connect(generate_proxy, SIGNAL(toggled(bool)), proxy_minsize, SLOT(setEnabled(bool)));
connect(generate_imageproxy, SIGNAL(toggled(bool)), proxy_imageminsize, SLOT(setEnabled(bool)));
QString currentProf;
if (doc) {
currentProf = KdenliveSettings::current_profile();
enable_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("enableproxy")).toInt());
generate_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateproxy")).toInt());
proxy_minsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyminsize")).toInt());
......@@ -75,6 +77,7 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
m_proxyextension = doc->getDocumentProperty(QStringLiteral("proxyextension"));
}
else {
currentProf = KdenliveSettings::default_profile();
enable_proxy->setChecked(KdenliveSettings::enableproxy());
generate_proxy->setChecked(KdenliveSettings::generateproxy());
proxy_minsize->setValue(KdenliveSettings::proxyminsize());
......@@ -83,6 +86,13 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
proxy_imageminsize->setValue(KdenliveSettings::proxyimageminsize());
m_proxyextension = KdenliveSettings::proxyextension();
}
// Select profile
for (int i = 0; i < profiles_list->count(); ++i) {
if (profiles_list->itemData(i).toString() == currentProf) {
profiles_list->setCurrentIndex(i);
break;
}
}
proxy_minsize->setEnabled(generate_proxy->isChecked());
proxy_imageminsize->setEnabled(generate_imageproxy->isChecked());
......@@ -640,22 +650,20 @@ void ProjectSettings::loadProfiles()
i.next();
profiles_list->addItem(i.key(), i.value());
}
QString currentProf = KdenliveSettings::current_profile();
for (int i = 0; i < profiles_list->count(); ++i) {
if (profiles_list->itemData(i).toString() == currentProf) {
profiles_list->setCurrentIndex(i);
break;
}
}
}
void ProjectSettings::slotEditProfiles()
{
ProfilesDialog *w = new ProfilesDialog;
w->exec();
QString currentProf = profiles_list->currentData().toString();
loadProfiles();
for (int i = 0; i < profiles_list->count(); ++i) {
if (profiles_list->itemData(i).toString() == currentProf) {
profiles_list->setCurrentIndex(i);
break;
}
}
emit refreshProfiles();
delete w;
}
......
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