From 39e387e732db729eaf44c1826d86cd45e3878482 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 2 Jun 2011 12:27:46 +0000 Subject: [PATCH] Fix buttons in capture monitor and crash when changing profile svn path=/trunk/kdenlive/; revision=5630 --- src/abstractmonitor.h | 9 +++-- src/colorscopes/abstractgfxscopewidget.cpp | 12 ++++--- src/colorscopes/abstractgfxscopewidget.h | 1 + src/mainwindow.cpp | 8 +++++ src/mainwindow.h | 2 ++ src/mltdevicecapture.cpp | 2 +- src/monitormanager.cpp | 13 +++++++- src/monitormanager.h | 3 ++ src/recmonitor.cpp | 38 +++++----------------- src/renderer.cpp | 2 +- src/stopmotion/stopmotion.cpp | 3 +- 11 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/abstractmonitor.h b/src/abstractmonitor.h index 3cde7e04..62d9ee27 100644 --- a/src/abstractmonitor.h +++ b/src/abstractmonitor.h @@ -53,20 +53,25 @@ class AbstractRender: public QObject Q_OBJECT public: /** @brief Build an abstract MLT Renderer - * @param rendererName A unique identifier for this renderer + * @param name A unique identifier for this renderer * @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering * @param profile The MLT profile used for the renderer (default one will be used if empty). */ - AbstractRender(QWidget *parent = 0):QObject(parent),sendFrameForAnalysis(false) {}; + AbstractRender(const QString &name, QWidget *parent = 0):QObject(parent), m_name(name), sendFrameForAnalysis(false) {}; /** @brief Destroy the MLT Renderer. */ virtual ~AbstractRender() {}; /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */ bool sendFrameForAnalysis; + + const QString &name() const {return m_name;}; /** @brief Someone needs us to send again a frame. */ virtual void sendFrameUpdate() = 0; +private: + QString m_name; + signals: /** @brief The renderer refreshed the current frame. */ void frameUpdated(QImage); diff --git a/src/colorscopes/abstractgfxscopewidget.cpp b/src/colorscopes/abstractgfxscopewidget.cpp index 43a7d815..370fcb0d 100644 --- a/src/colorscopes/abstractgfxscopewidget.cpp +++ b/src/colorscopes/abstractgfxscopewidget.cpp @@ -62,17 +62,16 @@ void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event) void AbstractGfxScopeWidget::slotActiveMonitorChanged() { if (m_activeRender) { + if (m_activeRender == m_manager->activeRenderer()) return; bool b = m_activeRender->disconnect(this); Q_ASSERT(b); } - m_activeRender = m_manager->activeRenderer(); + + if (m_activeRender) { #ifdef DEBUG_AGSW qDebug() << "Active monitor has changed in " << widgetName() << ". Is the clip monitor active now? " << m_activeRender->name(); #endif - - //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated())); - if (m_activeRender) { bool b = connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage))); Q_ASSERT(b); } @@ -81,6 +80,11 @@ void AbstractGfxScopeWidget::slotActiveMonitorChanged() forceUpdate(true); } +void AbstractGfxScopeWidget::slotClearMonitor() +{ + m_activeRender = NULL; +} + void AbstractGfxScopeWidget::slotRenderZoneUpdated(QImage frame) { m_scopeImage = frame; diff --git a/src/colorscopes/abstractgfxscopewidget.h b/src/colorscopes/abstractgfxscopewidget.h index 0dc59eb2..5748dae5 100644 --- a/src/colorscopes/abstractgfxscopewidget.h +++ b/src/colorscopes/abstractgfxscopewidget.h @@ -52,6 +52,7 @@ public slots: This slot must be connected in the implementing class, it is *not* done in this abstract class. */ void slotActiveMonitorChanged(); + void slotClearMonitor(); protected slots: virtual void slotAutoRefreshToggled(bool autoRefresh); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8346a8e0..2606751c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -565,6 +565,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors())); connect(m_monitorManager, SIGNAL(raiseMonitor(AbstractMonitor *)), this, SLOT(slotRaiseMonitor(AbstractMonitor *))); connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes())); + connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes())); connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement))); connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects())); @@ -4222,6 +4223,13 @@ void MainWindow::slotUpdateColorScopes() } } +void MainWindow::slotClearColorScopes() +{ + for (int i = 0; i < m_gfxScopesList.count(); i++) { + static_cast(m_gfxScopesList.at(i)->widget())->slotClearMonitor(); + } +} + void MainWindow::slotOpenStopmotion() { if (m_stopmotion == NULL) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 523bfc9a..f4d0d3b4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -528,6 +528,8 @@ private slots: void slotDoUpdateAudioScopeFrameRequest(); /** @brief When switching between monitors, update the visible scopes. */ void slotUpdateColorScopes(); + /** @brief Active monitor deleted, clear scopes. */ + void slotClearColorScopes(); /** @brief Switch current monitor to fullscreen. */ void slotSwitchFullscreen(); /** @brief Open the stopmotion dialog. */ diff --git a/src/mltdevicecapture.cpp b/src/mltdevicecapture.cpp index 8862d5cb..3f4f9794 100644 --- a/src/mltdevicecapture.cpp +++ b/src/mltdevicecapture.cpp @@ -83,7 +83,7 @@ static void rec_consumer_frame_preview(mlt_consumer, MltDeviceCapture * self, ml MltDeviceCapture::MltDeviceCapture(QString profile, VideoPreviewContainer *surface, QWidget *parent) : - AbstractRender(parent), + AbstractRender("capture", parent), doCapture(0), sendFrameForAnalysis(false), m_mltConsumer(NULL), diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index 1077967f..9bf6ce43 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -184,6 +184,7 @@ void MonitorManager::slotResetProfiles() { if (m_blocked) return; if (m_projectMonitor == NULL || m_clipMonitor == NULL) return; + blockSignals(true); QString active = m_activeMonitor ? m_activeMonitor->name() : QString(); activateMonitor("clip"); m_clipMonitor->resetProfile(KdenliveSettings::current_profile()); @@ -193,6 +194,9 @@ void MonitorManager::slotResetProfiles() m_projectMonitor->updateTimecodeFormat(); //m_projectMonitor->refreshMonitor(true); if (!active.isEmpty()) activateMonitor(active); + blockSignals(false); + emit raiseMonitor(m_activeMonitor); + emit checkColorScopes(); } void MonitorManager::slotRefreshCurrentMonitor() @@ -212,6 +216,11 @@ void MonitorManager::slotUpdateAudioMonitoring() } } +void MonitorManager::clearScopeSource() +{ + emit clearScopes(); +} + void MonitorManager::updateScopeSource() { emit checkColorScopes(); @@ -219,7 +228,9 @@ void MonitorManager::updateScopeSource() AbstractRender *MonitorManager::activeRenderer() { - if (m_activeMonitor) return m_activeMonitor->abstractRender(); + if (m_activeMonitor) { + return m_activeMonitor->abstractRender(); + } return NULL; } diff --git a/src/monitormanager.h b/src/monitormanager.h index 9352f4d7..171ad0b3 100644 --- a/src/monitormanager.h +++ b/src/monitormanager.h @@ -40,6 +40,7 @@ public: void stopActiveMonitor(); AbstractRender *activeRenderer(); void updateScopeSource(); + void clearScopeSource(); public slots: @@ -83,6 +84,8 @@ signals: void raiseMonitor(AbstractMonitor *); /** @brief When the monitor changed, update the visible color scopes */ void checkColorScopes(); + /** @brief When the active monitor renderer was deleted, reset color scopes */ + void clearScopes(); }; diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index a3f92948..c0d7af19 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -98,7 +98,6 @@ RecMonitor::RecMonitor(QString name, MonitorManager *manager, QWidget *parent) : m_recAction = toolbar->addAction(KIcon("media-record"), i18n("Record")); connect(m_recAction, SIGNAL(triggered()), this, SLOT(slotRecord())); - m_recAction->setCheckable(true); toolbar->addSeparator(); @@ -207,19 +206,20 @@ void RecMonitor::slotVideoDeviceChanged(int ix) m_fwdAction->setVisible(ix == FIREWIRE); m_discAction->setVisible(ix == FIREWIRE); m_rewAction->setVisible(ix == FIREWIRE); + m_recAction->setEnabled(ix != FIREWIRE); m_logger.setVisible(ix == BLACKMAGIC); if (m_captureDevice) { // MLT capture still running, abort m_captureDevice->stop(); delete m_captureDevice; m_captureDevice = NULL; + m_manager->clearScopeSource(); } switch (ix) { case SCREENGRAB: m_discAction->setEnabled(false); m_rewAction->setEnabled(false); m_fwdAction->setEnabled(false); - m_recAction->setEnabled(true); m_stopAction->setEnabled(false); m_playAction->setEnabled(false); if (KdenliveSettings::rmd_path().isEmpty()) { @@ -231,19 +231,13 @@ void RecMonitor::slotVideoDeviceChanged(int ix) //video_frame->setText(i18n("Press record button\nto start screen capture")); break; case VIDEO4LINUX: - m_discAction->setEnabled(false); - m_rewAction->setEnabled(false); - m_fwdAction->setEnabled(false); - m_recAction->setEnabled(true); m_stopAction->setEnabled(false); m_playAction->setEnabled(true); checkDeviceAvailability(); break; case BLACKMAGIC: - m_recAction->setEnabled(true); m_stopAction->setEnabled(false); m_playAction->setEnabled(true); - capturefile = m_capturePath; if (!capturefile.endsWith("/")) capturefile.append("/"); capturename = KdenliveSettings::decklink_filename(); @@ -253,7 +247,6 @@ void RecMonitor::slotVideoDeviceChanged(int ix) break; default: // FIREWIRE m_discAction->setEnabled(true); - m_recAction->setEnabled(false); m_stopAction->setEnabled(false); m_playAction->setEnabled(false); m_rewAction->setEnabled(false); @@ -374,22 +367,15 @@ void RecMonitor::slotStopCapture() m_playAction->setIcon(m_playIcon); m_isPlaying = false; break; - case VIDEO4LINUX: - if (m_captureDevice) { - m_captureDevice->stop(); - } - m_playAction->setEnabled(true); - m_stopAction->setEnabled(false); - break; case SCREENGRAB: m_captureProcess->write("q\n", 3); QTimer::singleShot(1000, m_captureProcess, SLOT(kill())); break; + case VIDEO4LINUX: case BLACKMAGIC: if (m_captureDevice) { m_captureDevice->stop(); } - //m_bmCapture->stopPreview(); m_playAction->setEnabled(true); m_stopAction->setEnabled(false); m_recAction->setEnabled(true); @@ -493,11 +479,6 @@ void RecMonitor::slotStartCapture(bool play) m_stopAction->setEnabled(true); } - /*m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << KdenliveSettings::video4container() << "-"; - m_displayArgs << "-f" << KdenliveSettings::video4container() << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-"; - m_captureProcess->setStandardOutputProcess(m_displayProcess); - kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" "); - m_captureProcess->start("ffmpeg", m_captureArgs);*/ break; case BLACKMAGIC: path = KdenliveSettings::current_profile(); @@ -519,10 +500,6 @@ void RecMonitor::slotStartCapture(bool play) m_playAction->setEnabled(false); m_stopAction->setEnabled(true); } - //m_bmCapture->startPreview(KdenliveSettings::decklink_capturedevice(), KdenliveSettings::hdmi_capturemode()); - m_playAction->setEnabled(false); - m_stopAction->setEnabled(true); - m_recAction->setEnabled(true); break; default: break; @@ -557,7 +534,8 @@ void RecMonitor::slotRecord() slotStopCapture(); slotSetInfoMessage(i18n("Capture stopped")); m_isCapturing = false; - m_recAction->setChecked(false); + m_recAction->setEnabled(true); + m_stopAction->setEnabled(false); if (autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile); //QTimer::singleShot(1000, this, SLOT(slotStartCapture())); break; @@ -634,12 +612,13 @@ void RecMonitor::slotRecord() if (m_captureDevice->slotStartCapture(KdenliveSettings::v4l_parameters(), m_captureFile.path(), playlist, enable_preview->isChecked())) { m_videoBox->setHidden(false); m_isCapturing = true; + m_recAction->setEnabled(false); + m_stopAction->setEnabled(true); } else { video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters...")); m_videoBox->setHidden(true); m_isCapturing = false; - m_recAction->setChecked(false); } /* @@ -666,13 +645,14 @@ void RecMonitor::slotRecord() m_videoBox->setHidden(false); m_isCapturing = true; slotSetInfoMessage(i18n("Capturing to %1", m_captureFile.fileName())); + m_recAction->setEnabled(false); + m_stopAction->setEnabled(true); } else { video_frame->setText(i18n("Failed to start Decklink,\ncheck your parameters...")); slotSetInfoMessage(i18n("Failed to start capture")); m_videoBox->setHidden(true); m_isCapturing = false; - m_recAction->setChecked(false); } break; diff --git a/src/renderer.cpp b/src/renderer.cpp index c42d2db5..6728fdde 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -94,7 +94,7 @@ static void consumer_gl_frame_show(mlt_consumer, Render * self, mlt_frame frame_ } Render::Render(const QString & rendererName, int winid, QString profile, QWidget *parent) : - AbstractRender(parent), + AbstractRender(rendererName, parent), m_isBlocked(0), analyseAudio(KdenliveSettings::monitor_audio()), m_name(rendererName), diff --git a/src/stopmotion/stopmotion.cpp b/src/stopmotion/stopmotion.cpp index 6d473277..92558538 100644 --- a/src/stopmotion/stopmotion.cpp +++ b/src/stopmotion/stopmotion.cpp @@ -324,8 +324,7 @@ StopmotionWidget::StopmotionWidget(MonitorManager *manager, KUrl projectFolder, StopmotionWidget::~StopmotionWidget() { - /*if (m_bmCapture) - m_bmCapture->stopPreview();*/ + m_manager->removeMonitor(m_monitor); if (m_captureDevice) { m_captureDevice->stop(); delete m_captureDevice; -- 2.39.2