Commit 9cc5dbf9 authored by Nicolas Carion's avatar Nicolas Carion

Revert "Fix some leaks in glwidget. cf #80"

This reverts commit a17762a3.
parent a17762a3
......@@ -416,7 +416,4 @@ void fuzz(const std::string &input)
pCore->m_projectManager = nullptr;
Core::m_self.reset();
MltConnection::m_self.reset();
std::cout << "---------------------------------------------------------------------------------------------------------------------------------------------"
"---------------"
<< std::endl;
}
......@@ -615,7 +615,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int clipId, Play
resource = m_service;
}
QString url = QString("timewarp:%1:%2").arg(locale.toString(speed)).arg(resource);
warpProducer.reset(new Mlt::Producer(originalProducer()->get_profile(), url.toUtf8().constData()));
warpProducer.reset(new Mlt::Producer(*originalProducer()->profile(), url.toUtf8().constData()));
qDebug() << "new producer: " << url;
qDebug() << "warp LENGTH before" << warpProducer->get_length();
int original_length = originalProducer()->get_length();
......
......@@ -130,7 +130,7 @@ GLWidget::GLWidget(int id, QObject *parent)
m_blackClip->set("kdenlive:id", "black");
m_blackClip->set("out", 3);
connect(&m_refreshTimer, &QTimer::timeout, this, &GLWidget::refresh);
m_producer = m_blackClip;
m_producer = &*m_blackClip;
if (!initGPUAccel()) {
disableGPUAccel();
......@@ -664,7 +664,7 @@ void GLWidget::wheelEvent(QWheelEvent *event)
void GLWidget::requestSeek()
{
if (!m_producer) {
if (m_producer == nullptr) {
return;
}
if (m_proxy->seeking()) {
......@@ -699,7 +699,7 @@ void GLWidget::seek(int pos)
void GLWidget::requestRefresh()
{
if (m_producer && qFuzzyIsNull(m_producer->get_speed())) {
if ((m_producer != nullptr) && qFuzzyIsNull(m_producer->get_speed())) {
m_refreshTimer.start();
}
}
......@@ -912,23 +912,23 @@ void GLWidget::slotSwitchAudioOverlay(bool enable)
{
KdenliveSettings::setDisplayAudioOverlay(enable);
if (m_audioWaveDisplayed && !enable) {
if (m_producer && m_producer->get_int("video_index") != -1) {
if ((m_producer != nullptr) && m_producer->get_int("video_index") != -1) {
// We have a video producer, disable filter
removeAudioOverlay();
}
}
if (enable && !m_audioWaveDisplayed && m_producer) {
if (enable && !m_audioWaveDisplayed && m_producer != nullptr) {
createAudioOverlay(m_producer->get_int("video_index") == -1);
}
}
int GLWidget::setProducer(std::shared_ptr<Mlt::Producer> producer, bool isActive, int position)
int GLWidget::setProducer(Mlt::Producer *producer, bool isActive, int position)
{
int error = 0;
QString currentId;
int consumerPosition = 0;
currentId = m_producer->parent().get("kdenlive:id");
if (producer) {
if (producer != nullptr) {
m_producer = producer;
} else {
if (currentId == QLatin1String("black")) {
......@@ -937,7 +937,7 @@ int GLWidget::setProducer(std::shared_ptr<Mlt::Producer> producer, bool isActive
if (m_audioWaveDisplayed) {
removeAudioOverlay();
}
m_producer = m_blackClip;
m_producer = &*m_blackClip;
}
// redundant check. postcondition of above is m_producer != null
if (m_producer) {
......@@ -1163,7 +1163,7 @@ int GLWidget::reconfigureMulti(const QString &params, const QString &path, Mlt::
// A & B
m_displayEvent = m_consumer->listen("consumer-frame-show", this, (mlt_listener)on_frame_show);
}
m_consumer->connect(*m_producer.get());
m_consumer->connect(*m_producer);
m_consumer->start();
return 0;
}
......@@ -1241,7 +1241,7 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
if (m_consumer->is_valid()) {
// Connect the producer to the consumer - tell it to "run" later
if (m_producer) {
m_consumer->connect(*m_producer.get());
m_consumer->connect(*m_producer);
// m_producer->set_speed(0.0);
}
int dropFrames = realTime();
......@@ -1786,7 +1786,7 @@ void GLWidget::refreshSceneLayout()
void GLWidget::switchPlay(bool play, double speed)
{
m_proxy->setSeekPosition(-1);
if (!m_producer || !m_consumer) {
if ((m_producer == nullptr) || (m_consumer == nullptr)) {
return;
}
if (m_isZoneMode) {
......@@ -1943,7 +1943,7 @@ void GLWidget::setDropFrames(bool drop)
int GLWidget::volume() const
{
if ((!m_consumer) || (!m_producer)) {
if ((m_consumer == nullptr) || (m_producer == nullptr)) {
return -1;
}
if (m_consumer->get("mlt_service") == QStringLiteral("multi")) {
......@@ -1965,7 +1965,7 @@ void GLWidget::setVolume(double volume)
int GLWidget::duration() const
{
if (!m_producer) {
if (m_producer == nullptr) {
return 0;
}
return m_producer->get_playtime();
......
......@@ -150,7 +150,7 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
/** @brief Update producer, should ONLY be called from monitor */
int setProducer(std::shared_ptr<Mlt::Producer> producer, bool isActive, int position = -1);
int setProducer(Mlt::Producer *producer, bool isActive, int position = -1);
QString frameToTime(int frames) const;
public slots:
......@@ -196,7 +196,7 @@ protected:
// keeping this for refactoring ease.
QMutex m_mltMutex;
std::shared_ptr<Mlt::Consumer> m_consumer;
std::shared_ptr<Mlt::Producer> m_producer;
Mlt::Producer *m_producer;
Mlt::Profile *m_monitorProfile;
int m_id;
int m_rulerHeight;
......@@ -231,7 +231,7 @@ private:
QPoint m_offset;
bool m_audioWaveDisplayed;
MonitorProxy *m_proxy;
std::shared_ptr<Mlt::Producer> m_blackClip;
QScopedPointer<Mlt::Producer> m_blackClip;
static void on_frame_show(mlt_consumer, void *self, mlt_frame frame);
static void on_gl_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr);
static void on_gl_nosync_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr);
......
......@@ -363,6 +363,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
Monitor::~Monitor()
{
delete m_splitEffect;
delete m_splitProducer;
delete m_audioMeterWidget;
delete m_glMonitor;
delete m_videoWidget;
......@@ -1325,7 +1326,7 @@ void Monitor::slotLoopClip()
}
}
void Monitor::updateClipProducer(std::shared_ptr<Mlt::Producer> prod)
void Monitor::updateClipProducer(Mlt::Producer *prod)
{
if (m_glMonitor->setProducer(prod, isActive(), -1)) {
prod->set_speed(1.0);
......@@ -1379,7 +1380,7 @@ void Monitor::slotOpenClip(std::shared_ptr<ProjectClip> controller, int in, int
if (m_playAction->isActive()) {
m_playAction->setActive(false);
}
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), in);
m_glMonitor->setProducer(m_controller->originalProducer().get(), isActive(), in);
m_audioMeterWidget->audioChannels = controller->audioInfo() ? controller->audioInfo()->channels() : 0;
m_glMonitor->setAudioThumb(controller->audioChannels(), controller->audioFrameCache);
m_controller->getMarkerModel()->registerSnapModel(m_snaps);
......@@ -1825,9 +1826,9 @@ void Monitor::slotSwitchCompare(bool enable)
buildSplitEffect(m_controller->masterProducer());
} else if (m_splitEffect) {
// TODO
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), position());
m_glMonitor->setProducer(m_controller->originalProducer().get(), isActive(), position());
delete m_splitEffect;
m_splitProducer.reset();
m_splitProducer = nullptr;
m_splitEffect = nullptr;
loadQmlScene(MonitorSceneDefault);
}
......@@ -1877,7 +1878,7 @@ void Monitor::buildSplitEffect(Mlt::Producer *original)
t.set("always_active", 1);
trac.plant_transition(t, 0, 1);
delete original;
m_splitProducer = std::make_shared<Mlt::Producer>(trac.get_producer());
m_splitProducer = new Mlt::Producer(trac.get_producer());
m_glMonitor->setProducer(m_splitProducer, isActive(), position());
m_glMonitor->setRulerInfo((int)m_controller->frameDuration(), m_controller->getMarkerModel());
loadQmlScene(MonitorSceneSplit);
......@@ -2081,7 +2082,7 @@ void Monitor::requestSeek(int pos)
m_glMonitor->seek(pos);
}
void Monitor::setProducer(std::shared_ptr<Mlt::Producer> producer, int pos)
void Monitor::setProducer(Mlt::Producer *producer, int pos)
{
m_glMonitor->setProducer(producer, isActive(), pos);
}
......
......@@ -152,7 +152,7 @@ public:
void activateSplit();
/** @brief Clear monitor display **/
void clearDisplay();
void setProducer(std::shared_ptr<Mlt::Producer> producer, int pos = -1);
void setProducer(Mlt::Producer *producer, int pos = -1);
void reconfigure();
/** @brief Saves current monitor frame to an image file, and add it to project if addToProject is set to true **/
void slotExtractCurrentFrame(QString frameName = QString(), bool addToProject = false);
......@@ -198,7 +198,7 @@ private:
std::shared_ptr<SnapModel> m_snaps;
Mlt::Filter *m_splitEffect;
std::shared_ptr<Mlt::Producer> m_splitProducer;
Mlt::Producer *m_splitProducer;
int m_length;
bool m_dragStarted;
// TODO: Move capture stuff in own class
......@@ -280,7 +280,7 @@ private slots:
public slots:
void slotOpenDvdFile(const QString &);
// void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
void updateClipProducer(std::shared_ptr<Mlt::Producer> prod);
void updateClipProducer(Mlt::Producer *prod);
void updateClipProducer(const QString &playlist);
void slotOpenClip(std::shared_ptr<ProjectClip> controller, int in = -1, int out = -1);
void slotRefreshMonitor(bool visible);
......
......@@ -407,8 +407,8 @@ void RecManager::slotPreview(bool preview)
{
if (m_device_selector->currentData().toInt() == Video4Linux) {
if (preview) {
std::shared_ptr<Mlt::Producer> prod(createV4lProducer());
if (prod && prod->is_valid()) {
Mlt::Producer *prod = createV4lProducer();
if ((prod != nullptr) && prod->is_valid()) {
m_monitor->updateClipProducer(prod);
} else {
emit warningMessage(i18n("Capture crashed, please check your parameters"));
......
......@@ -106,7 +106,7 @@ std::unique_ptr<ProfileModel> &ProfileRepository::getProfile(const QString &path
{
QReadLocker locker(&m_mutex);
if (m_profiles.count(path) == 0) {
// qCWarning(KDENLIVE_LOG) << "//// WARNING: profile not found: " << path << ". Returning default profile instead.";
qCWarning(KDENLIVE_LOG) << "//// WARNING: profile not found: " << path << ". Returning default profile instead.";
QString default_profile = KdenliveSettings::default_profile();
if (m_profiles.count(default_profile) == 0) {
qCWarning(KDENLIVE_LOG) << "//// WARNING: default profile not found: " << default_profile << ". Returning random profile instead.";
......
......@@ -663,7 +663,5 @@ bool ClipModel::checkConsistency()
qDebug() << "ERROR: clip is in video state but doesn't have video";
return false;
}
// TODO: check speed
return true;
}
......@@ -2633,9 +2633,10 @@ void TimelineModel::setTimelineEffectsEnabled(bool enabled)
// TODO if we support track effects, they should be disabled here too
}
std::shared_ptr<Mlt::Producer> TimelineModel::producer()
Mlt::Producer *TimelineModel::producer()
{
return std::make_shared<Mlt::Producer>(tractor());
auto *prod = new Mlt::Producer(tractor());
return prod;
}
void TimelineModel::checkRefresh(int start, int end)
......
......@@ -168,7 +168,7 @@ public:
/* @brief Returns the current tractor's producer, useful fo control seeking, playing, etc
*/
std::shared_ptr<Mlt::Producer> producer();
Mlt::Producer *producer();
Mlt::Profile *getProfile();
/* @brief returns the number of tracks */
......
......@@ -82,7 +82,6 @@ TEST_CASE("Effects stack", "[Effects]")
REQUIRE(model->rowCount() == 1);
}
/*
SECTION("Create cut with fade in")
{
auto clipModel = timeline->getClipPtr(cid1)->m_effectStack;
......@@ -114,5 +113,4 @@ TEST_CASE("Effects stack", "[Effects]")
REQUIRE(clipModel->rowCount() == 0);
REQUIRE(splitModel->rowCount() == 1);
}
*/
}
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