kill "might detach" warnings

master
Zithia Satazaki 2022-03-28 17:20:28 -04:00
parent 95c0af06be
commit 59de376d05
5 changed files with 12 additions and 12 deletions

View File

@ -39,7 +39,7 @@ void DirectoryNode::sortChildren() {
void DirectoryNode::sortTree() { void DirectoryNode::sortTree() {
sortChildren(); sortChildren();
for (auto c : children) c->sortTree(); for (auto c : qAsConst(children)) c->sortTree();
} }
DirectoryNode* DirectoryNode::subdir(QString name) { DirectoryNode* DirectoryNode::subdir(QString name) {
@ -47,7 +47,7 @@ DirectoryNode* DirectoryNode::subdir(QString name) {
QString first = name.section('/', 0, 0, QString::SectionSkipEmpty); QString first = name.section('/', 0, 0, QString::SectionSkipEmpty);
QString rest = name.section('/', 1, -1, QString::SectionSkipEmpty); QString rest = name.section('/', 1, -1, QString::SectionSkipEmpty);
DirectoryNode* sd = nullptr; DirectoryNode* sd = nullptr;
for (auto c : children) if (c->isDirectory() && c->name == first) { sd = c; break; } for (auto c : qAsConst(children)) if (c->isDirectory() && c->name == first) { sd = c; break; }
if (!sd) sd = new DirectoryNode(this, first); if (!sd) sd = new DirectoryNode(this, first);
return sd->subdir(rest); return sd->subdir(rest);
} }
@ -69,14 +69,14 @@ DirectoryNode* DirectoryNode::findPath(QString path) {
QString first = path.section('/', 0, 0, QString::SectionSkipEmpty); QString first = path.section('/', 0, 0, QString::SectionSkipEmpty);
QString rest = path.section('/', 1, -1, QString::SectionSkipEmpty); QString rest = path.section('/', 1, -1, QString::SectionSkipEmpty);
DirectoryNode* sd = nullptr; DirectoryNode* sd = nullptr;
for (auto c : children) if (c->name == first) { sd = c; break; } for (auto c : qAsConst(children)) if (c->name == first) { sd = c; break; }
if (!sd) return nullptr; if (!sd) return nullptr;
return sd->findPath(rest); return sd->findPath(rest);
} }
DirectoryNode* DirectoryNode::findData(const QVariant& d) { DirectoryNode* DirectoryNode::findData(const QVariant& d) {
if (data == d) return this; if (data == d) return this;
for (auto c : children) { for (auto c : qAsConst(children)) {
if (auto cd = c->findData(d); cd) return cd; if (auto cd = c->findData(d); cd) return cd;
} }
return nullptr; return nullptr;
@ -92,7 +92,7 @@ bool DirectoryNode::isChildOf(Xybrid::UI::DirectoryNode* dn) const {
} }
void DirectoryNode::treeExec(const std::function<void(Xybrid::UI::DirectoryNode*)>& f) { void DirectoryNode::treeExec(const std::function<void(Xybrid::UI::DirectoryNode*)>& f) {
for (auto c : children) c->treeExec(f); for (auto c : qAsConst(children)) c->treeExec(f);
f(this); f(this);
} }

View File

@ -65,13 +65,13 @@ void LayoutGadget::updateGeometry() {
qreal cur = margin; qreal cur = margin;
auto ms = orient(minSize); auto ms = orient(minSize);
qreal h = ms.height(); qreal h = ms.height();
for (auto c : childItems()) { for (auto c : childItems()) { // clazy:exclude=range-loop-detach
auto g = static_cast<Gadget*>(c); auto g = static_cast<Gadget*>(c);
g->updateGeometry(); g->updateGeometry();
auto r = orient(g->layoutBoundingRect()); auto r = orient(g->layoutBoundingRect());
h = std::max(h, r.height()); h = std::max(h, r.height());
} }
for (auto c : childItems()) { for (auto c : childItems()) { // clazy:exclude=range-loop-detach
auto g = static_cast<Gadget*>(c); auto g = static_cast<Gadget*>(c);
auto r = orient(g->layoutBoundingRect()); auto r = orient(g->layoutBoundingRect());
g->centerOn(orient(QPointF(cur + r.width()/2, r.height()/2 + (h - r.height())*bias))); g->centerOn(orient(QPointF(cur + r.width()/2, r.height()/2 + (h - r.height())*bias)));

View File

@ -105,7 +105,7 @@ void SampleSelectorGadget::paint(QPainter* p, const QStyleOptionGraphicsItem* op
void SampleSelectorGadget::buildSubmenu(DirectoryNode* dir, QMenu* menu) { void SampleSelectorGadget::buildSubmenu(DirectoryNode* dir, QMenu* menu) {
auto smp = currentSample.lock(); auto smp = currentSample.lock();
bool needSeparator = false; bool needSeparator = false;
for (auto c : dir->children) { for (auto c : qAsConst(dir->children)) {
if (c->isDirectory()) { if (c->isDirectory()) {
needSeparator = true; needSeparator = true;
buildSubmenu(c, menu->addMenu(c->name)); buildSubmenu(c, menu->addMenu(c->name));
@ -138,7 +138,7 @@ void SampleSelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) {
m->addAction("(no sample)", this, [this] { setSample(nullptr); }); m->addAction("(no sample)", this, [this] { setSample(nullptr); });
m->addSeparator(); m->addSeparator();
DirectoryNode root; DirectoryNode root;
for (auto s : project->samples) root.placeData(s->name, s->uuid); for (auto s : qAsConst(project->samples)) root.placeData(s->name, s->uuid);
root.sortTree(); root.sortTree();
buildSubmenu(&root, m); buildSubmenu(&root, m);

View File

@ -135,7 +135,7 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
} else { // note(s) } else { // note(s)
amt = std::clamp(amt, -12, 12); amt = std::clamp(amt, -12, 12);
auto cc = new CompositeCommand(); auto cc = new CompositeCommand();
for (auto s : sel.indexes()) { for (auto s : sel.indexes()) { // clazy:exclude=range-loop-detach
if (s.column() % Util::colsPerChannel != 1) continue; if (s.column() % Util::colsPerChannel != 1) continue;
int ch = Util::channelForColumn(s.column()); int ch = Util::channelForColumn(s.column());
auto c = new PatternDeltaCommand(p, ch, s.row()-1); auto c = new PatternDeltaCommand(p, ch, s.row()-1);

View File

@ -99,7 +99,7 @@ void SampleListModel::refresh() {
root = std::make_shared<DirectoryNode>(); root = std::make_shared<DirectoryNode>();
auto* project = window->getProject().get(); auto* project = window->getProject().get();
if (!project) return; if (!project) return;
for (auto s : project->samples) root->placeData(s->name, s->uuid); for (auto s : qAsConst(project->samples)) root->placeData(s->name, s->uuid);
root->sortTree(); root->sortTree();
view->setCurrentIndex(QModelIndex()); view->setCurrentIndex(QModelIndex());
@ -147,7 +147,7 @@ void SampleListModel::propagateSampleNames(DirectoryNode* dn) {
if (!dn->data.isNull()) { if (!dn->data.isNull()) {
auto* project = window->getProject().get(); auto* project = window->getProject().get();
project->samples[dn->data.toUuid()]->name = dn->path(); project->samples[dn->data.toUuid()]->name = dn->path();
} else for (auto c : dn->children) propagateSampleNames(c); } else for (auto c : qAsConst(dn->children)) propagateSampleNames(c);
} }
bool SampleListModel::setData(const QModelIndex& index, const QVariant& value, int role) { bool SampleListModel::setData(const QModelIndex& index, const QVariant& value, int role) {