Fix clazy warnings: potential Qt containter detaches in range-for loops

GIT_SILENT
This commit is contained in:
Ahmad Samir 2021-08-22 13:59:17 +02:00
parent 9f41691684
commit 731564f04d
12 changed files with 36 additions and 17 deletions

View file

@ -455,10 +455,12 @@ void Compositor::stop()
} }
if (waylandServer()) { if (waylandServer()) {
for (AbstractClient *c : waylandServer()->clients()) { const QList<AbstractClient *> toRemoveTopLevel = waylandServer()->clients();
for (AbstractClient *c : toRemoveTopLevel) {
m_scene->removeToplevel(c); m_scene->removeToplevel(c);
} }
for (AbstractClient *c : waylandServer()->clients()) { const QList<AbstractClient *> toFinishCompositing = waylandServer()->clients();
for (AbstractClient *c : toFinishCompositing) {
c->finishCompositing(); c->finishCompositing();
} }
} }
@ -591,7 +593,8 @@ void Compositor::composite(RenderLoop *renderLoop)
QList<Toplevel *> windows = Workspace::self()->xStackingOrder(); QList<Toplevel *> windows = Workspace::self()->xStackingOrder();
// Move elevated windows to the top of the stacking order // Move elevated windows to the top of the stacking order
for (EffectWindow *c : static_cast<EffectsHandlerImpl *>(effects)->elevatedWindows()) { const QList<EffectWindow *> elevatedList = static_cast<EffectsHandlerImpl *>(effects)->elevatedWindows();
for (EffectWindow *c : elevatedList) {
Toplevel *t = static_cast<EffectWindowImpl *>(c)->window(); Toplevel *t = static_cast<EffectWindowImpl *>(c)->window();
windows.removeAll(t); windows.removeAll(t);
windows.append(t); windows.append(t);

View file

@ -387,7 +387,8 @@ VirtualDesktopManagerDBusInterface::VirtualDesktopManagerDBusInterface(VirtualDe
connect(m_manager, &VirtualDesktopManager::rowsChanged, this, &VirtualDesktopManagerDBusInterface::rowsChanged); connect(m_manager, &VirtualDesktopManager::rowsChanged, this, &VirtualDesktopManagerDBusInterface::rowsChanged);
for (auto *vd : m_manager->desktops()) { const QVector<VirtualDesktop *> allDesks = m_manager->desktops();
for (auto *vd : allDesks) {
connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this,
[this, vd]() { [this, vd]() {
DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};

View file

@ -52,7 +52,8 @@ ContrastEffect::ContrastEffect()
); );
// Fetch the contrast regions for all windows // Fetch the contrast regions for all windows
for (EffectWindow *window: effects->stackingOrder()) { const EffectWindowList windowList = effects->stackingOrder();
for (EffectWindow *window : windowList) {
updateContrastRegion(window); updateContrastRegion(window);
} }
} }
@ -69,7 +70,9 @@ void ContrastEffect::slotScreenGeometryChanged()
effects->reloadEffect(this); effects->reloadEffect(this);
return; return;
} }
for (EffectWindow *window: effects->stackingOrder()) {
const EffectWindowList windowList = effects->stackingOrder();
for (EffectWindow *window : windowList) {
updateContrastRegion(window); updateContrastRegion(window);
} }
} }

View file

@ -179,7 +179,8 @@ void DesktopGridEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mi
finish(); finish();
} }
for (auto const &w : effects->stackingOrder()) { const EffectWindowList windows = effects->stackingOrder();
for (auto *w : windows) {
w->setData(WindowForceBlurRole, QVariant(true)); w->setData(WindowForceBlurRole, QVariant(true));
} }
@ -1377,7 +1378,9 @@ QVector<int> DesktopGridEffect::desktopList(const EffectWindow *w) const
QVector<int> desks; QVector<int> desks;
desks.resize(w->desktops().count()); desks.resize(w->desktops().count());
int i = 0; int i = 0;
for (const int desk : w->desktops()) {
const QVector<uint> allDesks = w->desktops();
for (const int desk : allDesks) {
desks[i++] = desk-1; desks[i++] = desk-1;
} }
return desks; return desks;

View file

@ -246,7 +246,7 @@ void OverviewEffect::activate()
void OverviewEffect::deactivate() void OverviewEffect::deactivate()
{ {
for (OverviewScreenView *screenView : m_screenViews) { for (OverviewScreenView *screenView : std::as_const(m_screenViews)) {
screenView->stop(); screenView->stop();
} }
m_shutdownTimer->start(animationDuration()); m_shutdownTimer->start(animationDuration());

View file

@ -139,7 +139,8 @@ void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
} }
for (auto const &w : effects->stackingOrder()) { const EffectWindowList windows = effects->stackingOrder();
for (auto *w : windows) {
w->setData(WindowForceBlurRole, QVariant(true)); w->setData(WindowForceBlurRole, QVariant(true));
} }

View file

@ -2302,7 +2302,8 @@ void InputRedirection::setupInputFilters()
if (m_libInput) { if (m_libInput) {
m_tabletSupport = new TabletInputFilter; m_tabletSupport = new TabletInputFilter;
for (LibInput::Device *dev : m_libInput->devices()) { const QVector<LibInput::Device *> devices = m_libInput->devices();
for (LibInput::Device *dev : devices) {
m_tabletSupport->integrateDevice(dev); m_tabletSupport->integrateDevice(dev);
} }
connect(m_libInput, &LibInput::Connection::deviceAdded, m_tabletSupport, &TabletInputFilter::integrateDevice); connect(m_libInput, &LibInput::Connection::deviceAdded, m_tabletSupport, &TabletInputFilter::integrateDevice);

View file

@ -21,7 +21,9 @@ KWinCompositingData::KWinCompositingData(QObject *parent, const QVariantList &ar
bool KWinCompositingData::isDefaults() const bool KWinCompositingData::isDefaults() const
{ {
bool defaults = true; bool defaults = true;
for (const auto &item : m_settings->items()) {
const KConfigSkeletonItem::List itemList = m_settings->items();
for (const auto &item : itemList) {
if (item->key() != QStringLiteral("OpenGLIsUnsafe")) { if (item->key() != QStringLiteral("OpenGLIsUnsafe")) {
defaults &= item->isDefault(); defaults &= item->isDefault();
} }

View file

@ -260,7 +260,8 @@ void KCMKWinRules::exportToFile(const QUrl &path, const QList<int> &indexes)
const auto config = KSharedConfig::openConfig(path.toLocalFile(), KConfig::SimpleConfig); const auto config = KSharedConfig::openConfig(path.toLocalFile(), KConfig::SimpleConfig);
for (const QString &groupName : config->groupList()) { const QStringList groups = config->groupList();
for (const QString &groupName : groups) {
config->deleteGroup(groupName); config->deleteGroup(groupName);
} }

View file

@ -187,7 +187,8 @@ bool RuleBookModel::isSaveNeeded()
void RuleBookModel::copySettingsTo(RuleSettings *dest, const RuleSettings &source) void RuleBookModel::copySettingsTo(RuleSettings *dest, const RuleSettings &source)
{ {
dest->setDefaults(); dest->setDefaults();
for (const KConfigSkeletonItem *item : source.items()) { const KConfigSkeletonItem::List itemList = source.items();
for (const KConfigSkeletonItem *item : itemList) {
dest->findItem(item->name())->setProperty(item->property()); dest->findItem(item->name())->setProperty(item->property());
} }
} }

View file

@ -104,7 +104,8 @@ void VirtualDesktopManager::setVirtualDesktopManagement(KWaylandServer::PlasmaVi
connect(this, &VirtualDesktopManager::currentChanged, m_virtualDesktopManagement, connect(this, &VirtualDesktopManager::currentChanged, m_virtualDesktopManagement,
[this]() { [this]() {
for (auto *deskInt : m_virtualDesktopManagement->desktops()) { const QList <PlasmaVirtualDesktopInterface *> deskIfaces = m_virtualDesktopManagement->desktops();
for (auto *deskInt : deskIfaces) {
if (deskInt->id() == currentDesktop()->id()) { if (deskInt->id() == currentDesktop()->id()) {
deskInt->setActive(true); deskInt->setActive(true);
} else { } else {

View file

@ -636,7 +636,8 @@ void WaylandServer::initScreenLocker()
} }
ScreenLocker::KSldApp::self()->setWaylandFd(clientFd); ScreenLocker::KSldApp::self()->setWaylandFd(clientFd);
for (auto *seat : m_display->seats()) { const QVector<SeatInterface *> seatIfaces = m_display->seats();
for (auto *seat : seatIfaces) {
connect(seat, &KWaylandServer::SeatInterface::timestampChanged, connect(seat, &KWaylandServer::SeatInterface::timestampChanged,
screenLockerApp, &ScreenLocker::KSldApp::userActivity); screenLockerApp, &ScreenLocker::KSldApp::userActivity);
} }
@ -651,7 +652,8 @@ void WaylandServer::initScreenLocker()
m_screenLockerClientConnection = nullptr; m_screenLockerClientConnection = nullptr;
} }
for (auto *seat : m_display->seats()) { const QVector<SeatInterface *> seatIfaces = m_display->seats();
for (auto *seat : seatIfaces) {
disconnect(seat, &KWaylandServer::SeatInterface::timestampChanged, disconnect(seat, &KWaylandServer::SeatInterface::timestampChanged,
screenLockerApp, &ScreenLocker::KSldApp::userActivity); screenLockerApp, &ScreenLocker::KSldApp::userActivity);
} }