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 opening project with unknown profile

Fix crash on thumbnail after profile change, should fix #24
parent 169bed10
......@@ -374,6 +374,7 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool repl
qDebug() << "################### ProjectClip::setproducer";
QMutexLocker locker(&m_producerMutex);
updateProducer(std::move(producer));
m_thumbsProducer.reset();
connectEffectStack();
// Update info
......
......@@ -646,7 +646,7 @@ Mlt::Profile *Core::thumbProfile()
m_thumbProfile = std::unique_ptr<Mlt::Profile>(new Mlt::Profile(m_currentProfile.toStdString().c_str()));
m_thumbProfile->set_height(200);
int width = 200 * m_thumbProfile->dar();
width += width % 8;
width += 8 - width % 8;
m_thumbProfile->set_width(width);
}
return m_thumbProfile.get();
......
......@@ -1291,7 +1291,12 @@ void KdenliveDoc::loadDocumentProperties()
list = m_document.elementsByTagName(QStringLiteral("profile"));
if (!list.isEmpty()) {
std::unique_ptr<ProfileInfo> xmlProfile(new ProfileParam(list.at(0).toElement()));
profileFound = pCore->setCurrentProfile(ProfileRepository::get()->findMatchingProfile(xmlProfile.get()));
QString profilePath = ProfileRepository::get()->findMatchingProfile(xmlProfile.get());
// Document profile does not exist, create it as custom profile
if (profilePath.isEmpty()) {
profilePath = ProfileRepository::get()->saveProfile(xmlProfile.get());
}
profileFound = pCore->setCurrentProfile(profilePath);
}
}
if (!profileFound) {
......
......@@ -35,7 +35,7 @@ QPixmap getImage(const QUrl &url, int width, int height = -1);
QPixmap getImage(const QUrl &url, int frame, int width, int height = -1);
QImage getFrame(Mlt::Producer *producer, int framepos, int displayWidth, int height);
QImage getFrame(Mlt::Producer &producer, int framepos, int displayWidth, int height);
QImage getFrame(Mlt::Frame *frame, int width, int height, bool forceRescale = false);
QImage getFrame(Mlt::Frame *frame, int width = 0, int height = 0, bool forceRescale = false);
/** @brief Calculates image variance, useful to know if a thumbnail is interesting.
* @return an integer between 0 and 100. 0 means no variance, eg. black image while bigger values mean contrasted image
* */
......
......@@ -149,7 +149,7 @@ void LoadJob::checkProfile(const QString clipId, QDomElement xml, std::shared_pt
if (service == QLatin1String("qimage") || service == QLatin1String("pixbuf")) {
// This is an image, create profile from image size
int width = producer->get_int("meta.media.width");
width += width % 8;
width += 8 - width % 8;
int height = producer->get_int("meta.media.height");
height += height % 2;
if (width > 100 && height > 100) {
......
......@@ -41,6 +41,8 @@ ThumbJob::ThumbJob(const QString &binId, int imageHeight, int frameNumber, bool
, m_reloadAll(reloadAllThumbs)
, m_subClip(false)
{
//m_fullWidth += 8 - m_fullWidth % 8;
//m_imageHeight += m_imageHeight % 2;
auto item = pCore->projectItemModel()->getItemByBinId(binId);
Q_ASSERT(item->itemType() == AbstractProjectItem::ClipItem || item->itemType() == AbstractProjectItem::SubClipItem);
if (item->itemType() == AbstractProjectItem::ClipItem) {
......@@ -100,7 +102,7 @@ bool ThumbJob::startJob()
frame->set("top_field_first", -1);
frame->set("rescale.interp", "nearest");
if ((frame != nullptr) && frame->is_valid()) {
m_result = KThumb::getFrame(frame.data(), m_fullWidth, m_imageHeight, false);
m_result = KThumb::getFrame(frame.data());
m_done = true;
}
return m_done;
......
......@@ -155,7 +155,7 @@ ProfileParam::ProfileParam(QDomElement element)
int height = element.attribute(QStringLiteral("height")).toInt();
if ((width % 8) + (height % 2) > 0) {
pCore->displayBinMessage(i18n("The project profile is invalid (%1x%2), it was adjusted to %3x%4.", width, height, width + (width % 8), height + (height % 2)), KMessageWidget::Warning);
width += width % 8;
width += 8 - width % 8;
height += height % 2;
element.setAttribute(QStringLiteral("width"), width);
element.setAttribute(QStringLiteral("height"), height);
......@@ -263,7 +263,7 @@ double ProfileParam::sar() const
}
void ProfileParam::adjustDimensions()
{
m_width += m_width % 8;
m_width += 8 - m_width % 8;
m_height += m_height % 2;
}
......
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