From ce8e6abe7fff563b11ab1e83e2bd83cbac5745f9 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 4 Sep 2012 21:10:05 +0200 Subject: [PATCH] Check for C++ operators that should be 'const' Make sure all C++ class comparison operators are const. Change-Id: Ib4a66f2afe6c62f437dae1ecde94287d3db8442d Reviewed-by: Thiago Macieira Reviewed-by: David Faure --- qmake/generators/makefiledeps.h | 4 ++-- src/corelib/mimetypes/qmimemagicrulematcher.cpp | 2 +- src/corelib/mimetypes/qmimemagicrulematcher_p.h | 2 +- src/gui/opengl/qopenglengineshadermanager_p.h | 2 +- src/sql/kernel/qsqlerror.cpp | 4 ++-- src/sql/kernel/qsqlerror.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qmake/generators/makefiledeps.h b/qmake/generators/makefiledeps.h index 7602b5ef4e..5eb66e9de4 100644 --- a/qmake/generators/makefiledeps.h +++ b/qmake/generators/makefiledeps.h @@ -63,10 +63,10 @@ public: inline const QString &real() const { return real_name; } const QString &local() const; - bool operator==(const QMakeLocalFileName &other) { + bool operator==(const QMakeLocalFileName &other) const { return (this->real_name == other.real_name); } - bool operator!=(const QMakeLocalFileName &other) { + bool operator!=(const QMakeLocalFileName &other) const { return !(*this == other); } }; diff --git a/src/corelib/mimetypes/qmimemagicrulematcher.cpp b/src/corelib/mimetypes/qmimemagicrulematcher.cpp index cdd73076fd..4a9cd2971e 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher.cpp +++ b/src/corelib/mimetypes/qmimemagicrulematcher.cpp @@ -67,7 +67,7 @@ QMimeMagicRuleMatcher::QMimeMagicRuleMatcher(const QString &mime, unsigned thePr { } -bool QMimeMagicRuleMatcher::operator==(const QMimeMagicRuleMatcher &other) +bool QMimeMagicRuleMatcher::operator==(const QMimeMagicRuleMatcher &other) const { return m_list == other.m_list && m_priority == other.m_priority; diff --git a/src/corelib/mimetypes/qmimemagicrulematcher_p.h b/src/corelib/mimetypes/qmimemagicrulematcher_p.h index b2bb287207..e4099da3cd 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher_p.h +++ b/src/corelib/mimetypes/qmimemagicrulematcher_p.h @@ -55,7 +55,7 @@ class QMimeMagicRuleMatcher public: explicit QMimeMagicRuleMatcher(const QString &mime, unsigned priority = 65535); - bool operator==(const QMimeMagicRuleMatcher &other); + bool operator==(const QMimeMagicRuleMatcher &other) const; void addRule(const QMimeMagicRule &rule); void addRules(const QList &rules); diff --git a/src/gui/opengl/qopenglengineshadermanager_p.h b/src/gui/opengl/qopenglengineshadermanager_p.h index 72ae1f9073..997a9d8e79 100644 --- a/src/gui/opengl/qopenglengineshadermanager_p.h +++ b/src/gui/opengl/qopenglengineshadermanager_p.h @@ -399,7 +399,7 @@ public: bool useOpacityAttribute; bool usePmvMatrixAttribute; - bool operator==(const QOpenGLEngineShaderProg& other) { + bool operator==(const QOpenGLEngineShaderProg& other) const { // We don't care about the program return ( mainVertexShader == other.mainVertexShader && positionVertexShader == other.positionVertexShader && diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp index edf034a48d..67c3be0c2d 100644 --- a/src/sql/kernel/qsqlerror.cpp +++ b/src/sql/kernel/qsqlerror.cpp @@ -121,7 +121,7 @@ QSqlError& QSqlError::operator=(const QSqlError& other) Compare the \a other error's values to this error and returns true, if it equal. */ -bool QSqlError::operator==(const QSqlError& other) +bool QSqlError::operator==(const QSqlError& other) const { return (errorType == other.errorType); } @@ -131,7 +131,7 @@ bool QSqlError::operator==(const QSqlError& other) Compare the \a other error's values to this error and returns true if it is not equal. */ -bool QSqlError::operator!=(const QSqlError& other) +bool QSqlError::operator!=(const QSqlError& other) const { return (errorType != other.errorType); } diff --git a/src/sql/kernel/qsqlerror.h b/src/sql/kernel/qsqlerror.h index 5a9cb50af0..dd2b650a57 100644 --- a/src/sql/kernel/qsqlerror.h +++ b/src/sql/kernel/qsqlerror.h @@ -66,8 +66,8 @@ public: int number = -1); QSqlError(const QSqlError& other); QSqlError& operator=(const QSqlError& other); - bool operator==(const QSqlError& other); - bool operator!=(const QSqlError& other); + bool operator==(const QSqlError& other) const; + bool operator!=(const QSqlError& other) const; ~QSqlError(); QString driverText() const;