Commit cf47be8a authored by Marius Pa's avatar Marius Pa Committed by Julius Künzel
Browse files

jobs C++ new keyword does not return zero

Fix PVS-Studio issue "warning: V668 There is no sense in testing
the 'X' pointer against null, as the memory was allocated using
the 'new' operator. The exception will be generated in the case of
memory allocation error.
parent 6d70e304
Pipeline #199936 passed with stage
in 7 minutes and 25 seconds
......@@ -229,7 +229,7 @@ void RenderJob::start()
// Use of the KDE JobViewServer is an ugly hack, it is not reliable
QString dbusView = QStringLiteral("org.kde.JobViewV2");
m_jobUiserver = new QDBusInterface(QStringLiteral("org.kde.JobViewServer"), reply, dbusView);
if ((m_jobUiserver != nullptr) && m_jobUiserver->isValid()) {
if (m_jobUiserver->isValid()) {
if (!m_args.contains(QStringLiteral("pass=2"))) {
m_jobUiserver->call(QStringLiteral("setPercent"), 0);
}
......@@ -303,12 +303,10 @@ void RenderJob::initKdenliveDbusInterface()
m_kdenliveinterface =
new QDBusInterface(kdenliveId, QStringLiteral("/kdenlive/MainWindow_1"), QStringLiteral("org.kde.kdenlive.rendering"), connection, this);
if (m_kdenliveinterface) {
if (!m_args.contains(QStringLiteral("pass=2"))) {
m_kdenliveinterface->callWithArgumentList(QDBus::NoBlock, QStringLiteral("setRenderingProgress"), {m_dest, 0, 0});
}
connect(m_kdenliveinterface, SIGNAL(abortRenderJob(QString)), this, SLOT(slotAbort(QString)));
if (!m_args.contains(QStringLiteral("pass=2"))) {
m_kdenliveinterface->callWithArgumentList(QDBus::NoBlock, QStringLiteral("setRenderingProgress"), {m_dest, 0, 0});
}
connect(m_kdenliveinterface, SIGNAL(abortRenderJob(QString)), this, SLOT(slotAbort(QString)));
}
#endif
......
......@@ -1808,85 +1808,82 @@ void TimeRemap::setClip(std::shared_ptr<ProjectClip> clip, int in, int out)
return;
}
m_view->m_remapLink.reset();
if (clip != nullptr) {
bool keyframesLoaded = false;
int min = in == -1 ? 0 : in;
int max = out == -1 ? clip->getFramePlaytime() : out;
m_in->setRange(0, max - min);
m_out->setRange(min, INT_MAX);
m_view->m_startPos = 0;
m_view->setBinClipDuration(clip, max - min);
if (clip->clipType() == ClipType::Playlist) {
Mlt::Service service(clip->originalProducer()->producer()->get_service());
qDebug() << "==== producer type: " << service.type();
if (service.type() == mlt_service_multitrack_type) {
Mlt::Multitrack multi(service);
for (int i = 0; i < multi.count(); i++) {
std::unique_ptr<Mlt::Producer> track(multi.track(i));
qDebug() << "==== GOT TRACK TYPE: " << track->type();
switch (track->type()) {
case mlt_service_chain_type: {
Mlt::Chain fromChain(*track.get());
int count = fromChain.link_count();
for (int j = 0; j < count; j++) {
QScopedPointer<Mlt::Link> fromLink(fromChain.link(j));
if (fromLink && fromLink->is_valid() && fromLink->get("mlt_service")) {
if (fromLink->get("mlt_service") == QLatin1String("timeremap")) {
// Found a timeremap effect, read params
m_view->m_remapLink = std::make_shared<Mlt::Link>(fromChain.link(j)->get_link());
QString mapData(fromLink->get("map"));
m_view->loadKeyframes(mapData);
keyframesLoaded = true;
break;
}
bool keyframesLoaded = false;
int min = in == -1 ? 0 : in;
int max = out == -1 ? clip->getFramePlaytime() : out;
m_in->setRange(0, max - min);
m_out->setRange(min, INT_MAX);
m_view->m_startPos = 0;
m_view->setBinClipDuration(clip, max - min);
if (clip->clipType() == ClipType::Playlist) {
Mlt::Service service(clip->originalProducer()->producer()->get_service());
qDebug() << "==== producer type: " << service.type();
if (service.type() == mlt_service_multitrack_type) {
Mlt::Multitrack multi(service);
for (int i = 0; i < multi.count(); i++) {
std::unique_ptr<Mlt::Producer> track(multi.track(i));
qDebug() << "==== GOT TRACK TYPE: " << track->type();
switch (track->type()) {
case mlt_service_chain_type: {
Mlt::Chain fromChain(*track.get());
int count = fromChain.link_count();
for (int j = 0; j < count; j++) {
QScopedPointer<Mlt::Link> fromLink(fromChain.link(j));
if (fromLink && fromLink->is_valid() && fromLink->get("mlt_service")) {
if (fromLink->get("mlt_service") == QLatin1String("timeremap")) {
// Found a timeremap effect, read params
m_view->m_remapLink = std::make_shared<Mlt::Link>(fromChain.link(j)->get_link());
QString mapData(fromLink->get("map"));
m_view->loadKeyframes(mapData);
keyframesLoaded = true;
break;
}
}
break;
}
case mlt_service_playlist_type: {
// that is a single track
Mlt::Playlist local_playlist(*track);
int count = local_playlist.count();
qDebug() << "==== PLAYLIST COUNT: " << count;
if (count == 1) {
Mlt::Producer prod = local_playlist.get_clip(0)->parent();
qDebug() << "==== GOT PROD TYPE: " << prod.type() << " = " << prod.get("mlt_service") << " = " << prod.get("resource");
if (prod.type() == mlt_service_chain_type) {
Mlt::Chain fromChain(prod);
int linkCount = fromChain.link_count();
for (int j = 0; j < linkCount; j++) {
QScopedPointer<Mlt::Link> fromLink(fromChain.link(j));
if (fromLink && fromLink->is_valid() && fromLink->get("mlt_service")) {
if (fromLink->get("mlt_service") == QLatin1String("timeremap")) {
// Found a timeremap effect, read params
m_view->m_remapLink = std::make_shared<Mlt::Link>(fromChain.link(j)->get_link());
QString mapData(fromLink->get("map"));
m_view->loadKeyframes(mapData);
keyframesLoaded = true;
break;
}
break;
}
case mlt_service_playlist_type: {
// that is a single track
Mlt::Playlist local_playlist(*track);
int count = local_playlist.count();
qDebug() << "==== PLAYLIST COUNT: " << count;
if (count == 1) {
Mlt::Producer prod = local_playlist.get_clip(0)->parent();
qDebug() << "==== GOT PROD TYPE: " << prod.type() << " = " << prod.get("mlt_service") << " = " << prod.get("resource");
if (prod.type() == mlt_service_chain_type) {
Mlt::Chain fromChain(prod);
int linkCount = fromChain.link_count();
for (int j = 0; j < linkCount; j++) {
QScopedPointer<Mlt::Link> fromLink(fromChain.link(j));
if (fromLink && fromLink->is_valid() && fromLink->get("mlt_service")) {
if (fromLink->get("mlt_service") == QLatin1String("timeremap")) {
// Found a timeremap effect, read params
m_view->m_remapLink = std::make_shared<Mlt::Link>(fromChain.link(j)->get_link());
QString mapData(fromLink->get("map"));
m_view->loadKeyframes(mapData);
keyframesLoaded = true;
break;
}
}
}
}
break;
}
default:
qDebug() << "=== UNHANDLED TRACK TYPE";
break;
}
break;
}
default:
qDebug() << "=== UNHANDLED TRACK TYPE";
break;
}
}
}
if (!keyframesLoaded) {
m_view->loadKeyframes(QString());
}
m_seekConnection1 = connect(m_view, &RemapView::seekToPos, pCore->getMonitor(Kdenlive::ClipMonitor), &Monitor::requestSeek, Qt::UniqueConnection);
m_seekConnection2 = connect(pCore->getMonitor(Kdenlive::ClipMonitor), &Monitor::seekPosition, this, [&](int pos) { m_view->slotSetPosition(pos); });
remap_box->setEnabled(m_view->m_remapLink != nullptr);
} else {
remap_box->setEnabled(false);
}
if (!keyframesLoaded) {
m_view->loadKeyframes(QString());
}
m_seekConnection1 = connect(m_view, &RemapView::seekToPos, pCore->getMonitor(Kdenlive::ClipMonitor), &Monitor::requestSeek, Qt::UniqueConnection);
m_seekConnection2 = connect(pCore->getMonitor(Kdenlive::ClipMonitor), &Monitor::seekPosition, this, [&](int pos) { m_view->slotSetPosition(pos); });
remap_box->setEnabled(m_view->m_remapLink != nullptr);
}
void TimeRemap::updateKeyframes()
......
......@@ -45,11 +45,9 @@ void AudioLevelsTask::start(const ObjectId &owner, QObject *object, bool force)
return;
}
AudioLevelsTask *task = new AudioLevelsTask(owner, object);
if (task) {
// Otherwise, start a new audio levels generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
// Otherwise, start a new audio levels generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
void AudioLevelsTask::run()
......
......@@ -41,11 +41,9 @@ void CacheTask::start(const ObjectId &owner, int thumbsCount, int in, int out, Q
return;
}
CacheTask *task = new CacheTask(owner, thumbsCount, in, out, object);
if (task) {
// Otherwise, start a new audio levels generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
// Otherwise, start a new audio levels generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
void CacheTask::generateThumbnail(std::shared_ptr<ProjectClip> binClip)
......
......@@ -180,11 +180,9 @@ void CutTask::start(const ObjectId &owner, int in, int out, QObject *object, boo
}
}
CutTask *task = new CutTask(owner, path, encodingParams, in, out, KdenliveSettings::add_new_clip(), object);
if (task) {
// Otherwise, start a filter thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
// Otherwise, start a filter thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
void CutTask::run()
......
......@@ -44,11 +44,9 @@ void FilterTask::start(const ObjectId &owner, const QString &binId, const std::w
const std::unordered_map<QString, QString> &filterData, const QStringList &consumerArgs, QObject *object, bool force)
{
FilterTask *task = new FilterTask(owner, binId, model, assetId, in, out, filterName, filterParams, filterData, consumerArgs, object);
if (task) {
// Otherwise, start a filter thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
// Otherwise, start a filter thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
void FilterTask::run()
......
......@@ -35,11 +35,9 @@ void ProxyTask::start(const ObjectId &owner, QObject *object, bool force)
return;
}
ProxyTask *task = new ProxyTask(owner, object);
if (task) {
// Otherwise, start a new proxy generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
// Otherwise, start a new proxy generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
void ProxyTask::run()
......
Supports Markdown
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