[vlmc-devel] EffectHelper: Don't remember its target
Yikai Lu
git at videolan.org
Wed Jun 29 08:20:14 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jun 29 15:05:11 2016 +0900| [66bb8e979311b4ba026806a5bdc581d8a0642661] | committer: Yikai Lu
EffectHelper: Don't remember its target
> https://code.videolan.org/videolan/vlmc/commit/66bb8e979311b4ba026806a5bdc581d8a0642661
---
src/Commands/Commands.cpp | 6 +++---
src/Commands/Commands.h | 4 ++--
src/EffectsEngine/EffectHelper.cpp | 15 ++-------------
src/EffectsEngine/EffectHelper.h | 2 --
src/Gui/timeline/GraphicsEffectItem.cpp | 4 ++--
src/Gui/timeline/TracksScene.cpp | 2 +-
src/Gui/timeline/TracksView.cpp | 4 ++--
7 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index a39aa4a..4e37e91 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -370,9 +370,9 @@ Commands::Effect::Resize::internalUndo()
m_helper->setBoundaries( m_oldBegin, m_oldEnd );
}
-Commands::Effect::Remove::Remove( std::shared_ptr<EffectHelper> const& helper, Backend::IInput* target )
+Commands::Effect::Remove::Remove( std::shared_ptr<EffectHelper> const& helper )
: m_helper( helper )
- , m_target( target )
+ , m_target( helper->filter()->input() )
{
}
@@ -392,5 +392,5 @@ Commands::Effect::Remove::internalRedo()
void
Commands::Effect::Remove::internalUndo()
{
- m_helper->setTarget( m_target );
+ m_helper->setTarget( m_target.get() );
}
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index c9fe352..2387945 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -235,13 +235,13 @@ namespace Commands
Q_OBJECT
public:
- Remove( std::shared_ptr<EffectHelper> const& helper, Backend::IInput* target );
+ Remove( std::shared_ptr<EffectHelper> const& helper );
virtual void internalRedo();
virtual void internalUndo();
virtual void retranslate();
private:
std::shared_ptr<EffectHelper> m_helper;
- Backend::IInput* m_target;
+ std::shared_ptr<Backend::IInput> m_target;
};
}
}
diff --git a/src/EffectsEngine/EffectHelper.cpp b/src/EffectsEngine/EffectHelper.cpp
index da8b1cb..d557a98 100644
--- a/src/EffectsEngine/EffectHelper.cpp
+++ b/src/EffectsEngine/EffectHelper.cpp
@@ -47,7 +47,6 @@ conv( std::string str, SettingValue::Type type )
EffectHelper::EffectHelper( const char* id, qint64 begin, qint64 end,
const QString &uuid ) :
Helper( uuid ),
- m_input( nullptr ),
m_filterInfo( nullptr )
{
try
@@ -72,7 +71,6 @@ EffectHelper::EffectHelper( const QString& id, qint64 begin, qint64 end, const Q
EffectHelper::EffectHelper( std::shared_ptr<Backend::IFilter> filter, const QString& uuid )
: Helper( uuid )
, m_filter( std::dynamic_pointer_cast<Backend::MLT::MLTFilter>( filter ) )
- , m_input( nullptr )
, m_filterInfo( nullptr )
{
if ( m_filter->isValid() == false )
@@ -218,7 +216,7 @@ EffectHelper::loadFromVariant( const QVariant& variant, Backend::IInput* input )
for ( auto& var : variant.toList() )
{
EffectHelper helper( var );
- input->attach( *helper.filter() );
+ helper.setTarget( input );
}
}
@@ -267,16 +265,7 @@ EffectHelper::isValid() const
void
EffectHelper::setTarget( Backend::IInput* input )
{
- if ( m_input )
- m_input->detach( *m_filter );
- m_input = input;
- m_input->attach( *m_filter );
-}
-
-Backend::IInput*
-EffectHelper::target()
-{
- return m_input;
+ input->attach( *m_filter );
}
Backend::IFilterInfo*
diff --git a/src/EffectsEngine/EffectHelper.h b/src/EffectsEngine/EffectHelper.h
index 45f8143..2212700 100644
--- a/src/EffectsEngine/EffectHelper.h
+++ b/src/EffectsEngine/EffectHelper.h
@@ -68,7 +68,6 @@ class EffectHelper : public Workflow::Helper
bool isValid() const;
void setTarget( Backend::IInput* input );
- Backend::IInput* target();
Backend::IFilterInfo* filterInfo();
@@ -89,7 +88,6 @@ class EffectHelper : public Workflow::Helper
private:
std::shared_ptr<Backend::MLT::MLTFilter> m_filter;
- Backend::IInput* m_input;
Backend::IFilterInfo* m_filterInfo;
Settings m_settings;
diff --git a/src/Gui/timeline/GraphicsEffectItem.cpp b/src/Gui/timeline/GraphicsEffectItem.cpp
index ec5b051..e768e40 100644
--- a/src/Gui/timeline/GraphicsEffectItem.cpp
+++ b/src/Gui/timeline/GraphicsEffectItem.cpp
@@ -359,9 +359,9 @@ GraphicsEffectItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
void
GraphicsEffectItem::setStartPos( qint64 position )
{
- if ( m_effectHelper != nullptr && m_effectHelper->target() != nullptr )
+ if ( m_effectHelper != nullptr && m_effectHelper->isValid() )
{
- int nbFilter = m_effectHelper->target()->filterCount() - 1;
+ int nbFilter = m_effectHelper->filter()->input()->filterCount() - 1;
QGraphicsItem::setPos( position, nbFilter * itemHeight() );
}
else
diff --git a/src/Gui/timeline/TracksScene.cpp b/src/Gui/timeline/TracksScene.cpp
index ad598fd..fcf0c56 100644
--- a/src/Gui/timeline/TracksScene.cpp
+++ b/src/Gui/timeline/TracksScene.cpp
@@ -128,7 +128,7 @@ TracksScene::askRemoveSelectedItems()
{
auto helper = std::static_pointer_cast<EffectHelper>( item->helper() );
Q_ASSERT( helper.get() != nullptr );
- Commands::trigger( new Commands::Effect::Remove( helper, helper->target() ) );
+ Commands::trigger( new Commands::Effect::Remove( helper ) );
}
}
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 35f652a..1a551e1 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -423,10 +423,10 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
auto clip = std::dynamic_pointer_cast<Clip>( item->helper() );
Q_ASSERT( clip.get() != nullptr );
+ m_dragEffectItem->effectHelper()->setTarget( clip->input() );
m_dragEffectItem->setWidth( item->clip()->length() );
m_dragEffectItem->setStartPos( item->startPos() );
m_dragEffectItem->setTrack( item->track() );
- m_dragEffectItem->effectHelper()->setTarget( clip->input() );
}
else
{
@@ -436,10 +436,10 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
GraphicsTrack *track = qgraphicsitem_cast<GraphicsTrack*>( item );
if ( track != nullptr && track->mediaType() == Workflow::VideoTrack )
{
+ m_dragEffectItem->effectHelper()->setTarget( track->trackWorkflow()->input() );
m_dragEffectItem->setWidth( m_dragEffectItem->helper()->length() );
m_dragEffectItem->setStartPos( 0 );
m_dragEffectItem->setTrack( track );
- m_dragEffectItem->effectHelper()->setTarget( track->trackWorkflow()->input() );
break ;
}
}
More information about the Vlmc-devel
mailing list