From 4329ed5f483544c2da48d8a5ba04e39a6a47376c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 14 Oct 2012 21:56:30 +0200 Subject: [PATCH] Fix crash in scopes: http://kdenlive.org/mantis/view.php?id=2779 --- src/colorcorrection/rgbparadegenerator.cpp | 3 +-- src/mainwindow.cpp | 1 + src/projectlist.cpp | 3 ++- src/projectlist.h | 1 + src/projectlistview.cpp | 1 + src/renderer.cpp | 7 ------- src/scopes/colorscopes/abstractgfxscopewidget.cpp | 4 +++- src/scopes/colorscopes/abstractgfxscopewidget.h | 3 ++- src/scopes/scopemanager.cpp | 6 +++--- src/scopes/scopemanager.h | 2 +- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/colorcorrection/rgbparadegenerator.cpp b/src/colorcorrection/rgbparadegenerator.cpp index cd2a0048..f8ad5cd0 100644 --- a/src/colorcorrection/rgbparadegenerator.cpp +++ b/src/colorcorrection/rgbparadegenerator.cpp @@ -47,7 +47,7 @@ QImage RGBParadeGenerator::calculateRGBParade(const QSize ¶deSize, const QIm } else { QImage parade(paradeSize, QImage::Format_ARGB32); - parade.fill(qRgba(0,0,0,0)); + parade.fill(Qt::transparent); QRgb *col; QPainter davinci(¶de); @@ -92,7 +92,6 @@ QImage RGBParadeGenerator::calculateRGBParade(const QSize ¶deSize, const QIm const uint stepsize = 4*accelFactor; for (uint i = 0, x = 0; i < byteCount; i += stepsize) { - col = (QRgb *)bits; r = qRed(*col); g = qGreen(*col); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e80868fd..5ca55a8a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -912,6 +912,7 @@ void MainWindow::slotUpdateClip(const QString &id) void MainWindow::slotConnectMonitors() { m_projectList->setRenderer(m_projectMonitor->render); + connect(m_projectList, SIGNAL(pauseMonitor()), m_monitorManager, SLOT(slotPause())); connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap)), this, SLOT(slotDeleteProjectClips(QStringList, QMap))); connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *))); connect(m_projectList, SIGNAL(showClipProperties(QList , QMap)), this, SLOT(slotShowClipProperties(QList , QMap))); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index d60e3081..be927c1b 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -310,8 +310,9 @@ ProjectList::ProjectList(QWidget *parent) : connect(m_listView, SIGNAL(projectModified()), this, SIGNAL(projectModified())); connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected())); connect(m_listView, SIGNAL(focusMonitor()), this, SIGNAL(raiseClipMonitor())); - connect(m_listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor())); + connect(m_listView, SIGNAL(pauseMonitor()), this, SIGNAL(pauseMonitor())); connect(m_listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *))); + connect(m_listView, SIGNAL(addClip()), this, SIGNAL(pauseMonitor())); connect(m_listView, SIGNAL(addClip()), this, SLOT(slotAddClip())); connect(m_listView, SIGNAL(addClip(const QList , const QString &, const QString &)), this, SLOT(slotAddClip(const QList , const QString &, const QString &))); connect(this, SIGNAL(addClip(const QString, const QString &, const QString &)), this, SLOT(slotAddClip(const QString, const QString &, const QString &))); diff --git a/src/projectlist.h b/src/projectlist.h index 7d7e384f..8ed251af 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -523,6 +523,7 @@ signals: void checkJobProcess(); /** @brief A Filter Job produced results, send them back to the clip. */ void gotFilterJobResults(const QString &id, int startPos, int track, const QString &filterName, stringMap params); + void pauseMonitor(); }; #endif diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index cda2480a..21e212c2 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -184,6 +184,7 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) { QTreeWidgetItem *it = itemAt(event->pos()); if (!it) { + emit pauseMonitor(); emit addClip(); return; } diff --git a/src/renderer.cpp b/src/renderer.cpp index 7572a6b9..c163bb12 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -1705,13 +1705,6 @@ void Render::emitFrameUpdated(Mlt::Frame& frame) const uchar* image = frame.get_image(format, width, height); QImage qimage(width, height, QImage::Format_ARGB32_Premultiplied); memcpy(qimage.scanLine(0), image, width * height * 4); - - /*mlt_image_format format = mlt_image_rgb24; - int width = 0; - int height = 0; - const uchar* image = frame.get_image(format, width, height); - QImage qimage(width, height, QImage::Format_RGB888); - memcpy(qimage.bits(), image, width * height * 3);*/ emit frameUpdated(qimage.rgbSwapped()); } diff --git a/src/scopes/colorscopes/abstractgfxscopewidget.cpp b/src/scopes/colorscopes/abstractgfxscopewidget.cpp index 430b3319..39343490 100644 --- a/src/scopes/colorscopes/abstractgfxscopewidget.cpp +++ b/src/scopes/colorscopes/abstractgfxscopewidget.cpp @@ -37,6 +37,7 @@ AbstractGfxScopeWidget::~AbstractGfxScopeWidget() { } QImage AbstractGfxScopeWidget::renderScope(uint accelerationFactor) { + QMutexLocker lock(&m_mutex); return renderGfxScope(accelerationFactor, m_scopeImage); } @@ -50,8 +51,9 @@ void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event) ///// Slots ///// -void AbstractGfxScopeWidget::slotRenderZoneUpdated(QImage frame) +void AbstractGfxScopeWidget::slotRenderZoneUpdated(const QImage frame) { + QMutexLocker lock(&m_mutex); m_scopeImage = frame; AbstractScopeWidget::slotRenderZoneUpdated(); } diff --git a/src/scopes/colorscopes/abstractgfxscopewidget.h b/src/scopes/colorscopes/abstractgfxscopewidget.h index cd8d68e4..a4ff72c1 100644 --- a/src/scopes/colorscopes/abstractgfxscopewidget.h +++ b/src/scopes/colorscopes/abstractgfxscopewidget.h @@ -45,12 +45,13 @@ protected: private: QImage m_scopeImage; + QMutex m_mutex; public slots: /** @brief Must be called when the active monitor has shown a new frame. This slot must be connected in the implementing class, it is *not* done in this abstract class. */ - void slotRenderZoneUpdated(QImage); + void slotRenderZoneUpdated(const QImage); protected slots: virtual void slotAutoRefreshToggled(bool autoRefresh); diff --git a/src/scopes/scopemanager.cpp b/src/scopes/scopemanager.cpp index a1fc1416..283dc341 100644 --- a/src/scopes/scopemanager.cpp +++ b/src/scopes/scopemanager.cpp @@ -129,7 +129,7 @@ void ScopeManager::slotDistributeAudio(QVector sampleData, int freq, in checkActiveAudioScopes(); } -void ScopeManager::slotDistributeFrame(QImage image) +void ScopeManager::slotDistributeFrame(const QImage image) { #ifdef DEBUG_SM qDebug() << "ScopeManager: Starting to distribute frame."; @@ -205,8 +205,8 @@ void ScopeManager::slotUpdateActiveRenderer() // Connect new renderer if (m_lastConnectedRenderer != NULL) { - b &= connect(m_lastConnectedRenderer, SIGNAL(frameUpdated(QImage)), - this, SLOT(slotDistributeFrame(QImage)), Qt::UniqueConnection); + b &= connect(m_lastConnectedRenderer, SIGNAL(frameUpdated(const QImage)), + this, SLOT(slotDistributeFrame(const QImage)), Qt::UniqueConnection); b &= connect(m_lastConnectedRenderer, SIGNAL(audioSamplesSignal(QVector,int,int,int)), this, SLOT(slotDistributeAudio(QVector,int,int,int)), Qt::UniqueConnection); Q_ASSERT(b); diff --git a/src/scopes/scopemanager.h b/src/scopes/scopemanager.h index 79b45e1e..d4d98d43 100644 --- a/src/scopes/scopemanager.h +++ b/src/scopes/scopemanager.h @@ -115,7 +115,7 @@ private slots: */ void slotCheckActiveScopes(); - void slotDistributeFrame(QImage image); + void slotDistributeFrame(const QImage image); void slotDistributeAudio(QVector sampleData, int freq, int num_channels, int num_samples); /** Allows a scope to explicitly request a new frame, even if the scope's autoRefresh is disabled. -- 2.39.2