Fix crash editing keyframes if something was wrong in project keyframes

Fixes #126
parent d9e7d38c
......@@ -444,3 +444,35 @@ void KeyframeModelList::resizeKeyframes(int oldIn, int oldOut, int in, int out,
}
}
}
void KeyframeModelList::checkConsistency()
{
if (m_parameters.size() < 2) {
return;
}
// Check keyframes in all parameters
QList<GenTime> fullList;
for (const auto &param : m_parameters) {
QList<GenTime> list = param.second->getKeyframePos();
for (auto &time : list) {
if (!fullList.contains(time)) {
fullList << time;
}
}
}
Fun local_update = []() { return true; };
KeyframeType type = (KeyframeType)KdenliveSettings::defaultkeyframeinterp();
for (const auto &param : m_parameters) {
QList<GenTime> list = param.second->getKeyframePos();
for (auto &time : fullList) {
if (!list.contains(time)) {
qDebug()<<" = = = \n\n = = = = \n\nWARNING; MISSING KF DETECTED AT: "<<time.seconds()<<"\n\n= = = \n\n= = =";
//TODO: add better error message after string freeze
pCore->displayMessage(i18n("Keyframe interpolation"), ErrorMessage);
QVariant missingVal = param.second->getInterpolatedValue(time);
local_update = param.second->addKeyframe_lambda(time, type, missingVal, false);
local_update();
}
}
}
}
......@@ -136,6 +136,10 @@ public:
/** @brief Parent item size change, update keyframes*/
void resizeKeyframes(int oldIn, int oldOut, int in, int out, int offset, bool adjustFromEnd, Fun &undo, Fun &redo);
/** @brief Check that all keyframable parameters have the same keyframes on loading
* (that's how our model works) */
void checkConsistency();
protected:
/** @brief Helper function to apply a given operation on all parameters */
......
......@@ -140,6 +140,10 @@ void AssetParameterModel::prepareKeyframes()
}
ix++;
}
if (m_keyframes) {
// Make sure we have keyframes at same position for all parameters
m_keyframes->checkConsistency();
}
}
void AssetParameterModel::setParameter(const QString &name, int value, bool update)
......
......@@ -82,7 +82,7 @@ const AudioEnvelope::AudioSummary &AudioEnvelope::audioSummary()
return *m_audioSummary.constBegin();
}
const size_t AudioEnvelope::offset()
size_t AudioEnvelope::offset()
{
return m_offset;
}
......
......@@ -55,7 +55,7 @@ public:
QImage drawEnvelope();
const size_t offset();
size_t offset();
void dumpInfo();
......
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