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

Solved segfaults ( when moving track, when closing the soft )

I finally renamed a method starting by m_, this was pissing me off for weeks :)
This solves the random crash due to letting Qt delete the main workflow. MainWorkflow is a QObject, but
it's not Qt's job to decide when to delete it, since it used by at least 2 widgets which are deleted in an
arbitrary order...
parent 9711575e
......@@ -28,8 +28,7 @@
unsigned char* MainWorkflow::blackOutput = NULL;
MainWorkflow* MainWorkflow::m_instance = NULL;
MainWorkflow::MainWorkflow( QObject* parent, int trackCount ) :
QObject( parent ),
MainWorkflow::MainWorkflow( int trackCount ) :
m_length( 0 ),
m_trackCount( trackCount ),
m_renderStarted( false )
......@@ -52,6 +51,8 @@ MainWorkflow::MainWorkflow( QObject* parent, int trackCount ) :
MainWorkflow::~MainWorkflow()
{
stop();
delete m_renderStartedLock;
for (unsigned int i = 0; i < m_trackCount; ++i)
delete m_tracks[i];
......@@ -191,13 +192,12 @@ void MainWorkflow::stop()
m_renderStarted = false;
for (unsigned int i = 0; i < m_trackCount; ++i)
{
//FIXME: After debugging period, this should'nt be necessary --
m_tracks[i].activate();
//--------
m_tracks[i]->stop();
if ( m_tracks[i].activated() == true )
m_tracks[i]->stop();
}
m_currentFrame = 0;
emit frameChanged( 0 );
qDebug() << "Stopped main workflow";
}
MainWorkflow* MainWorkflow::getInstance()
......@@ -206,6 +206,15 @@ MainWorkflow* MainWorkflow::getInstance()
return m_instance;
}
void MainWorkflow::deleteInstance()
{
if ( m_instance != NULL )
{
delete m_instance;
m_instance = NULL;
}
}
void MainWorkflow::clipMoved( QUuid clipUuid, int oldTrack, int newTrack, qint64 startingFrame )
{
Q_ASSERT( newTrack < m_trackCount && oldTrack < m_trackCount && oldTrack >= 0 && newTrack >= 0 );
......
......@@ -36,7 +36,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
Q_OBJECT
public:
MainWorkflow( QObject* parent, int trackCount );
MainWorkflow( int trackCount );
~MainWorkflow();
void addClip( Clip* clip, unsigned int trackId, qint64 start );
......@@ -77,6 +77,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void activateOneFrameOnly();
static MainWorkflow* getInstance();
static void deleteInstance();
private:
static MainWorkflow* m_instance;
......
......@@ -67,7 +67,10 @@ void TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
void TrackWorkflow::computeLength()
{
if ( m_clips.count() == 0 )
{
m_length = 0;
return ;
}
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
m_length = (it.key() + it.value()->getClip()->getLength() );
}
......@@ -199,11 +202,15 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
}
else if ( cw->getState() == ClipWorkflow::Rendering )
{
qDebug() << "Stopping while rendering";
cw->getStateLock()->unlock();
qDebug() << "Waiting complete render";
cw->waitForCompleteRender();
qDebug() << "Waited ok.";
cw->queryStateChange( ClipWorkflow::Stopping );
cw->wake();
cw->stop();
qDebug() << "Stopped clip workflow";
}
else if ( cw->getState() == ClipWorkflow::Initializing )
{
......
......@@ -45,7 +45,7 @@ MainWindow::MainWindow( QWidget *parent ) :
{
m_ui.setupUi( this );
DockWidgetManager::instance( this )->setMainWindow( this );
m_initializeDockWidgets();
initializeDockWidgets();
createStatusBar();
// Translation
......@@ -133,7 +133,7 @@ void MainWindow::createStatusBar()
m_ui.statusbar->addPermanentWidget( m_zoomSlider );
}
void MainWindow::m_initializeDockWidgets( void )
void MainWindow::initializeDockWidgets( void )
{
m_timeline = new Timeline( this );
m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
......@@ -160,6 +160,7 @@ void MainWindow::m_initializeDockWidgets( void )
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
dockManager->addDockedWidget( new QUndoView( UndoStack::getInstance(), this),
tr( "History" ),
Qt::AllDockWidgetAreas,
......
......@@ -53,7 +53,7 @@ protected:
virtual void changeEvent( QEvent *e );
private:
void m_initializeDockWidgets( void );
void initializeDockWidgets( void );
void setupLibrary();
void createStatusBar();
......
......@@ -59,6 +59,7 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
PreviewWidget::~PreviewWidget()
{
delete m_renderer;
delete m_ui;
}
......
......@@ -36,7 +36,7 @@ Timeline::Timeline( QWidget *parent ) :
m_instance = this;
m_ui.setupUi( this );
m_mainWorkflow = new MainWorkflow( this, MAX_TRACKS );
m_mainWorkflow = new MainWorkflow( MAX_TRACKS );
m_tracksScene = new TracksScene( this );
m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame );
......
......@@ -76,6 +76,7 @@ WorkflowRenderer::~WorkflowRenderer()
disconnect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
delete m_media;
delete m_mainWorkflow;
}
void* WorkflowRenderer::lock( void* datas )
......
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