Commits

Jean-Baptiste Mardelle  committed 2af4330

Fix moving transition sometimes losing properties: http://kdenlive.org/mantis/view.php?id=3025

  • Participants
  • Parent commits bf992ae

Comments (0)

Files changed (2)

File src/renderer.cpp

                 Mlt::Properties trans_props(transition.get_properties());
                 Mlt::Transition new_transition(*m_mltProfile, transition.get("mlt_service"));
                 Mlt::Properties new_trans_props(new_transition.get_properties());
-                new_trans_props.inherit(trans_props);
-                new_transition.set_in_and_out(new_in, new_out);
+		// We cannot use MLT's property inherit because it also clones internal values like _unique_id which messes up the playlist
+		cloneProperties(new_trans_props, trans_props);
+		new_transition.set_in_and_out(new_in, new_out);
                 field->disconnect_service(transition);
                 mltPlantTransition(field, new_transition, newTransitionTrack, newTrack);
-                //field->plant_transition(new_transition, newTransitionTrack, newTrack);
             } else transition.set_in_and_out(new_in, new_out);
             break;
         }
     return found;
 }
 
+void Render::cloneProperties(Mlt::Properties &dest, Mlt::Properties &source)
+{
+    	int count = source.count();
+	int i = 0;
+	for ( i = 0; i < count; i ++ )
+	{
+		char *value = source.get(i);
+		if ( value != NULL )
+		{
+			char *name = source.get_name( i );
+			if (name != NULL && name[0] != '_') dest.set(name, value);
+		}
+	}
+}
 
 void Render::mltPlantTransition(Mlt::Field *field, Mlt::Transition &tr, int a_track, int b_track)
 {
             Mlt::Properties trans_props(transition.get_properties());
             Mlt::Transition *cp = new Mlt::Transition(*m_mltProfile, transition.get("mlt_service"));
             Mlt::Properties new_trans_props(cp->get_properties());
-            new_trans_props.inherit(trans_props);
+            //new_trans_props.inherit(trans_props);
+	    cloneProperties(new_trans_props, trans_props);
             trList.append(cp);
             field->disconnect_service(transition);
         }
 	    Mlt::Properties trans_props(transition.get_properties());
 	    Mlt::Transition *cp = new Mlt::Transition(*m_mltProfile, transition.get("mlt_service"));
 	    Mlt::Properties new_trans_props(cp->get_properties());
-	    new_trans_props.inherit(trans_props);
+	    cloneProperties(new_trans_props, trans_props);
+	    //new_trans_props.inherit(trans_props);
 	    
 	    if (trackChanged) {
 		// Transition track needs to be adjusted

File src/renderer.h

 {
 class Consumer;
 class Playlist;
+class Properties;
 class Tractor;
 class Transition;
 class Frame;
     void fixAudioMixing(Mlt::Tractor tractor);
     /** @brief Make sure we inform MLT if we need a lot of threads for avformat producer */
     void checkMaxThreads();
+    /** @brief Clone serialisable properties only */
+    void cloneProperties(Mlt::Properties &dest, Mlt::Properties &source);
 
 private slots: