Commit 32788093 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle Committed by Vincent PINON

Fix crash on quick undo/redo: issue #3240

Conflicts:
	src/projectlist.cpp
parent 5a491def
......@@ -4572,6 +4572,11 @@ void CustomTrackView::doGroupClips(QList <ItemInfo> clipInfos, QList <ItemInfo>
setDocumentModified();
}
void CustomTrackView::slotInfoProcessingFinished()
{
m_producerNotReady.wakeAll();
}
void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList effects, bool overwrite, bool push, bool refresh)
{
DocClipBase *baseclip = m_document->clipManager()->getClipById(clipId);
......@@ -4582,14 +4587,19 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
if (baseclip->getProducer() == NULL) {
// If the clip has no producer, we must wait until it is created...
m_mutex.lock();
emit displayMessage(i18n("Waiting for clip..."), InformationMessage);
emit forceClipProcessing(clipId);
qApp->processEvents();
m_document->renderer()->forceProcessing(clipId);
m_mutex.lock();
for (int i = 0; i < 10; ++i) {
baseclip = m_document->clipManager()->getClipById(clipId);
if (baseclip == NULL) {
emit displayMessage(i18n("Cannot insert clip..."), ErrorMessage);
m_mutex.unlock();
return;
}
if (baseclip->getProducer() == NULL) {
qApp->processEvents();
m_producerNotReady.wait(&m_mutex, 200);
m_producerNotReady.wait(&m_mutex);
} else break;
}
if (baseclip->getProducer() == NULL) {
......
......@@ -302,6 +302,8 @@ public slots:
static void adjustEffectParameters(EffectsParameterList &parameters, QDomNodeList params, MltVideoProfile profile, const QString &prefix = QString());
/** @brief Move playhead to mouse curser position if defined key is pressed */
void slotAlignPlayheadToMousePos();
void slotInfoProcessingFinished();
protected:
virtual void drawBackground(QPainter * painter, const QRectF & rect);
......@@ -521,7 +523,6 @@ signals:
void playMonitor();
/** @brief Monitor document changes (for example the presence of audio data in timeline for export widget.*/
void documentModified();
void forceClipProcessing(const QString &);
void showTrackEffects(int, TrackInfo);
/** @brief Update the track effect button that shows if a track has effects or not.*/
void updateTrackEffectState(int);
......
......@@ -949,7 +949,7 @@ void MainWindow::slotConnectMonitors()
connect(m_projectMonitor->render, SIGNAL(replyGetImage(QString,QString,int,int)), m_projectList, SLOT(slotReplyGetImage(QString,QString,int,int)));
connect(m_projectMonitor->render, SIGNAL(replyGetImage(QString,QImage)), m_projectList, SLOT(slotReplyGetImage(QString,QImage)));
connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(QString,Mlt::Producer*,stringMap,stringMap,bool)), m_projectList, SLOT(slotReplyGetFileProperties(QString,Mlt::Producer*,stringMap,stringMap,bool)));
connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(QString,Mlt::Producer*,stringMap,stringMap,bool)), m_projectList, SLOT(slotReplyGetFileProperties(QString,Mlt::Producer*,stringMap,stringMap,bool)), Qt::DirectConnection);
connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(QString,bool)), m_projectList, SLOT(slotRemoveInvalidClip(QString,bool)));
......@@ -2722,6 +2722,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
disconnect(m_projectList, SIGNAL(refreshClip(QString)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(QString)));
disconnect(m_projectList, SIGNAL(addMarkers(QString,QList<CommentedTime>)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(QString,QList<CommentedTime>)));
disconnect(m_projectMonitor->render, SIGNAL(infoProcessingFinished()), m_activeTimeline->projectView(), SLOT(slotInfoProcessingFinished()));
m_effectStack->clear();
}
//m_activeDocument->setRenderer(NULL);
......@@ -2742,7 +2743,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
connect(trackView->projectView(), SIGNAL(forceClipProcessing(QString)), m_projectList, SLOT(slotForceProcessing(QString)));
connect(m_projectMonitor->render, SIGNAL(infoProcessingFinished()), trackView->projectView(), SLOT(slotInfoProcessingFinished()), Qt::DirectConnection);
connect(trackView->projectView(), SIGNAL(importKeyframes(GraphicsRectItem,QString,int)), this, SLOT(slotProcessImportKeyframes(GraphicsRectItem,QString,int)));
......
......@@ -1664,7 +1664,7 @@ QString ProjectList::getExtensions()
mimeTypes << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "audio/x-aiff" << "audio/aiff" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash" << "audio/ac3";
// Image mimes
mimeTypes << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
mimeTypes << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr" << "image/x-portable-pixmap";
QString allExtensions;
foreach(const QString & mimeType, mimeTypes) {
......@@ -2280,6 +2280,9 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
if (item && producer) {
monitorItemEditing(false);
DocClipBase *clip = item->referencedClip();
if (clip->getProducer() == NULL && replace) {
replace = false;
}
if (producer->is_valid()) {
if (clip->isPlaceHolder()) {
clip->setValid();
......
......@@ -661,20 +661,42 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, in
void Render::forceProcessing(const QString &id)
{
if (m_processingClipId.contains(id)) return;
QMutexLocker lock(&m_infoMutex);
for (int i = 0; i < m_requestList.count(); ++i) {
requestClipInfo info = m_requestList.at(i);
if (info.clipId == id) {
if (i == 0) {
break;
} else {
m_requestList.removeAt(i);
m_requestList.prepend(info);
break;
}
// Make sure we load the clip producer now so that we can use it in timeline
QList <requestClipInfo> requestListCopy;
if (m_processingClipId.contains(id)) {
m_infoMutex.lock();
requestListCopy = m_requestList;
m_requestList.clear();
m_infoMutex.unlock();
m_infoThread.waitForFinished();
emit infoProcessingFinished();
} else {
m_infoMutex.lock();
for (int i = 0; i < m_requestList.count(); ++i) {
requestClipInfo info = m_requestList.at(i);
if (info.clipId == id) {
m_requestList.removeAt(i);
requestListCopy = m_requestList;
m_requestList.clear();
m_requestList.append(info);
break;
}
}
m_infoMutex.unlock();
if (!m_infoThread.isRunning()) {
m_infoThread = QtConcurrent::run(this, &Render::processFileProperties);
}
m_infoThread.waitForFinished();
emit infoProcessingFinished();
}
m_infoMutex.lock();
m_requestList.append(requestListCopy);
m_infoMutex.unlock();
if (!m_infoThread.isRunning()) {
m_infoThread = QtConcurrent::run(this, &Render::processFileProperties);
}
}
int Render::processingItems()
......@@ -781,7 +803,6 @@ void Render::processFileProperties()
continue;
}
}
if (info.xml.hasAttribute("force_aspect_ratio")) {
double aspect = info.xml.attribute("force_aspect_ratio").toDouble();
if (aspect > 0) producer->set("force_aspect_ratio", aspect);
......
......@@ -483,6 +483,7 @@ signals:
/** @brief Activate current monitor. */
void activateMonitor(Kdenlive::MonitorId);
void mltFrameReceived(Mlt::Frame *);
void infoProcessingFinished();
public slots:
......
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