From: Jean-Baptiste Mardelle Date: Tue, 19 Jan 2010 02:48:42 +0000 (+0000) Subject: Fix crash on clip deletion, fix issues with placeholder clips X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=459decee5e330552ef73b7cb363dbbe38fdc7e87;p=kdenlive Fix crash on clip deletion, fix issues with placeholder clips svn path=/trunk/kdenlive/; revision=4236 --- diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 05dbb2fe..1aa2b203 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -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))); } } diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 4f96ba18..ff27251a 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -50,6 +50,7 @@ ClipManager::~ClipManager() { kDebug() << "\n\n 2222222222222222222222222 CLOSE CM 22222222222"; qDeleteAll(m_clipList); + m_clipList.clear(); } void ClipManager::clear() diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 7e5b0329..680c7fc9 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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 brokenClips; for (int i = 0; i < items.count(); i++) { ClipItem *item = static_cast (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(); } diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 9ede6abb..7b55fa5f 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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"); diff --git a/src/docclipbase.h b/src/docclipbase.h index 9b76a2e7..dac2c770 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -245,7 +245,6 @@ public slots: void updateAudioThumbnail(QMap > 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); diff --git a/src/documentchecker.cpp b/src/documentchecker.cpp index a168d0e1..f0bf23ec 100644 --- a/src/documentchecker.cpp +++ b/src/documentchecker.cpp @@ -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); diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index a86983e6..c2990c57 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -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 { diff --git a/src/projectitem.cpp b/src/projectitem.cpp index cfba3932..ae1eab26 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -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 = ""; + if (m_clip->isPlaceHolder()) tip.append(i18n("Missing") + " | "); switch (m_clipType) { case AUDIO: tip.append(i18n("Audio clip") + "
" + clipUrl().path()); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 7a4121c0..fb099e49 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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()); diff --git a/src/projectlist.h b/src/projectlist.h index 55ceaafc..993501f0 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -33,6 +33,7 @@ #include #include +#include #ifdef NEPOMUK #include @@ -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));