Commit 3853a4af authored by Julius Künzel's avatar Julius Künzel
Browse files

CppCheck fixes Pt. 2

parent 128fb884
......@@ -665,7 +665,7 @@ bool KeyframeModel::singleKeyframe() const
Keyframe KeyframeModel::getKeyframe(const GenTime &pos, bool *ok) const
{
READ_LOCK();
if (m_keyframeList.count(pos) <= 0) {
if (m_keyframeList.count(pos) == 0) {
// return empty marker
*ok = false;
return {GenTime(), KeyframeType::Linear};
......@@ -1408,9 +1408,8 @@ bool KeyframeModel::removeNextKeyframes(GenTime pos, Fun &undo, Fun &redo)
PUSH_LAMBDA(update_redo_start, local_redo);
PUSH_LAMBDA(update_undo_start, local_undo);
update_redo_start();
bool res = true;
for (const auto &p : all_pos) {
res = removeKeyframe(p, local_undo, local_redo, false);
bool res = removeKeyframe(p, local_undo, local_redo, false);
if (!res) {
bool undone = local_undo();
Q_ASSERT(undone);
......
......@@ -1022,7 +1022,7 @@ QJsonDocument AssetParameterModel::valueAsJson(int pos, bool includeFixed) const
double x, y, w, h;
int count = 0;
for (const auto &param : m_params) {
if (!includeFixed && param.second.type != ParamType::KeyframeParam && param.second.type != ParamType::AnimatedRect && param.second.type != ParamType::AnimatedRect) {
if (!includeFixed && param.second.type != ParamType::KeyframeParam && param.second.type != ParamType::AnimatedRect && param.second.type != ParamType::ColorWheel) {
continue;
}
......
......@@ -19,8 +19,8 @@ CubicBezierSpline::CubicBezierSpline()
}
CubicBezierSpline::CubicBezierSpline(const CubicBezierSpline &spline)
: m_points(spline.m_points)
{
m_points = spline.m_points;
}
CubicBezierSpline &CubicBezierSpline::operator=(const CubicBezierSpline &spline) = default;
......
......@@ -33,17 +33,16 @@
KisCurveWidget::KisCurveWidget(QWidget *parent)
: AbstractCurveWidget(parent)
, m_grabOffsetX(0)
, m_grabOffsetY(0)
, m_grabOriginalX(0)
, m_grabOriginalY(0)
, m_draggedAwayPointIndex(0)
, m_guideVisible(false)
{
setObjectName(QStringLiteral("KisCurveWidget"));
m_guideVisible = false;
m_maxPoints = -1;
m_grabOffsetX = 0;
m_grabOffsetY = 0;
m_grabOriginalX = 0;
m_grabOriginalY = 0;
m_draggedAwayPointIndex = 0;
m_pixmapIsDirty = false;
m_pixmapCache = nullptr;
m_maxPoints = 0;
......
......@@ -602,9 +602,8 @@ QString KeyframeImport::selectedData() const
anim2->interpolate();
int length = lastKeyframe;
double interval = double(length) / (m_limitNumber->value() - 1);
int pos = 0;
for (int i = 0; i < m_limitNumber->value(); i++) {
pos = firstKeyframe + in + i * interval;
int pos = firstKeyframe + in + i * interval;
pos = qMin(pos, length - 1);
double dval = animData->anim_get_double("key", pos);
animData2->anim_set("key", dval, pos);
......@@ -652,9 +651,8 @@ QString KeyframeImport::selectedData() const
anim2->interpolate();
int length = lastKeyframe - firstKeyframe;
double interval = double(length) / (m_limitNumber->value() - 1);
int pos = 0;
for (int i = 0; i < m_limitNumber->value(); i++) {
pos = firstKeyframe + i * interval;
int pos = firstKeyframe + i * interval;
pos = qMin(pos, lastKeyframe);
mlt_rect rect = animData->anim_get_rect("key", pos);
animData2->anim_set("key", rect, pos);
......
......@@ -840,7 +840,6 @@ bool ProjectItemModel::requestCleanupUnused()
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool res = true;
std::vector<std::shared_ptr<AbstractProjectItem>> to_delete;
// Iterate to find clips that are not in timeline
for (const auto &clip : m_allItems) {
......@@ -852,7 +851,7 @@ bool ProjectItemModel::requestCleanupUnused()
// it is important to execute deletion in a separate loop, because otherwise
// the iterators of m_allItems get messed up
for (const auto &c : to_delete) {
res = requestBinClipDeletion(c, undo, redo);
bool res = requestBinClipDeletion(c, undo, redo);
if (!res) {
bool undone = undo();
Q_ASSERT(undone);
......@@ -868,7 +867,6 @@ bool ProjectItemModel::requestTrashClips(QStringList &urls)
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool res = true;
std::vector<std::shared_ptr<AbstractProjectItem>> to_delete;
// Iterate to find clips that are not in timeline
for (const auto &clip : m_allItems) {
......@@ -881,7 +879,7 @@ bool ProjectItemModel::requestTrashClips(QStringList &urls)
// it is important to execute deletion in a separate loop, because otherwise
// the iterators of m_allItems get messed up
for (const auto &c : to_delete) {
res = requestBinClipDeletion(c, undo, redo);
bool res = requestBinClipDeletion(c, undo, redo);
if (!res) {
bool undone = undo();
Q_ASSERT(undone);
......
......@@ -518,7 +518,6 @@ void VideoTextEdit::mouseReleaseEvent(QMouseEvent *e)
cursor.setPosition(end, QTextCursor::KeepAnchor);
cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
}
pos = cursor.position();
if (!cursor.atBlockEnd() && document()->characterAt(pos - 1) != QLatin1Char(' ')) {
// Remove trailing space
cursor.setPosition(pos + 1, QTextCursor::KeepAnchor);
......@@ -1102,8 +1101,8 @@ void TextBasedEdit::previewPlaylist(bool createNew)
playZones << QString("%1:%2").arg(p.x()).arg(p.y());
}
properties.insert(QStringLiteral("kdenlive:cutzones"), playZones.join(QLatin1Char(';')));
int ix = 1;
if (createNew) {
int ix = 1;
m_playlist = QString("%1-cut%2.kdenlive").arg(sourcePath).arg(ix);
while (QFile::exists(m_playlist)) {
ix++;
......
......@@ -1375,9 +1375,8 @@ void RemapView::paintEvent(QPaintEvent *event)
int base = int(tickOffset / frameSize);
tickOffset = frameSize - (tickOffset - (base * frameSize));
// Draw frame ticks
int scaledTick = 0;
for (int i = 0; i < maxWidth / frameSize; i++) {
scaledTick = int(m_offset + (i * frameSize) + tickOffset);
int scaledTick = int(m_offset + (i * frameSize) + tickOffset);
if (scaledTick >= maxWidth + m_offset) {
break;
}
......@@ -1476,10 +1475,9 @@ void RemapView::paintEvent(QPaintEvent *event)
if (m_bottomPosition >= 0 && m_bottomPosition < m_duration) {
p.setBrush(m_colSelected);
int topPos = -1;
double scaledPos = -1;
if (m_remapLink && !m_keyframes.isEmpty()) {
topPos = GenTime(m_remapLink->anim_get_double("map", m_bottomPosition + m_inFrame)).frames(pCore->getCurrentFps()) - m_inFrame;
int topPos = GenTime(m_remapLink->anim_get_double("map", m_bottomPosition + m_inFrame)).frames(pCore->getCurrentFps()) - m_inFrame;
scaledPos = topPos * m_scale;
scaledPos -= m_zoomStart;
scaledPos *= m_zoomFactor;
......@@ -1753,8 +1751,8 @@ void TimeRemap::setClip(std::shared_ptr<ProjectClip> clip, int in, int out)
return;
}
m_view->m_remapLink.reset();
bool keyframesLoaded = false;
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);
......
......@@ -203,12 +203,10 @@ void EffectTreeModel::editCustomAsset(const QString newName,const QString newDes
QDomElement effect = EffectsRepository::get()->getXml(currentName);
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/"));
QString oldpath = dir.absoluteFilePath(currentName + QStringLiteral(".xml"));
QString oldpath = dir.absoluteFilePath(currentName + QStringLiteral(".xml"));
doc.appendChild(doc.importNode(effect, true));
if(!newDescription.trimmed().isEmpty()){
QDomElement root = doc.documentElement();
QDomElement nodelist = root.firstChildElement("description");
......@@ -224,7 +222,6 @@ void EffectTreeModel::editCustomAsset(const QString newName,const QString newDes
if(!newName.trimmed().isEmpty() && newName != currentName)
{
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/"));
if (!dir.exists()) {
dir.mkpath(QStringLiteral("."));
}
......
......@@ -19,13 +19,13 @@
EffectStackModel::EffectStackModel(std::weak_ptr<Mlt::Service> service, ObjectId ownerId, std::weak_ptr<DocUndoStack> undo_stack)
: AbstractTreeModel()
, m_masterService(std::move(service))
, m_effectStackEnabled(true)
, m_ownerId(std::move(ownerId))
, m_undoStack(std::move(undo_stack))
, m_lock(QReadWriteLock::Recursive)
, m_loadingExisting(false)
{
m_masterService = std::move(service);
}
std::shared_ptr<EffectStackModel> EffectStackModel::construct(std::weak_ptr<Mlt::Service> service, ObjectId ownerId, std::weak_ptr<DocUndoStack> undo_stack)
......@@ -871,7 +871,6 @@ void EffectStackModel::registerItem(const std::shared_ptr<TreeItem> &item)
{
QWriteLocker locker(&m_lock);
// qDebug() << "$$$$$$$$$$$$$$$$$$$$$ Planting effect";
QModelIndex ix;
if (!item->isRoot()) {
auto effectItem = std::static_pointer_cast<EffectItemModel>(item);
if (!m_loadingExisting) {
......@@ -889,7 +888,7 @@ void EffectStackModel::registerItem(const std::shared_ptr<TreeItem> &item)
} else if (effectId == QLatin1String("fadeout") || effectId == QLatin1String("fade_to_black")) {
m_fadeOuts.insert(effectItem->getId());
}
ix = getIndexFromItem(effectItem);
QModelIndex ix = getIndexFromItem(effectItem);
if (!effectItem->isAudio() && !m_loadingExisting) {
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
......
......@@ -33,6 +33,8 @@ MonitorProxy::MonitorProxy(GLWidget *parent)
, m_seekFinished(true)
, m_td(nullptr)
, m_boundsCount(0)
, m_trimmingFrames1(0)
, m_trimmingFrames2(0)
{
}
......
......@@ -953,8 +953,8 @@ QString ArchiveWidget::processMltFile(QDomDocument doc, const QString &destPrefi
}
propertyProcessUrl(e, QStringLiteral("kdenlive:originalurl"), root);
src = Xml::getXmlProperty(e, QStringLiteral("xmldata"));
bool found = false;
if (!src.isEmpty() && (src.contains(QLatin1String("QGraphicsPixmapItem")) || src.contains(QLatin1String("QGraphicsSvgItem")))) {
bool found = false;
// Title with images, replace paths
QDomDocument titleXML;
titleXML.setContent(src);
......
......@@ -24,19 +24,19 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
ProfileWidget::ProfileWidget(QWidget *parent)
: QWidget(parent)
, m_originalProfile(QStringLiteral("invalid"))
{
m_originalProfile = QStringLiteral("invalid");
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
auto *lay = new QVBoxLayout;
lay->setContentsMargins(0, 0, 0, 0);
auto *labelLay = new QHBoxLayout;
QLabel *fpsLabel = new QLabel(i18n("Fps"), this);
auto *fpsLabel = new QLabel(i18n("Fps"), this);
m_fpsFilt = new QComboBox(this);
fpsLabel->setBuddy(m_fpsFilt);
labelLay->addWidget(fpsLabel);
labelLay->addWidget(m_fpsFilt);
QLabel *scanningLabel = new QLabel(i18n("Scanning"), this);
auto *scanningLabel = new QLabel(i18n("Scanning"), this);
m_scanningFilt = new QComboBox(this);
scanningLabel->setBuddy(m_scanningFilt);
labelLay->addWidget(scanningLabel);
......@@ -64,7 +64,8 @@ ProfileWidget::ProfileWidget(QWidget *parent)
QItemSelectionModel *selectionModel = m_treeView->selectionModel();
connect(selectionModel, &QItemSelectionModel::currentRowChanged, this, &ProfileWidget::slotChangeSelection);
connect(selectionModel, &QItemSelectionModel::selectionChanged, this, [&](const QItemSelection &selected, const QItemSelection &deselected) {
QModelIndex current, old;
QModelIndex current;
QModelIndex old;
if (!selected.indexes().isEmpty()) {
current = selected.indexes().front();
}
......
......@@ -274,12 +274,11 @@ void SlideshowClip::parseFolder()
QString regexp = QLatin1Char('^') + filter + QStringLiteral("\\d+\\.") + ext + QLatin1Char('$');
QRegularExpression rx(QRegularExpression::anchoredPattern(regexp));
QStringList entries;
int ix;
for (const QString &p : qAsConst(result)) {
if (rx.match(p).hasMatch()) {
if (offset > 0) {
// make sure our image is in the range we want (> begin)
ix = p.section(filter, 1).section(QLatin1Char('.'), 0, 0).toInt();
int ix = p.section(filter, 1).section(QLatin1Char('.'), 0, 0).toInt();
ix = p.section(filter, 1).section('.', 0, 0).toInt();
if (ix < offset) {
continue;
......
......@@ -108,7 +108,6 @@ void NotesPlugin::slotReAssign(QStringList anchors, QList <QPoint> points)
updatedLink.prepend(QString("%1#").arg(binId));
}
} else {
updatedLink = a;
position = a.toInt();
if (!binId.isEmpty()) {
updatedLink.prepend(QString("%1#").arg(binId));
......
......@@ -364,7 +364,6 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
const int h = m_innerScopeRect.height();
const int leftDist = m_innerScopeRect.left() - m_scopeRect.left();
const int topDist = m_innerScopeRect.top() - m_scopeRect.top();
int windowSize;
int y;
bool completeRedraw = true;
......@@ -384,14 +383,13 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
y = 0;
if ((newData != 0) || m_parameterChanged) {
m_parameterChanged = false;
bool peak = false;
QVector<float> dbMap;
uint right;
////////////////FIXME
for (auto &it : m_fftHistory) {
windowSize = it.size();
int windowSize = it.size();
// Interpolate the frequency data to match the pixel coordinates
right = uint(m_freqMax / (m_freq / 2.f) * (windowSize - 1));
......@@ -400,7 +398,7 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
for (int i = 0; i < dbMap.size(); ++i) {
float val;
val = dbMap[i];
peak = val > m_dBmax;
bool peak = val > m_dBmax;
// Normalize dB value to [0 1], 1 corresponding to dbMax dB and 0 to dbMin dB
val = (val - m_dBmax) / (m_dBmax - m_dBmin) + 1.f;
......
......@@ -1260,12 +1260,12 @@ int TimelineModel::suggestSubtitleMove(int subId, int position, int cursorPositi
QWriteLocker locker(&m_lock);
Q_ASSERT(isSubTitle(subId));
int currentPos = getSubtitlePosition(subId);
int offset = 0;
if (currentPos == position || m_subtitleModel->isLocked()) {
return position;
}
int newPos = position;
if (snapDistance > 0) {
int offset = 0;
std::vector<int> ignored_pts;
// For snapping, we must ignore all in/outs of the clips of the group being moved
std::unordered_set<int> all_items = {subId};
......@@ -1813,8 +1813,8 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
bool canMirrorDrop = !useTargets && ((mirror > -1 && (audioDrop || !keys.isEmpty())) || keys.count() > 1);
QMap<int, int> dropTargets;
if (res && (canMirrorDrop || !target_track.isEmpty()) && master->hasAudioAndVideo()) {
int streamsCount = 0;
if (!useTargets) {
int streamsCount = 0;
target_track.clear();
QList <int> audioTids;
if (!audioDrop) {
......
......@@ -164,7 +164,6 @@ public:
if (!KdenliveSettings::displayallchannels()) {
// Draw merged channels
double i = 0;
double level;
int j = 0;
QPainterPath path;
if (m_drawInPoint > 0) {
......@@ -174,6 +173,7 @@ public:
path.moveTo(j - 1, height());
}
for (; i <= width() && i < m_drawOutPoint; j++) {
double level;
i = j * increment;
int idx = qCeil((startPos + i) * indicesPrPixel);
idx += idx % m_channels;
......@@ -199,12 +199,11 @@ public:
double channelHeight = height() / m_channels;
// Draw separate channels
scaleFactor = channelHeight / (2 * scaleFactor);
double i = 0;
double level;
QRectF bgRect(0, 0, width(), channelHeight);
// Path for vector drawing
//qDebug()<<"==== DRAWING FROM: "<<m_drawInPoint<<" - "<<m_drawOutPoint<<", FIRST: "<<m_firstChunk;
for (int channel = 0; channel < m_channels; channel++) {
double level;
// y is channel median pos
double y = (channel * channelHeight) + channelHeight / 2;
QPainterPath path;
......@@ -225,7 +224,7 @@ public:
pen.setWidth(int(ceil(increment)));
painter->setPen(pathDraw ? Qt::NoPen : pen);
painter->setOpacity(1);
i = 0;
double i = 0;
int j = 0;
if (m_drawInPoint > 0) {
j = int(m_drawInPoint / increment);
......
......@@ -3263,11 +3263,10 @@ void TimelineController::switchTrackLock(bool applyToAll)
int toBeLockedCount =
std::accumulate(ids.begin(), ids.end(), 0, [this](int s, int id) { return s + (m_model->getTrackById_const(id)->isLocked() ? 0 : 1); });
auto subtitleModel = pCore->getSubtitleModel();
bool subLocked = false;
bool hasSubtitleTrack = false;
if (subtitleModel) {
hasSubtitleTrack = true;
subLocked= subtitleModel->isLocked();
bool subLocked = subtitleModel->isLocked();
if (!subLocked) {
toBeLockedCount++;
}
......@@ -4015,7 +4014,6 @@ bool TimelineController::endFakeGroupMove(int clipId, int groupId, int delta_tra
int old_trackId = m_model->getItemTrackId(item);
old_track_ids[item] = old_trackId;
if (old_trackId != -1) {
bool updateThisView = true;
if (m_model->isClip(item)) {
int current_track_position = m_model->getTrackPosition(old_trackId);
int d = m_model->getTrackById_const(old_trackId)->isAudioTrack() ? audio_delta : video_delta;
......@@ -4029,7 +4027,7 @@ bool TimelineController::endFakeGroupMove(int clipId, int groupId, int delta_tra
int duration = m_model->m_allClips[item]->getPlaytime();
min = min < 0 ? old_position[item] + delta_pos : qMin(min, old_position[item] + delta_pos);
max = max < 0 ? old_position[item] + delta_pos + duration : qMax(max, old_position[item] + delta_pos + duration);
ok = ok && m_model->getTrackById(old_trackId)->requestClipDeletion(item, updateThisView, finalMove, undo, redo, false, false);
ok = ok && m_model->getTrackById(old_trackId)->requestClipDeletion(item, true, finalMove, undo, redo, false, false);
if (m_model->m_editMode == TimelineMode::InsertEdit) {
// Lift space left by removed clip
ok = ok && TimelineFunctions::removeSpace(m_model, {old_position[item],old_position[item] + duration}, undo, redo, {old_trackId}, false);
......
......@@ -310,12 +310,11 @@ void TimelineWidget::showRulerMenu()
{
m_guideMenu->clear();
const QList<CommentedTime> guides = pCore->projectManager()->current()->getGuideModel()->getAllMarkers();
QAction *ac;
m_editGuideAcion->setEnabled(false);
double fps = pCore->getCurrentFps();
int currentPos = rootObject()->property("consumerPosition").toInt();
for (const auto &guide : guides) {
ac = new QAction(guide.comment(), this);
auto *ac = new QAction(guide.comment(), this);
int frame = guide.time().frames(fps);
ac->setData(frame);
if (frame == currentPos) {
......@@ -331,12 +330,11 @@ void TimelineWidget::showTimelineMenu()
{
m_guideMenu->clear();
const QList<CommentedTime> guides = pCore->projectManager()->current()->getGuideModel()->getAllMarkers();
QAction *ac;
m_editGuideAcion->setEnabled(false);
double fps = pCore->getCurrentFps();
int currentPos = rootObject()->property("consumerPosition").toInt();
for (const auto &guide : guides) {
ac = new QAction(guide.comment(), this);
auto ac = new QAction(guide.comment(), this);
int frame = guide.time().frames(fps);
ac->setData(frame);
if (frame == currentPos) {
......
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