void KThumb::setProducer(Mlt::Producer *producer)
{
+ m_mutex.lock();
m_requestedThumbs.clear();
m_intraFramesQueue.clear();
m_future.waitForFinished();
m_intra.waitForFinished();
- m_mutex.lock();
m_producer = producer;
- m_mutex.unlock();
// FIXME: the profile() call leaks an object, but trying to free
// it leads to a double-free in Profile::~Profile()
if (producer) {
m_dar = producer->profile()->dar();
m_ratio = (double) producer->profile()->width() / producer->profile()->height();
}
-
+ m_mutex.unlock();
}
void KThumb::clearProducer()
if (!KdenliveSettings::videothumbnails() || m_producer == NULL) return;
if (frame != -1 && !m_requestedThumbs.contains(frame)) m_requestedThumbs.append(frame);
if (frame2 != -1 && !m_requestedThumbs.contains(frame2)) m_requestedThumbs.append(frame2);
- if (!m_future.isRunning()) m_future = QtConcurrent::run(this, &KThumb::doGetThumbs);
+ qSort(m_requestedThumbs);
+ if (!m_future.isRunning()) {
+ m_mutex.lock();
+ m_future = QtConcurrent::run(this, &KThumb::doGetThumbs);
+ m_mutex.unlock();
+ }
}
void KThumb::doGetThumbs()
//static
QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int frameWidth, int displayWidth, int height)
{
- QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied);
if (producer == NULL || !producer->is_valid()) {
- p.fill(Qt::red);
+ QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied);
+ p.fill(QColor(Qt::red).rgb());
return p;
}
if (producer->is_blank()) {
- p.fill(Qt::black);
+ QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied);
+ p.fill(QColor(Qt::black).rgb());
return p;
}
producer->seek(framepos);
Mlt::Frame *frame = producer->get_frame();
- p = getFrame(frame, frameWidth, displayWidth, height);
+ QImage p = getFrame(frame, frameWidth, displayWidth, height);
delete frame;
return p;
}
{
QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied);
if (frame == NULL || !frame->is_valid()) {
- p.fill(Qt::red);
+ p.fill(QColor(Qt::red).rgb());
return p;
}
} else {
image = image.scaled(displayWidth, height, Qt::IgnoreAspectRatio).rgbSwapped();
}
+ p.fill(QColor(Qt::black).rgb());
QPainter painter(&p);
- painter.fillRect(p.rect(), Qt::black);
- painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.drawImage(p.rect(), image);
painter.end();
} else
- p.fill(Qt::red);
+ p.fill(QColor(Qt::red).rgb());
return p;
}
if (!m_intraFramesQueue.contains(i)) m_intraFramesQueue.append(i);
}
qSort(m_intraFramesQueue);
- if (!m_intra.isRunning()) m_intra = QtConcurrent::run(this, &KThumb::slotGetIntraThumbs);
+ if (!m_intra.isRunning()) {
+ m_mutex.lock();
+ m_intra = QtConcurrent::run(this, &KThumb::slotGetIntraThumbs);
+ m_mutex.unlock();
+ }
}
void KThumb::slotGetIntraThumbs()