From e189a9de1fe2a7646354d727b456dccf74e61b7f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 6 Jul 2011 20:19:34 +0000 Subject: [PATCH] Prevent crash when deleting a clip while playing: http://kdenlive.org/mantis/view.php?id=2200 svn path=/trunk/kdenlive/; revision=5770 --- src/clipitem.cpp | 34 +++++++--------------------------- src/kthumb.cpp | 2 +- src/projectlist.cpp | 2 ++ 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 08c03719..2af20baf 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -773,11 +773,13 @@ void ClipItem::paint(QPainter *painter, } else { #if KDE_IS_VERSION(4,5,0) - m_clip->thumbProducer()->queryIntraThumbs(left, right); - connect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache())); - QString path = m_clip->fileURL().path() + "%"; - for (int i = left; i <= right; i++) { - painter->drawImage(startPos + QPointF(twidth *(i - startOffset), 0), m_clip->thumbProducer()->findCachedThumb(path + QString::number(i))); + if (m_clip && m_clip->thumbProducer()) { + m_clip->thumbProducer()->queryIntraThumbs(left, right); + connect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache())); + QString path = m_clip->fileURL().path() + "_"; + for (int i = left; i <= right; i++) { + painter->drawImage(startPos + QPointF(twidth *(i - startOffset), 0), m_clip->thumbProducer()->findCachedThumb(path + QString::number(i))); + } } #endif } @@ -1734,28 +1736,6 @@ void ClipItem::updateKeyframes(QDomElement effect) if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1; } -/*void ClipItem::slotGetIntraThumbs(CustomTrackView *view, int start, int end) -{ - const int theight = KdenliveSettings::trackheight(); - const int twidth = FRAME_SIZE; - QString path = m_clip->fileURL().path() + "%"; - QPixmap p; - for (int i = start; i <= end; i++) { -#if KDE_IS_VERSION(4,5,0) - if (!view->m_pixmapCache->contains(path + QString::number(i))) { - p = m_clip->extractImage(i, twidth, theight); - view->m_pixmapCache->insertPixmap(path + QString::number(i), p); - } -#else - if (!view->m_pixmapCache->find(path + QString::number(i), p)) { - p = m_clip->extractImage(i, twidth, theight); - view->m_pixmapCache->insert(path + QString::number(i), p); - } -#endif - } - update(); -}*/ - Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific) { if (isAudioOnly()) diff --git a/src/kthumb.cpp b/src/kthumb.cpp index 09f8802a..6392f2b0 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -462,7 +462,7 @@ void KThumb::slotGetIntraThumbs() { int theight = KdenliveSettings::trackheight(); int twidth = FRAME_SIZE; - QString path = m_url.path() + "%"; + QString path = m_url.path() + "_"; QImage img; while (!m_intraFramesQueue.isEmpty()) { diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 03f05f84..31c7b1a3 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -911,6 +911,8 @@ void ProjectList::slotDeleteClip(const QString &clipId) if (!newSelectedItem) newSelectedItem = m_listView->itemBelow(item); delete item; + // Pause playing to prevent crash while deleting clip + slotPauseMonitor(); m_doc->clipManager()->deleteClip(clipId); m_listView->blockSignals(false); if (newSelectedItem) { -- 2.39.2