Fix crash on new project:

http://kdenlive.org/mantis/view.php?id=2365

svn path=/trunk/kdenlive/; revision=6005
parent ecb88802
......@@ -46,7 +46,8 @@ ClipManager::ClipManager(KdenliveDoc *doc) :
m_audioThumbsQueue(),
m_doc(doc),
m_generatingAudioId(),
m_abortThumb(false)
m_abortThumb(false),
m_closing(false)
{
m_clipIdCounter = 1;
m_folderIdCounter = 1;
......@@ -65,6 +66,7 @@ ClipManager::ClipManager(KdenliveDoc *doc) :
ClipManager::~ClipManager()
{
m_closing = true;
m_abortThumb = true;
m_thumbsThread.waitForFinished();
m_thumbsMutex.lock();
......@@ -123,6 +125,7 @@ void ClipManager::requestThumbs(const QString id, QList <int> frames)
void ClipManager::stopThumbs(const QString &id)
{
if (m_requestedThumbs.isEmpty() || m_closing) return;
m_abortThumb = true;
m_thumbsThread.waitForFinished();
m_thumbsMutex.lock();
......@@ -149,13 +152,6 @@ void ClipManager::slotGetThumbs()
while (!values.isEmpty() && clip->thumbProducer() && !m_abortThumb) {
clip->thumbProducer()->getThumb(values.takeFirst());
}
if (m_abortThumb) {
// keep the requested frames that were not processed
m_thumbsMutex.lock();
foreach (int frame, values)
m_requestedThumbs.insertMulti(producerId, frame);
m_thumbsMutex.unlock();
}
}
}
......
......@@ -153,6 +153,8 @@ private: // Private attributes
QFuture<void> m_thumbsThread;
/** @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. */
bool m_closing;
signals:
void reloadClip(const QString &);
......
......@@ -98,6 +98,8 @@ DocClipBase::~DocClipBase()
m_audioTimer->stop();
delete m_audioTimer;
}
qDeleteAll(m_toDeleteProducers);
m_toDeleteProducers.clear();
qDeleteAll(m_baseTrackProducers);
m_baseTrackProducers.clear();
qDeleteAll(m_audioTrackProducers);
......@@ -413,7 +415,7 @@ void DocClipBase::clearThumbProducer()
void DocClipBase::deleteProducers()
{
m_thumbProd->clearProducer();
if (m_thumbProd) m_thumbProd->clearProducer();
if (numReferences() > 0) {
// Clip is used in timeline, delay producers deletion
......
......@@ -57,7 +57,7 @@ KThumb::KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QStr
KThumb::~KThumb()
{
m_clipManager->stopThumbs(m_id);
if (m_producer) m_clipManager->stopThumbs(m_id);
m_intraFramesQueue.clear();
if (m_audioThumbProducer.isRunning()) {
m_stopAudioThumbs = true;
......@@ -69,7 +69,7 @@ KThumb::~KThumb()
void KThumb::setProducer(Mlt::Producer *producer)
{
m_clipManager->stopThumbs(m_id);
if (m_producer) m_clipManager->stopThumbs(m_id);
m_intraFramesQueue.clear();
m_intra.waitForFinished();
m_mutex.lock();
......@@ -77,15 +77,16 @@ void KThumb::setProducer(Mlt::Producer *producer)
// 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();
Mlt::Profile *profile = producer->profile();
m_dar = profile->dar();
m_ratio = (double) profile->width() / profile->height();
}
m_mutex.unlock();
}
void KThumb::clearProducer()
{
setProducer(NULL);
if (m_producer) setProducer(NULL);
}
bool KThumb::hasProducer() const
......@@ -518,7 +519,7 @@ void KThumb::slotGetIntraThumbs()
if (addedThumbs) emit thumbsCached();
}
QImage KThumb::findCachedThumb(const QString path)
QImage KThumb::findCachedThumb(const QString &path)
{
QImage img;
m_clipManager->pixmapCache->findImage(path, &img);
......
......@@ -69,7 +69,7 @@ Q_OBJECT public:
/** @brief Request thumbnails for the frame range. */
void queryIntraThumbs(QList <int> missingFrames);
/** @brief Query cached thumbnail. */
QImage findCachedThumb(const QString path);
QImage findCachedThumb(const QString &path);
#endif
void getThumb(int frame);
......
......@@ -182,7 +182,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
closeTabButton->adjustSize();
closeTabButton->setToolTip(i18n("Close the current tab"));
m_timelineArea->setCornerWidget(closeTabButton);
connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
//connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
m_findTimer.setSingleShot(true);
......@@ -1903,6 +1903,7 @@ bool MainWindow::closeCurrentDocument(bool saveChanges)
}
}
m_clipMonitor->slotSetClipProducer(NULL);
m_projectList->slotResetProjectList();
m_timelineArea->removeTab(m_timelineArea->indexOf(w));
if (m_timelineArea->count() == 1) {
m_timelineArea->setTabBarHidden(true);
......@@ -2099,7 +2100,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
connectDocument(trackView, doc);
progressDialog.progressBar()->setValue(3);
qApp->processEvents();
......
......@@ -1129,7 +1129,7 @@ void ProjectList::slotGotProxy(const QString &proxyPath)
QTreeWidgetItemIterator it(m_listView);
ProjectItem *item;
while (*it) {
while (*it && !m_abortAllProxies) {
if ((*it)->type() == PROJECTCLIPTYPE) {
item = static_cast <ProjectItem *>(*it);
if (item->referencedClip()->getProperty("proxy") == proxyPath)
......@@ -1166,6 +1166,7 @@ void ProjectList::slotGotProxy(ProjectItem *item)
void ProjectList::slotResetProjectList()
{
m_listView->blockSignals(true);
m_abortAllProxies = true;
m_proxyThreads.waitForFinished();
m_proxyThreads.clearFutures();
......@@ -1175,6 +1176,7 @@ void ProjectList::slotResetProjectList()
m_refreshed = false;
m_allClipsProcessed = false;
m_abortAllProxies = false;
m_listView->blockSignals(false);
}
void ProjectList::slotUpdateClip(const QString &id)
......@@ -2396,8 +2398,8 @@ void ProjectList::slotGenerateProxy()
// Proxy process crashed
QFile::remove(info.dest);
setProxyStatus(info.dest, PROXYCRASHED);
}
}
return;
}
if (info.type == IMAGE) {
......@@ -2478,7 +2480,7 @@ void ProjectList::slotGenerateProxy()
m_abortProxy.removeAll(info.dest);
m_processingProxy.removeAll(info.dest);
QFile::remove(info.dest);
setProxyStatus(info.dest, NOPROXY);
if (!m_abortAllProxies) setProxyStatus(info.dest, NOPROXY);
result = -2;
}
......@@ -2688,7 +2690,7 @@ void ProjectList::setProxyStatus(const QString proxyPath, PROXYSTATUS status, in
if (proxyPath.isEmpty() || m_abortAllProxies) return;
QTreeWidgetItemIterator it(m_listView);
ProjectItem *item;
while (*it) {
while (*it && !m_abortAllProxies) {
if ((*it)->type() == PROJECTCLIPTYPE) {
item = static_cast <ProjectItem *>(*it);
if (item->referencedClip()->getProperty("proxy") == proxyPath) {
......
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