Commit 1cb39f73 authored by Julius Künzel's avatar Julius Künzel
Browse files

CppCheck fixes Pt. 4

parent cc00a839
Pipeline #106719 passed with stage
in 6 minutes and 47 seconds
......@@ -30,9 +30,9 @@ public:
RenderJob::RenderJob(const QString &render, const QString &scenelist, const QString &target, int pid, int in, int out, QObject *parent)
: QObject(parent)
, m_scenelist(scenelist)
, m_dest(std::move(target))
, m_dest(target)
, m_progress(0)
, m_prog(std::move(render))
, m_prog(render)
, m_player()
#ifndef NODBUS
, m_jobUiserver(nullptr)
......@@ -41,7 +41,7 @@ RenderJob::RenderJob(const QString &render, const QString &scenelist, const QStr
, m_kdenlivesocket(new QLocalSocket(this))
#endif
, m_usekuiserver(true)
, m_logfile(target + QStringLiteral(".log"))
, m_logfile(m_dest + QStringLiteral(".log"))
, m_erase(scenelist.startsWith(QDir::tempPath()) || scenelist.startsWith(QString("xml:%2").arg(QDir::tempPath())))
, m_seconds(0)
, m_frame(in)
......
......@@ -736,7 +736,6 @@ bool KeyframeModel::hasKeyframe(const GenTime &pos) const
bool KeyframeModel::removeAllKeyframes(Fun &undo, Fun &redo)
{
QWriteLocker locker(&m_lock);
std::vector<GenTime> all_pos;
Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; };
int kfrCount = int(m_keyframeList.size()) - 1;
......@@ -768,9 +767,7 @@ bool KeyframeModel::removeAllKeyframes(Fun &undo, Fun &redo)
};
PUSH_LAMBDA(update_redo_start, local_redo);
PUSH_LAMBDA(update_undo_start, local_undo);
for (const auto &m : m_keyframeList) {
all_pos.push_back(m.first);
}
QList<GenTime> all_pos = getKeyframePos();
update_redo_start();
bool res = true;
bool first = true;
......
......@@ -144,7 +144,6 @@ void KeyframeView::slotAddRemove()
}
} else {
if (slotAddKeyframe(m_position)) {
int offset = pCore->getItemIn(m_model->getOwnerId());
GenTime position(m_position + offset, pCore->getCurrentFps());
int currentIx = m_model->getIndexForPos(position);
if (currentIx > -1) {
......@@ -456,8 +455,8 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event)
double fps = pCore->getCurrentFps();
int kfrIx = 0;
for (const auto &keyframe : *m_model.get()) {
int pos = keyframe.first.frames(fps) - offset;
if (pos > min && pos <= max) {
int kfPos = keyframe.first.frames(fps) - offset;
if (kfPos > min && kfPos <= max) {
m_model->appendSelectedKeyframe(kfrIx);
}
kfrIx++;
......
......@@ -49,7 +49,7 @@ public:
void setText(const QString &str) { m_label->setText(str); }
void slotRefresh() override {}
protected:
private:
QLabel *m_label;
};
......
......@@ -54,15 +54,11 @@ ButtonParamWidget::ButtonParamWidget(std::shared_ptr<AssetParameterModel> model,
}
}
QVector<QPair<QString, QVariant>> filterParams = m_model->getAllParameters();
m_displayConditional = true;
for (const auto &param : qAsConst(filterParams)) {
if (param.first == m_keyParam) {
if (!param.second.toString().isEmpty() && param.second.toString().contains(QLatin1Char(';'))) {
m_displayConditional = false;
}
break;
}
}
auto has_analyse_data = [&](const QPair<QString, QVariant>& param) {
return param.first == m_keyParam && !param.second.isNull() && param.second.toString().contains(QLatin1Char(';'));
};
m_displayConditional = std::none_of(filterParams.begin(), filterParams.end(), has_analyse_data);
if (!conditionalInfo.isEmpty()) {
m_label = new KMessageWidget(conditionalInfo, this);
m_label->setWordWrap(true);
......@@ -199,13 +195,11 @@ void ButtonParamWidget::slotShowComment(bool show)
void ButtonParamWidget::slotRefresh()
{
QVector<QPair<QString, QVariant>> filterParams = m_model->getAllParameters();
m_displayConditional = true;
for (const auto &param : qAsConst(filterParams)) {
if (param.first == m_keyParam && !param.second.isNull() && param.second.toString().contains(QLatin1Char(';'))) {
m_displayConditional = false;
break;
}
}
auto has_analyse_data = [&](const QPair<QString, QVariant>& param) {
return param.first == m_keyParam && !param.second.isNull() && param.second.toString().contains(QLatin1Char(';'));
};
m_displayConditional = std::none_of(filterParams.begin(), filterParams.end(), has_analyse_data);
if (m_label) {
m_label->setVisible(m_displayConditional);
}
......
......@@ -20,6 +20,7 @@ AudioLevelWidget::AudioLevelWidget(int width, QWidget *parent)
: QWidget(parent)
, audioChannels(pCore->audioChannels())
, m_width(width)
, m_offset(fontMetrics().boundingRect(QStringLiteral("-45")).width() + 5)
, m_channelWidth(width / 2)
, m_channelDistance(2)
, m_channelFillWidth(m_channelWidth)
......@@ -62,7 +63,6 @@ void AudioLevelWidget::drawBackground(int channels)
if (!newSize.isValid()) {
return;
}
m_offset = fontMetrics().boundingRect(QStringLiteral("-45")).width() + 5;
newSize.setWidth(newSize.width() - m_offset - 1);
QLinearGradient gradient(0, newSize.height(), 0, 0);
gradient.setColorAt(0.0, Qt::darkGreen);
......
......@@ -21,7 +21,6 @@ public:
~AudioLevelWidget() override;
void refreshPixmap();
int audioChannels;
bool isValid;
void setVisibility(bool enable);
protected:
......
......@@ -66,7 +66,6 @@ private:
QHBoxLayout *m_masterBox;
QHBoxLayout *m_channelsLayout;
QScrollArea *m_channelsBox;
int m_lastFrame;
bool m_visibleMixerManager;
int m_expandedWidth;
QVector <int> m_soloMuted;
......
......@@ -24,6 +24,9 @@ AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, QString id, const
, m_name()
, m_description()
, m_thumbnail(QIcon())
, m_parentDuration()
, m_inPoint()
, m_outPoint()
, m_date()
, m_binId(std::move(id))
, m_usage(0)
......
......@@ -47,8 +47,7 @@ void FileWatcher::removeFile(const QString &binId)
void FileWatcher::slotUrlModified(const QString &path)
{
if (m_modifiedUrls.count(path) == 0) {
m_modifiedUrls.insert(path);
if (m_modifiedUrls.insert(path).second) {
for (const QString &id : m_occurences[path]) {
emit binClipWaiting(id);
}
......
......@@ -69,7 +69,7 @@ RTTR_REGISTRATION
ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, const std::shared_ptr<ProjectItemModel> &model, std::shared_ptr<Mlt::Producer> producer)
: AbstractProjectItem(AbstractProjectItem::ClipItem, id, model)
, ClipController(id, std::move(producer))
, ClipController(id, producer)
, m_resetTimelineOccurences(false)
, m_audioCount(0)
{
......
......@@ -283,16 +283,13 @@ QVector<qreal> getBufferLevels(const QAudioBuffer &buffer)
if (buffer.format().sampleSize() == 8) {
values = getBufferLevels(buffer.constData<quint8>(), buffer.frameCount(), channelCount);
}
for (double &value : values) {
value = qAbs(value - peak_value / 2) / (peak_value / 2);
}
std::transform(values.begin(), values.end(), values.begin(),
[peak_value](double val) { return qAbs(val - peak_value / 2) / (peak_value / 2); });
break;
case QAudioFormat::Float:
if (buffer.format().sampleSize() == 32) {
values = getBufferLevels(buffer.constData<float>(), buffer.frameCount(), channelCount);
for (double &value : values) {
value /= peak_value;
}
std::transform(values.begin(), values.end(), values.begin(), [peak_value](double val) { return val / peak_value; });
}
break;
case QAudioFormat::SignedInt:
......@@ -305,9 +302,7 @@ QVector<qreal> getBufferLevels(const QAudioBuffer &buffer)
if (buffer.format().sampleSize() == 8) {
values = getBufferLevels(buffer.constData<qint8>(), buffer.frameCount(), channelCount);
}
for (double &value : values) {
value /= peak_value;
}
std::transform(values.begin(), values.end(), values.begin(), [peak_value](double val) { return val / peak_value; });
break;
}
return values;
......
......@@ -2134,8 +2134,8 @@ void KdenliveSettingsDialog::processArchive(const QString archiveFile)
}
} else {
// Test if it is a folder
QDir dir(archiveFile);
if (dir.exists()) {
QDir testDir(archiveFile);
if (testDir.exists()) {
}
qDebug()<<"=== CANNOT OPEN ARCHIVE!!";
......
......@@ -1796,8 +1796,8 @@ void TimeRemap::setClip(std::shared_ptr<ProjectClip> clip, int in, int out)
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 count = fromChain.link_count();
for (int j = 0; j < count; j++) {
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")) {
......
......@@ -1197,9 +1197,6 @@ void DocumentChecker::acceptDialog()
// prepare transitions
QDomNodeList trans = m_doc.elementsByTagName(QStringLiteral("transition"));
// prepare filters
QDomNodeList filters = m_doc.elementsByTagName(QStringLiteral("filter"));
// Mark document as modified
m_doc.documentElement().setAttribute(QStringLiteral("modified"), 1);
......
......@@ -888,7 +888,6 @@ void EffectStackModel::registerItem(const std::shared_ptr<TreeItem> &item)
} else if (effectId == QLatin1String("fadeout") || effectId == QLatin1String("fade_to_black")) {
m_fadeOuts.insert(effectItem->getId());
}
QModelIndex ix = getIndexFromItem(effectItem);
if (!effectItem->isAudio() && !m_loadingExisting) {
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
......
......@@ -73,7 +73,7 @@ AbstractTask::~AbstractTask()
{
}
bool AbstractTask::operator==(AbstractTask &b)
bool AbstractTask::operator==(const AbstractTask &b)
{
return m_owner == b.ownerId();
}
......
......@@ -38,7 +38,7 @@ public:
virtual ~AbstractTask();
static void closeAll();
const ObjectId ownerId() const;
bool operator==(AbstractTask& b);
bool operator==(const AbstractTask& b);
protected:
ObjectId m_owner;
......
......@@ -19,7 +19,6 @@ class CutTask : public AbstractTask
public:
CutTask(const ObjectId &owner, const QString &destination, const QStringList encodingParams, int in ,int out, bool addToProject, QObject* object);
static void start(const ObjectId &owner, int in , int out, QObject* object, bool force = false);
int length;
private slots:
void processLogInfo();
......
......@@ -24,6 +24,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
FilterTask::FilterTask(const ObjectId &owner, const QString &binId, std::weak_ptr<AssetParameterModel> model, const QString &assetId, int in, int out, QString filterName, std::unordered_map<QString, QVariant> filterParams, std::unordered_map<QString, QString> filterData, const QStringList consumerArgs, QObject* object)
: AbstractTask(owner, AbstractTask::FILTERCLIPJOB, object)
, length(0)
, m_binId(binId)
, m_inPoint(in)
, m_outPoint(out)
......
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