Commit d3bb2cb2 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved potential crash.

When a clip was splitted, and the operation undone, every other operation that was relying on the new clip was screwed, as this clip was deleted each time the split operation was undone.
parent 4a4422c3
......@@ -157,19 +157,22 @@ Commands::MainWorkflow::SplitClip::SplitClip( WorkflowRenderer* renderer, Clip*
m_clipOldEnd( toSplit->getEnd() ),
m_trackType( trackType )
{
m_clipOldEnd = m_toSplit->getEnd();
setText( QObject::tr("Splitting clip") );
}
void Commands::MainWorkflow::SplitClip::redo()
Commands::MainWorkflow::SplitClip::~SplitClip()
{
Q_ASSERT( m_newClip == NULL );
if ( m_newClip != NULL )
delete m_newClip;
}
m_clipOldEnd = m_toSplit->getEnd();
m_newClip = m_renderer->split( m_toSplit, m_trackId, m_newClipPos, m_newClipBegin, m_trackType );
void Commands::MainWorkflow::SplitClip::redo()
{
m_newClip = m_renderer->split( m_toSplit, m_newClip, m_trackId, m_newClipPos, m_newClipBegin, m_trackType );
}
void Commands::MainWorkflow::SplitClip::undo()
{
m_renderer->unsplit( m_toSplit, m_newClip, m_trackId, m_clipOldEnd, m_trackType );
m_newClip = NULL;
}
......@@ -136,6 +136,7 @@ namespace Commands
public:
SplitClip( WorkflowRenderer* renderer, Clip* toSplit, uint32_t trackId,
qint64 newClipPos, qint64 newClipBegin, ::MainWorkflow::TrackType trackType );
~SplitClip();
virtual void redo();
virtual void undo();
private:
......
......@@ -135,7 +135,6 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
void AbstractGraphicsMediaItem::adjustLength()
{
qDebug() << "Resize event. m_resizeExpected:" << m_resizeExpected;
if ( m_resizeExpected == true )
{
m_resizeExpected = false;
......
......@@ -26,6 +26,7 @@
#include <QMessageBox>
#include <QApplication>
#include <errno.h>
#include <signal.h>
#include "ProjectManager.h"
......
......@@ -266,9 +266,10 @@ void WorkflowRenderer::rulerCursorChanged( qint64 newFrame )
m_mainWorkflow->setCurrentFrame( newFrame, MainWorkflow::RulerCursor );
}
Clip* WorkflowRenderer::split( Clip* toSplit, uint32_t trackId, qint64 newClipPos, qint64 newClipBegin, MainWorkflow::TrackType trackType )
Clip* WorkflowRenderer::split( Clip* toSplit, Clip* newClip, uint32_t trackId, qint64 newClipPos, qint64 newClipBegin, MainWorkflow::TrackType trackType )
{
Clip* newClip = new Clip( toSplit, newClipBegin, toSplit->getEnd() );
if ( newClip == NULL )
newClip = new Clip( toSplit, newClipBegin, toSplit->getEnd() );
if ( m_isRendering == true )
{
......@@ -307,7 +308,7 @@ void WorkflowRenderer::unsplit( Clip* origin, Clip* splitted, uint32_t trackI
}
else
{
delete m_mainWorkflow->removeClip( splitted->getUuid(), trackId, trackType );
m_mainWorkflow->removeClip( splitted->getUuid(), trackId, trackType );
origin->setEnd( oldEnd );
}
}
......
......@@ -51,7 +51,18 @@ class WorkflowRenderer : public GenericRenderer
virtual float getFps() const;
void addClip( Clip* clip, uint32_t trackId, qint64 startingPos, MainWorkflow::TrackType trackType );
void removeClip( const QUuid& uuid, uint32_t trackId, MainWorkflow::TrackType trackType );
Clip* split( Clip* toSplit, uint32_t trackId, qint64 newClipPos, qint64 newClipBegin, MainWorkflow::TrackType trackType );
/**
* \brief Will split a clip and return the created clip, resulting of the split operation.
* \param toSplit The clip to split
* \param newClip If the "toSplit" clip already has been splitted, this is the clip resulting
* from the previous split operation. This prevent creating and deleting clip that could be used elsewhere.
* \param trackId The track containing the clip
* \param newClipPos The position of the "newClip" on the timeline.
* \param newClipBegin The starting frame (from the beginning of the clip's parent media)
* \param trackType The track type (audio or video)
* \return The newly created clip if "newClip" was NULL; else, newClip is returned.
*/
Clip* split( Clip* toSplit, Clip* newClip, uint32_t trackId, qint64 newClipPos, qint64 newClipBegin, MainWorkflow::TrackType trackType );
void unsplit( Clip* origin, Clip* splitted, uint32_t trackId, qint64 oldEnd, MainWorkflow::TrackType trackType );
/**
* \param undoRedoAction: if true, the potential move resulting from the resize will be emmited to the GUI.
......
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