]> git.sesse.net Git - kdenlive/commitdiff
Fix crash on clip deletion, fix issues with placeholder clips
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 19 Jan 2010 02:48:42 +0000 (02:48 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 19 Jan 2010 02:48:42 +0000 (02:48 +0000)
svn path=/trunk/kdenlive/; revision=4236

src/clipitem.cpp
src/clipmanager.cpp
src/customtrackview.cpp
src/docclipbase.cpp
src/docclipbase.h
src/documentchecker.cpp
src/effectstackview.cpp
src/projectitem.cpp
src/projectlist.cpp
src/projectlist.h

index 05dbb2feb156e75e99f70051f7f3ef9fbc1fd5ed..1aa2b203dcbd674b8ffb9a69edc65ad7d9c08e57 100644 (file)
@@ -83,17 +83,19 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
 
     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
         m_baseColor = QColor(141, 166, 215);
-        m_hasThumbs = true;
-        m_startThumbTimer.setSingleShot(true);
-        connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
-        m_endThumbTimer.setSingleShot(true);
-        connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
+        if (!m_clip->isPlaceHolder()) {
+            m_hasThumbs = true;
+            m_startThumbTimer.setSingleShot(true);
+            connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
+            m_endThumbTimer.setSingleShot(true);
+            connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
 
-        connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
+            connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
 
-        connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
-        connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
-        if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
+            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+            connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+            if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
+        }
 
     } else if (m_clipType == COLOR) {
         QString colour = m_clip->getProperty("colour");
@@ -118,8 +120,8 @@ ClipItem::~ClipItem()
     blockSignals(true);
     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)));
-        disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+        //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+        //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
     delete m_timeLine;
 }
@@ -760,38 +762,38 @@ void ClipItem::paint(QPainter *painter,
 
 
     // draw markers
-    QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
-    QList < CommentedTime >::Iterator it = markers.begin();
-    GenTime pos;
-    double framepos;
-    QBrush markerBrush(QColor(120, 120, 0, 140));
-    QPen pen = painter->pen();
-    pen.setColor(QColor(255, 255, 255, 200));
-    pen.setStyle(Qt::DotLine);
-
-    for (; it != markers.end(); ++it) {
-        pos = GenTime((int)((*it).time().frames(m_fps) / m_speed + 0.5), m_fps) - cropStart();
-        if (pos > GenTime()) {
-            if (pos > cropDuration()) break;
-            QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
-            QLineF l2 = painter->matrix().map(l);
-            //framepos = scale * pos.frames(m_fps);
-            //QLineF l(framepos, 5, framepos, itemHeight - 5);
-            painter->setPen(pen);
-            painter->drawLine(l2);
-            if (KdenliveSettings::showmarkers()) {
-                framepos = rect().x() + pos.frames(m_fps);
-                const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
-                const QRectF r2 = painter->matrix().mapRect(r1);
-                const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
-                painter->setBrush(markerBrush);
-                painter->setPen(Qt::NoPen);
-                painter->drawRoundedRect(txtBounding3, 3, 3);
-                painter->setBrush(QBrush(Qt::NoBrush));
-                painter->setPen(Qt::white);
-                painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
+    if (isEnabled() && m_clip) {
+        QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
+        QList < CommentedTime >::Iterator it = markers.begin();
+        GenTime pos;
+        double framepos;
+        QBrush markerBrush(QColor(120, 120, 0, 140));
+        QPen pen = painter->pen();
+        pen.setColor(QColor(255, 255, 255, 200));
+        pen.setStyle(Qt::DotLine);
+
+        for (; it != markers.end(); ++it) {
+            pos = GenTime((int)((*it).time().frames(m_fps) / m_speed + 0.5), m_fps) - cropStart();
+            if (pos > GenTime()) {
+                if (pos > cropDuration()) break;
+                QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
+                QLineF l2 = painter->matrix().map(l);
+                painter->setPen(pen);
+                painter->drawLine(l2);
+                if (KdenliveSettings::showmarkers()) {
+                    framepos = rect().x() + pos.frames(m_fps);
+                    const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
+                    const QRectF r2 = painter->matrix().mapRect(r1);
+                    const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
+                    painter->setBrush(markerBrush);
+                    painter->setPen(Qt::NoPen);
+                    painter->drawRoundedRect(txtBounding3, 3, 3);
+                    painter->setBrush(QBrush(Qt::NoBrush));
+                    painter->setPen(Qt::white);
+                    painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
+                }
+                //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
             }
-            //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
         }
     }
 
index 4f96ba185bcfac2aa78599c662bab0457e1b1a7f..ff27251a3e763e61925c13e56ef0f619d823e59f 100644 (file)
@@ -50,6 +50,7 @@ ClipManager::~ClipManager()
 {
     kDebug() << "\n\n 2222222222222222222222222  CLOSE CM 22222222222";
     qDeleteAll(m_clipList);
+    m_clipList.clear();
 }
 
 void ClipManager::clear()
index 7e5b0329290ad129355c05243a9d274bb6dfd70d..680c7fc9cc32978c0c757461bfd64cb96f48edbc 100644 (file)
@@ -171,6 +171,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
 CustomTrackView::~CustomTrackView()
 {
     qDeleteAll(m_guides);
+    m_guides.clear();
     m_waitingThumbs.clear();
 }
 
@@ -1410,7 +1411,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             //item->setZValue(10);
             item->setFlag(QGraphicsItem::ItemIsMovable, false);
             m_selectionGroup->addToGroup(item);
-            m_waitingThumbs.append(item);
+            if (!clip->isPlaceHolder()) m_waitingThumbs.append(item);
         }
 
         updateSnapPoints(NULL, offsetList);
@@ -2049,6 +2050,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
         bool hasVideoClip = false;
         QUndoCommand *addCommand = new QUndoCommand();
         addCommand->setText(i18n("Add timeline clip"));
+        QList <ClipItem *> brokenClips;
 
         for (int i = 0; i < items.count(); i++) {
             ClipItem *item = static_cast <ClipItem *>(items.at(i));
@@ -2072,6 +2074,8 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             clipInfo.track = m_document->tracksCount() - item->track();
             if (m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT) == -1) {
                 emit displayMessage(i18n("Cannot insert clip in timeline"), ErrorMessage);
+                brokenClips.append(item);
+                continue;
             }
             adjustTimelineClips(m_scene->editMode(), item, ItemInfo(), addCommand);
 
@@ -2084,7 +2088,10 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             }
             item->setSelected(true);
         }
-        m_commandStack->push(addCommand);
+        qDeleteAll(brokenClips);
+        brokenClips.clear();
+        if (addCommand->childCount() > 0) m_commandStack->push(addCommand);
+        else delete addCommand;
         setDocumentModified();
 
         /*
@@ -3663,7 +3670,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
     }
     setDocumentModified();
     if (refresh) m_document->renderer()->doRefresh();
-    m_waitingThumbs.append(item);
+    if (!baseclip->isPlaceHolder()) m_waitingThumbs.append(item);
     m_thumbsTimer.start();
 }
 
index 9ede6abbba82fd23dc808706dd439e60e773e0e1..7b55fa5f3beba4fd871deb908d158fa4cebbd29f 100644 (file)
@@ -325,10 +325,6 @@ QList < CommentedTime > DocClipBase::commentedSnapMarkers() const
     return m_snapMarkers;
 }
 
-void DocClipBase::setSnapMarkers(QList < CommentedTime > markers)
-{
-    m_snapMarkers = markers;
-}
 
 void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
 {
@@ -462,7 +458,7 @@ void DocClipBase::deleteProducers()
 
 void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
 {
-    if (producer == NULL) return;
+    if (producer == NULL || m_placeHolder) return;
     if (reset) {
         // Clear all previous producers
         kDebug() << "/+++++++++++++++   DELETE ALL PRODS " << producer->get("id");
index 9b76a2e72c8e11f8dce673866f5a47f104807dc4..dac2c770846bbeb835882052dad44c3fa6a72f72 100644 (file)
@@ -245,7 +245,6 @@ public slots:
     void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
     bool slotGetAudioThumbs();
     QList < CommentedTime > commentedSnapMarkers() const;
-    void setSnapMarkers(QList < CommentedTime > markers);
     GenTime findNextSnapMarker(const GenTime & currTime);
     GenTime findPreviousSnapMarker(const GenTime & currTime);
     GenTime hasSnapMarkers(const GenTime & time);
index a168d0e1342af65b9e6e7d42a8255fa83e6b3de1..f0bf23ec375df6cc87db7a2aafe60658b3c19e10 100644 (file)
@@ -105,8 +105,8 @@ bool DocumentChecker::hasMissingClips()
         if (!luma.isEmpty() && !QFile::exists(luma)) {
             if (!missingLumas.contains(luma)) {
                 missingLumas.append(luma);
-           }
-       }
+            }
+        }
     }
 
     if (missingClips.isEmpty() && missingLumas.isEmpty()) {
@@ -116,8 +116,8 @@ bool DocumentChecker::hasMissingClips()
     m_dialog->setFont(KGlobalSettings::toolBarFont());
     m_ui.setupUi(m_dialog);
 
-    foreach (const QString l, missingLumas) {
-       QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << i18n("Luma file") << l);
+    foreach(const QString l, missingLumas) {
+        QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << i18n("Luma file") << l);
         item->setIcon(0, KIcon("dialog-close"));
         item->setData(0, idRole, l);
         item->setData(0, statusRole, LUMAMISSING);
index a86983e65b70aa4090d969773f3c2a06ac36659a..c2990c57a04fdb0d5f991cfc1ed4ab7bfb8655fe 100644 (file)
@@ -140,6 +140,7 @@ void EffectStackView::slotUpdateEffectParams(const QDomElement old, const QDomEl
 
 void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
 {
+    if (c && !c->isEnabled()) return;
     if (c && c == m_clipref) {
         if (ix == -1) ix = m_ui.effectlist->currentRow();
     } else {
index cfba3932e89c5f7d4996483f74701cde6b049541..ae1eab2688bd7fcf4123a0137795f6fea226efb5 100644 (file)
@@ -34,7 +34,8 @@ ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
         QTreeWidgetItem(parent, PROJECTCLIPTYPE)
 {
     setSizeHint(0, QSize(itemHeight * 3, itemHeight));
-    setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+    if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+    else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
     m_clip = clip;
     m_clipId = clip->getId();
     QString name = m_clip->getProperty("name");
@@ -54,7 +55,8 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
         QTreeWidgetItem(parent, PROJECTCLIPTYPE)
 {
     setSizeHint(0, QSize(itemHeight * 3, itemHeight));
-    setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+    if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+    else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
     m_clip = clip;
     m_clipId = clip->getId();
     QString name = m_clip->getProperty("name");
@@ -159,6 +161,7 @@ DocClipBase *ProjectItem::referencedClip()
 void ProjectItem::slotSetToolTip()
 {
     QString tip = "<b>";
+    if (m_clip->isPlaceHolder()) tip.append(i18n("Missing") + " | ");
     switch (m_clipType) {
     case AUDIO:
         tip.append(i18n("Audio clip") + "</b><br />" + clipUrl().path());
index 7a4121c02481192634367321041856f1bed17fba..fb099e49153d65e1e4d5e89290fd8639f3192634 100644 (file)
@@ -856,7 +856,7 @@ void ProjectList::updateAllClips()
             if (item->referencedClip()->producer() == NULL) {
                 if (clip->isPlaceHolder() == false) {
                     requestClipInfo(clip->toXML(), clip->getId());
-                } else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+                } else if (!clip->isPlaceHolder()) item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
             } else {
                 if (item->data(0, Qt::DecorationRole).isNull()) {
                     requestClipThumbnail(clip->getId());
index 55ceaafc78759ea9d0984d53f3ce7f34bc2176df..993501f0c5dd4da7c8d30cd88d042b3463fa00a0 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <KTreeWidgetSearchLine>
 #include <KUrl>
+#include <KIcon>
 
 #ifdef NEPOMUK
 #include <nepomuk/kratingpainter.h>
@@ -79,6 +80,12 @@ public:
             }
             QStyleOptionViewItemV2 opt = setOptions(index, option);
             QPixmap pixmap = decoration(opt, index.data(Qt::DecorationRole));
+            if ((index.flags() & (Qt::ItemIsDragEnabled)) == false) {
+                KIcon icon("dialog-close");
+                QPainter p(&pixmap);
+                p.drawPixmap(1, 1, icon.pixmap(16, 16));
+                p.end();
+            }
             QRect decorationRect = pixmap.rect(); //QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());
             const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
             decorationRect.moveTo(r1.topLeft() + QPoint(0, 1));