]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_transition.c
Mlt Ref Counts and Playlist split/join
[mlt] / src / framework / mlt_transition.c
index 7d4bc417d026236aef9770987d07573d78b8fa0d..13957752d2c39a5a1c428e0be31fa94f76c4b5fc 100644 (file)
@@ -45,6 +45,8 @@ int mlt_transition_init( mlt_transition this, void *child )
                mlt_properties properties = mlt_transition_properties( this );
 
                service->get_frame = transition_get_frame;
+               service->close = ( mlt_destructor )mlt_transition_close;
+               service->close_object = this;
 
                mlt_properties_set_position( properties, "in", 0 );
                mlt_properties_set_position( properties, "out", 0 );
@@ -72,7 +74,7 @@ mlt_transition mlt_transition_new( )
 
 mlt_service mlt_transition_service( mlt_transition this )
 {
-       return &this->parent;
+       return this != NULL ? &this->parent : NULL;
 }
 
 /** Get the properties interface.
@@ -230,8 +232,12 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i
 
 void mlt_transition_close( mlt_transition this )
 {
-       if ( this->close != NULL )
-               this->close( this );
-       else
-               mlt_service_close( &this->parent );
+       if ( this != NULL && mlt_properties_dec_ref( mlt_transition_properties( this ) ) <= 0 )
+       {
+               this->parent.close = NULL;
+               if ( this->close != NULL )
+                       this->close( this );
+               else
+                       mlt_service_close( &this->parent );
+       }
 }