Fix non-const ref iterator issues reported by Krazy2 checker foreach

This commit is contained in:
Martin Gräßlin 2012-12-29 07:51:05 +01:00
parent 533d57da60
commit 47ddf1384c
4 changed files with 5 additions and 5 deletions

View file

@ -1046,7 +1046,7 @@ void Client::checkWorkspacePosition(QRect oldGeometry, int oldDesktop)
oldGeomTall = QRect(oldGeometry.x(), 0, oldGeometry.width(), workspace()->oldDisplayHeight()); // Full screen height
oldGeomWide = QRect(0, oldGeometry.y(), workspace()->oldDisplayWidth(), oldGeometry.height()); // Full screen width
int distance = INT_MAX;
foreach( QRect r, workspace()->previousScreenSizes()) {
foreach(const QRect &r, workspace()->previousScreenSizes()) {
int d = r.contains( oldGeometry.center()) ? 0 : ( r.center() - oldGeometry.center()).manhattanLength();
if( d < distance ) {
distance = d;

View file

@ -98,7 +98,7 @@ QVariant ClientModel::data(const QModelIndex& index, int role) const
QString ClientModel::longestCaption() const
{
QString caption;
foreach (QWeakPointer<TabBoxClient> clientPointer, m_clientList) {
foreach (const QWeakPointer<TabBoxClient> &clientPointer, m_clientList) {
QSharedPointer<TabBoxClient> client = clientPointer.toStrongRef();
if (!client) {
continue;
@ -218,7 +218,7 @@ void ClientModel::createClientList(int desktop, bool partialReset)
break;
}
}
foreach (QWeakPointer< TabBoxClient > c, stickyClients) {
foreach (const QWeakPointer< TabBoxClient > &c, stickyClients) {
m_clientList.removeAll(c);
m_clientList.prepend(c);
}

View file

@ -600,7 +600,7 @@ ClientList TabBox::currentClientList()
{
TabBoxClientList list = m_tabBox->clientList();
ClientList ret;
foreach (QWeakPointer<TabBoxClient> clientPointer, list) {
foreach (const QWeakPointer<TabBoxClient> &clientPointer, list) {
QSharedPointer<TabBoxClient> client = clientPointer.toStrongRef();
if (!client)
continue;

View file

@ -455,7 +455,7 @@ void TabBoxHandler::createModel(bool partialReset)
// TODO: C++11 use lambda function
bool lastRaised = false;
bool lastRaisedSucc = false;
foreach (QWeakPointer<TabBoxClient> clientPointer, stackingOrder()) {
foreach (const QWeakPointer<TabBoxClient> &clientPointer, stackingOrder()) {
QSharedPointer<TabBoxClient> client = clientPointer.toStrongRef();
if (!client) {
continue;