Commit 43c86b11 authored by luyikei's avatar luyikei

ClipRenderer: Use shared pointer

parent 0667503b
......@@ -528,11 +528,11 @@ MainWindow::setupClipPreview()
renderer, &ClipRenderer::clipUnloaded );
connect( m_clipLibrary, &ClipLibraryView::clipSelected, renderer, [renderer]( const QString& uuid )
{
renderer->setClip( Core::instance()->library()->clip( uuid ).data() );
renderer->setClip( Core::instance()->library()->clip( uuid ) );
} );
connect( m_mediaLibrary, &MediaLibraryView::baseClipSelected, renderer, [renderer]( const QString& uuid )
{
renderer->setClip( Core::instance()->library()->clip( uuid ).data() );
renderer->setClip( Core::instance()->library()->clip( uuid ) );
} );
......
......@@ -239,7 +239,7 @@ PreviewWidget::createNewClipFromMarkers()
ClipRenderer* clipRenderer = qobject_cast<ClipRenderer*>( m_renderer );
Q_ASSERT( clipRenderer != nullptr );
Clip* clip = clipRenderer->getClip();
auto clip = clipRenderer->getClip();
if ( clip == nullptr )
return ;
auto media = clip->media();
......
......@@ -54,7 +54,7 @@ ClipRenderer::~ClipRenderer()
}
void
ClipRenderer::setClip( Clip* clip )
ClipRenderer::setClip( QSharedPointer<Clip> clip )
{
// if the clip is different (or nullptr) we have to stop playback.
if ( m_selectedClip != nullptr &&
......@@ -64,7 +64,7 @@ ClipRenderer::setClip( Clip* clip )
}
if ( clip == nullptr )
{
m_selectedClip = nullptr;
m_selectedClip.clear();
m_clipLoaded = false;
m_input = nullptr;
return ;
......@@ -72,12 +72,6 @@ ClipRenderer::setClip( Clip* clip )
m_selectedClip = clip;
if ( clip->length() == 0 )
return ;
updateInfos( clip );
}
void
ClipRenderer::updateInfos( Clip* clip )
{
if ( m_output->isStopped() == true )
m_clipLoaded = false;
else
......@@ -89,7 +83,6 @@ ClipRenderer::startPreview()
{
if ( m_selectedClip == nullptr || m_selectedClip->length() == 0 )
return ;
updateInfos( m_selectedClip );
setInput( m_selectedClip->input() );
m_input->setPosition( 0 );
......@@ -154,11 +147,11 @@ ClipRenderer::clipUnloaded( const QUuid& uuid )
{
stop();
m_clipLoaded = false;
m_selectedClip = nullptr;
m_selectedClip.clear();
}
}
Clip*
QSharedPointer<Clip>
ClipRenderer::getClip()
{
return m_selectedClip;
......
......@@ -27,6 +27,7 @@
#include "AbstractRenderer.h"
#include <QObject>
#include <QSharedPointer>
class Clip;
class Media;
......@@ -44,14 +45,14 @@ public:
virtual void stop();
virtual qint64 length() const;
virtual qint64 getLengthMs() const;
virtual Clip *getClip();
virtual QSharedPointer<Clip> getClip();
private:
void startPreview();
private:
bool m_clipLoaded;
Clip* m_selectedClip;
QSharedPointer<Clip> m_selectedClip;
/**
* \brief This flags is used to know if a new media has been selected in the
* library. If so, we must relaunch the render if the play button is clicked again.
......@@ -63,9 +64,8 @@ public slots:
* \brief Set the Clip to render
* \param clip The clip to render
*/
void setClip( Clip* clip );
void setClip( QSharedPointer<Clip> clip );
void clipUnloaded( const QUuid& uuid );
void updateInfos( Clip* clip );
/**
* \brief Triggered at every libvlc_MediaPlayerTimeChanged event.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment