Commit 5c1662ac authored by Vincent Pinon's avatar Vincent Pinon

Fix use after free

CID 1323741, 1323740
parent d14bd6f0
......@@ -1017,8 +1017,8 @@ void Monitor::slotLoopClip()
void Monitor::updateClipProducer(Mlt::Producer *prod)
{
if (render == NULL) return;
render->setProducer(prod, -1, false);
if (prod) prod->set_speed(1.0);
if (render->setProducer(prod, -1, false))
prod->set_speed(1.0);
}
void Monitor::updateClipProducer(const QString &playlist)
......@@ -1464,9 +1464,10 @@ void Monitor::slotSwitchRec(bool enable)
bool Monitor::startCapture(const QString &params, const QString &path, Mlt::Producer *p)
{
m_controller = NULL;
render->updateProducer(p);
m_glMonitor->reconfigureMulti(params, path, p->profile());
return true;
if (render->updateProducer(p)) {
m_glMonitor->reconfigureMulti(params, path, p->profile());
return true;
} else return false;
}
bool Monitor::stopCapture()
......
......@@ -1041,7 +1041,7 @@ void Render::loadUrl(const QString &url)
setProducer(producer, 0, true);
}
int Render::updateProducer(Mlt::Producer *producer)
bool Render::updateProducer(Mlt::Producer *producer)
{
if (m_mltProducer) {
if (strcmp(m_mltProducer->get("resource"), "<tractor>") == 0) {
......@@ -1060,10 +1060,7 @@ int Render::updateProducer(Mlt::Producer *producer)
}
}
if (!producer || !producer->is_valid()) {
if (producer) delete producer;
producer = m_blackClip->cut(0, 1);
producer->set("id", "black");
return -1;
return false;
}
m_fps = producer->get_fps();
m_mltProducer = producer;
......@@ -1071,10 +1068,10 @@ int Render::updateProducer(Mlt::Producer *producer)
m_qmlView->setProducer(producer, false);
m_mltConsumer = m_qmlView->consumer();
}
return 0;
return true;
}
int Render::setProducer(Mlt::Producer *producer, int position, bool isActive)
bool Render::setProducer(Mlt::Producer *producer, int position, bool isActive)
{
m_refreshTimer.stop();
requestedSeekPosition = SEEK_INACTIVE;
......@@ -1104,13 +1101,8 @@ int Render::setProducer(Mlt::Producer *producer, int position, bool isActive)
}
blockSignals(true);
if (!producer || !producer->is_valid()) {
if (producer) delete producer;
producer = m_blackClip->cut(0, 1);
producer->set("id", "black");
}
if (!producer || !producer->is_valid()) {
qDebug() << " WARNING - - - - -INVALID PLAYLIST: ";
return -1;
qWarning() << "Invalid playlist";
return false;
}
emit stopped();
......@@ -1133,7 +1125,7 @@ int Render::setProducer(Mlt::Producer *producer, int position, bool isActive)
emit durationChanged(m_mltProducer->get_playtime(), m_mltProducer->get_in());
position = m_mltProducer->position();
emit rendererPosition(position);
return 0;
return true;
}
void Render::startConsumer() {
......
......@@ -125,8 +125,8 @@ class Render: public AbstractRender
*
* Creates the producer from the text playlist. */
int setSceneList(QString playlist, int position = 0);
int updateProducer(Mlt::Producer *producer);
int setProducer(Mlt::Producer *producer, int position, bool isActive);
bool updateProducer(Mlt::Producer *producer);
bool setProducer(Mlt::Producer *producer, int position, bool isActive);
/** @brief Get the current MLT producer playlist.
* @return A string describing the playlist */
......
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