[vlmc-devel] AbstractRenderer: Use shared pointer for eventWatcher
Yikai Lu
git at videolan.org
Fri Jun 30 17:33:32 CEST 2017
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Fri Jun 30 15:28:18 2017 +0900| [e0130fcef01820dce2cab8a6a3304d06cb7ba0cd] | committer: Yikai Lu
AbstractRenderer: Use shared pointer for eventWatcher
> https://code.videolan.org/videolan/vlmc/commit/e0130fcef01820dce2cab8a6a3304d06cb7ba0cd
---
src/Gui/preview/PreviewRuler.cpp | 4 ++--
src/Gui/preview/PreviewWidget.cpp | 10 +++++-----
src/Renderer/AbstractRenderer.cpp | 17 ++++++++---------
src/Renderer/AbstractRenderer.h | 5 +++--
src/Workflow/MainWorkflow.cpp | 8 ++++----
5 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/Gui/preview/PreviewRuler.cpp b/src/Gui/preview/PreviewRuler.cpp
index b0e18296..f621eee5 100644
--- a/src/Gui/preview/PreviewRuler.cpp
+++ b/src/Gui/preview/PreviewRuler.cpp
@@ -49,9 +49,9 @@ PreviewRuler::setRenderer( AbstractRenderer* renderer )
m_renderer->disconnect( this );
m_renderer = renderer;
- connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged,
+ connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::positionChanged,
this, &PreviewRuler::updateTimecode );
- connect( m_renderer->eventWatcher(), SIGNAL( stopped() ),
+ connect( m_renderer->eventWatcher().data(), SIGNAL( stopped() ),
this, SLOT( clear() ) );
connect( m_renderer, SIGNAL( lengthChanged(qint64) ), this, SLOT( update() ) );
}
diff --git a/src/Gui/preview/PreviewWidget.cpp b/src/Gui/preview/PreviewWidget.cpp
index b1a5c4f9..978d259b 100644
--- a/src/Gui/preview/PreviewWidget.cpp
+++ b/src/Gui/preview/PreviewWidget.cpp
@@ -86,11 +86,11 @@ PreviewWidget::setRenderer( AbstractRenderer* renderer )
m_ui->renderWidget->release();
#endif
- connect( renderer->eventWatcher(), SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
- connect( renderer->eventWatcher(), SIGNAL( paused() ), this, SLOT( videoPaused() ) );
- connect( renderer->eventWatcher(), SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
- connect( renderer->eventWatcher(), SIGNAL( errorEncountered() ), this, SLOT( error() ) );
- connect( renderer->eventWatcher(), SIGNAL( volumeChanged() ), this, SLOT( volumeChanged() ) );
+ connect( renderer->eventWatcher().data(), SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
+ connect( renderer->eventWatcher().data(), SIGNAL( paused() ), this, SLOT( videoPaused() ) );
+ connect( renderer->eventWatcher().data(), SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
+ connect( renderer->eventWatcher().data(), SIGNAL( errorEncountered() ), this, SLOT( error() ) );
+ connect( renderer->eventWatcher().data(), SIGNAL( volumeChanged() ), this, SLOT( volumeChanged() ) );
connect( m_ui->rulerWidget, SIGNAL( frameChanged(qint64, Vlmc::FrameChangedReason) ),
m_renderer, SLOT( previewWidgetCursorChanged(qint64) ) );
diff --git a/src/Renderer/AbstractRenderer.cpp b/src/Renderer/AbstractRenderer.cpp
index 959b280e..cc7f8bc8 100644
--- a/src/Renderer/AbstractRenderer.cpp
+++ b/src/Renderer/AbstractRenderer.cpp
@@ -34,21 +34,20 @@
AbstractRenderer::AbstractRenderer()
: m_input( nullptr )
+ , m_eventWatcher( new RendererEventWatcher )
{
- m_eventWatcher = new RendererEventWatcher;
- connect( m_eventWatcher, &RendererEventWatcher::stopped, this, &AbstractRenderer::stop );
- connect( m_eventWatcher, &RendererEventWatcher::positionChanged, this, [this]( qint64 pos ){ emit frameChanged( pos, Vlmc::Renderer ); } );
- connect( m_eventWatcher, &RendererEventWatcher::lengthChanged, this, &AbstractRenderer::lengthChanged );
- connect( m_eventWatcher, &RendererEventWatcher::endReached, this, &AbstractRenderer::stop );
+ connect( m_eventWatcher.data(), &RendererEventWatcher::stopped, this, &AbstractRenderer::stop );
+ connect( m_eventWatcher.data(), &RendererEventWatcher::positionChanged, this, [this]( qint64 pos ){ emit frameChanged( pos, Vlmc::Renderer ); } );
+ connect( m_eventWatcher.data(), &RendererEventWatcher::lengthChanged, this, &AbstractRenderer::lengthChanged );
+ connect( m_eventWatcher.data(), &RendererEventWatcher::endReached, this, &AbstractRenderer::stop );
}
AbstractRenderer::~AbstractRenderer()
{
stop();
- delete m_eventWatcher;
}
-RendererEventWatcher*
+QSharedPointer<RendererEventWatcher>
AbstractRenderer::eventWatcher()
{
return m_eventWatcher;
@@ -163,7 +162,7 @@ AbstractRenderer::setInput( Backend::IInput* input )
if ( m_input )
{
- m_input->setCallback( m_eventWatcher );
+ m_input->setCallback( m_eventWatcher.data() );
emit lengthChanged( m_input->playableLength() );
}
else
@@ -177,7 +176,7 @@ void
AbstractRenderer::setOutput( std::unique_ptr<Backend::IOutput> consuemr )
{
m_output = std::move( consuemr );
- m_output->setCallback( m_eventWatcher );
+ m_output->setCallback( m_eventWatcher.data() );
if ( m_input != nullptr )
m_output->connect( *m_input );
diff --git a/src/Renderer/AbstractRenderer.h b/src/Renderer/AbstractRenderer.h
index 01b8c2a5..ee508c94 100644
--- a/src/Renderer/AbstractRenderer.h
+++ b/src/Renderer/AbstractRenderer.h
@@ -29,6 +29,7 @@
#endif
#include <memory>
#include <QObject>
+#include <QSharedPointer>
#include "Workflow/Types.h"
#include "Backend/IOutput.h"
@@ -149,12 +150,12 @@ public:
virtual void setInput( Backend::IInput* input );
virtual void setOutput( std::unique_ptr<Backend::IOutput> consuemr );
- RendererEventWatcher* eventWatcher();
+ QSharedPointer<RendererEventWatcher> eventWatcher();
protected:
std::unique_ptr<Backend::IOutput> m_output;
Backend::IInput* m_input;
- RendererEventWatcher* m_eventWatcher;
+ QSharedPointer<RendererEventWatcher> m_eventWatcher;
public slots:
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 5c7fdd89..5c38b52d 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -68,9 +68,9 @@ MainWorkflow::MainWorkflow( Settings* projectSettings, int trackCount ) :
connect( m_sequenceWorkflow.get(), &SequenceWorkflow::clipResized, this, &MainWorkflow::clipResized );
m_renderer->setInput( m_sequenceWorkflow->input() );
- connect( m_renderer->eventWatcher(), &RendererEventWatcher::lengthChanged, this, &MainWorkflow::lengthChanged );
- connect( m_renderer->eventWatcher(), &RendererEventWatcher::endReached, this, &MainWorkflow::mainWorkflowEndReached );
- connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged, this, [this]( qint64 pos )
+ connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::lengthChanged, this, &MainWorkflow::lengthChanged );
+ connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::endReached, this, &MainWorkflow::mainWorkflowEndReached );
+ connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::positionChanged, this, [this]( qint64 pos )
{
emit frameChanged( pos, m_sequenceWorkflow->input()->playableLength(), Vlmc::Renderer );
}, Qt::DirectConnection );
@@ -340,7 +340,7 @@ MainWorkflow::startRenderToFile( const QString &outputFileName, quint32 width, q
dialog.setOutputFileName( outputFileName );
connect( this, &MainWorkflow::frameChanged, &dialog, &WorkflowFileRendererDialog::frameChanged );
connect( &dialog, &WorkflowFileRendererDialog::stop, this, [&output]{ output.stop(); } );
- connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged, &dialog,
+ connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::positionChanged, &dialog,
[this, input, &dialog, width, height]( qint64 pos )
{
// Update the preview per five seconds
More information about the Vlmc-devel
mailing list