ClipItem::~ClipItem()
{
blockSignals(true);
+ m_endThumbTimer.stop();
+ m_startThumbTimer.stop();
if (scene()) scene()->removeItem(this);
if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
//disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
if (!frames.isEmpty()) m_clip->slotExtractImage(frames);
}
+void ClipItem::stopThumbs()
+{
+ // Clip is about to be deleted, make sure we don't request thumbnails
+ disconnect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
+ disconnect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
+}
+
void ClipItem::slotGetStartThumb()
{
m_startThumbRequested = true;
* Which producer is returned depends on the type of this clip (audioonly, videoonly, normal) */
Mlt::Producer *getProducer(int track, bool trackSpecific = true);
void resetFrameWidth(int width);
+ /** @brief Clip is about to be deleted, block thumbs. */
+ void stopThumbs();
protected:
//virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
void ClipManager::stopThumbs(const QString &id)
{
- if (m_closing || (m_requestedThumbs.isEmpty() && m_audioThumbsQueue.isEmpty() && m_processingAudioThumbId != id)) return;
-
+ if (m_closing || (m_requestedThumbs.isEmpty() && m_processingThumbId != id && m_audioThumbsQueue.isEmpty() && m_processingAudioThumbId != id)) return;
// Abort video thumbs for this clip
m_abortThumb = true;
m_thumbsThread.waitForFinished();
while (!m_requestedThumbs.isEmpty() && !m_abortThumb) {
m_thumbsMutex.lock();
i = m_requestedThumbs.constBegin();
- QString producerId = i.key();
- QList<int> values = m_requestedThumbs.values(producerId);
- m_requestedThumbs.remove(producerId);
+ m_processingThumbId = i.key();
+ QList<int> values = m_requestedThumbs.values(m_processingThumbId);
+ m_requestedThumbs.remove(m_processingThumbId);
m_thumbsMutex.unlock();
qSort(values);
- DocClipBase *clip = getClipById(producerId);
+ DocClipBase *clip = getClipById(m_processingThumbId);
if (!clip) continue;
max = m_requestedThumbs.size() + values.count();
while (!values.isEmpty() && clip->thumbProducer() && !m_abortThumb) {
if (max > 3) emit displayMessage(i18n("Loading thumbnails"), 100 * done / max);
}
}
+ m_processingThumbId.clear();
emit displayMessage(QString(), -1);
}
QMap <QString, int> m_requestedThumbs;
QMutex m_thumbsMutex;
QFuture<void> m_thumbsThread;
+ /** @brief The id of currently processed clip for thumbs creation. */
+ QString m_processingThumbId;
/** @brief If true, abort processing of clip thumbs before removing a clip. */
bool m_abortThumb;
/** @brief We are about to delete the clip producer, stop processing thumbs. */
emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
kDebug()<<"CANNOT REMOVE: "<<info.startPos.frames(m_document->fps())<<", TK: "<<info.track;
//m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
- exit(1);
return;
}
m_waitingThumbs.removeAll(item);
+ item->stopThumbs();
if (item->isSelected()) emit clipItemSelected(NULL);
item->baseClip()->removeReference();
m_document->updateClip(item->baseClip()->getId());
emit displayMessage(i18n("Waiting for clip..."), InformationMessage);
emit forceClipProcessing(clipId);
qApp->processEvents();
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 10; i++) {
if (baseclip->getProducer() == NULL) {
- m_producerNotReady.wait(&m_mutex, 500 + 500 * i);
+ qApp->processEvents();
+ m_producerNotReady.wait(&m_mutex, 200);
} else break;
}
if (baseclip->getProducer() == NULL) {
{
m_audioTimer.stop();
delete m_thumbProd;
+ m_thumbProd = NULL;
qDeleteAll(m_toDeleteProducers);
m_toDeleteProducers.clear();
qDeleteAll(m_baseTrackProducers);
#include <QtConcurrentRun>
#include <QVarLengthArray>
-KThumb::KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent, const char */*name*/) :
+KThumb::KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent) :
QObject(parent),
m_url(url),
m_thumbFile(),
KThumb::~KThumb()
{
if (m_producer) m_clipManager->stopThumbs(m_id);
+ m_producer = NULL;
m_intraFramesQueue.clear();
m_intra.waitForFinished();
}
Q_OBJECT public:
- KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent = 0, const char *name = 0);
+ KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent = 0);
~KThumb();
void setProducer(Mlt::Producer *producer);
bool hasProducer() const;
void Render::forceProcessing(const QString &id)
{
+ if (m_processingClipId == id) return;
m_infoMutex.lock();
for (int i = 0; i < m_requestList.count(); i++) {
requestClipInfo info = m_requestList.at(i);