dbus test headers: port away from Q_FOREACH
Headers must be free of Q_FOREACH uses if we want to white-list only those .cpp files that still use Q_FOREACH in order to enable QT_NO_FOREACH by default. In common.h, the situation is pretty clear: the loop bodies clearly don't modify the container being iterated over. In MyServer, the situation is not clear at all, and this author doesn't have the time to investigate, so take a copy and iterate over that (eactly what Q_FOREACH does), and leave a comment. As a drive-by, fix missing {} around multi-line loop bodies. Task-number: QTBUG-115839 Change-Id: I06311a641c83daeee25f45522c694ac355ee86b6 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
This commit is contained in:
parent
574aa256cf
commit
33f7eb44ff
@ -164,7 +164,8 @@ public:
|
|||||||
|
|
||||||
bool registerObject()
|
bool registerObject()
|
||||||
{
|
{
|
||||||
Q_FOREACH (const QString &name, m_connections) {
|
const auto copy = m_connections; // needed? Loop doesn't modify, but handleConnection() does
|
||||||
|
for (const QString &name : copy) {
|
||||||
if (!registerObject(QDBusConnection(name)))
|
if (!registerObject(QDBusConnection(name)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -173,7 +174,8 @@ public:
|
|||||||
|
|
||||||
void unregisterObject()
|
void unregisterObject()
|
||||||
{
|
{
|
||||||
Q_FOREACH (const QString &name, m_connections) {
|
const auto copy = m_connections; // needed? Loop doesn't modify, but handleConnection() does
|
||||||
|
for (const QString &name : copy) {
|
||||||
QDBusConnection c(name);
|
QDBusConnection c(name);
|
||||||
c.unregisterObject(m_path);
|
c.unregisterObject(m_path);
|
||||||
}
|
}
|
||||||
|
@ -206,12 +206,14 @@ inline const char* mapName(const PropertyMap&)
|
|||||||
QString printable(const QDBusIntrospection::Method& m)
|
QString printable(const QDBusIntrospection::Method& m)
|
||||||
{
|
{
|
||||||
QString result = "method " + m.name + "(";
|
QString result = "method " + m.name + "(";
|
||||||
foreach (QDBusIntrospection::Argument arg, m.inputArgs)
|
for (QDBusIntrospection::Argument arg : m.inputArgs) {
|
||||||
result += QString("in %1 %2, ")
|
result += QString("in %1 %2, ")
|
||||||
.arg(arg.type, arg.name);
|
.arg(arg.type, arg.name);
|
||||||
foreach (QDBusIntrospection::Argument arg, m.outputArgs)
|
}
|
||||||
|
for (QDBusIntrospection::Argument arg : m.outputArgs) {
|
||||||
result += QString("out %1 %2, ")
|
result += QString("out %1 %2, ")
|
||||||
.arg(arg.type, arg.name);
|
.arg(arg.type, arg.name);
|
||||||
|
}
|
||||||
AnnotationsMap::const_iterator it = m.annotations.begin();
|
AnnotationsMap::const_iterator it = m.annotations.begin();
|
||||||
for ( ; it != m.annotations.end(); ++it)
|
for ( ; it != m.annotations.end(); ++it)
|
||||||
result += QString("%1 \"%2\", ").arg(it.key()).arg(it.value().value);
|
result += QString("%1 \"%2\", ").arg(it.key()).arg(it.value().value);
|
||||||
@ -223,9 +225,10 @@ QString printable(const QDBusIntrospection::Method& m)
|
|||||||
QString printable(const QDBusIntrospection::Signal& s)
|
QString printable(const QDBusIntrospection::Signal& s)
|
||||||
{
|
{
|
||||||
QString result = "signal " + s.name + "(";
|
QString result = "signal " + s.name + "(";
|
||||||
foreach (QDBusIntrospection::Argument arg, s.outputArgs)
|
for (QDBusIntrospection::Argument arg : s.outputArgs) {
|
||||||
result += QString("out %1 %2, ")
|
result += QString("out %1 %2, ")
|
||||||
.arg(arg.type, arg.name);
|
.arg(arg.type, arg.name);
|
||||||
|
}
|
||||||
AnnotationsMap::const_iterator it = s.annotations.begin();
|
AnnotationsMap::const_iterator it = s.annotations.begin();
|
||||||
for ( ; it != s.annotations.end(); ++it)
|
for ( ; it != s.annotations.end(); ++it)
|
||||||
result += QString("%1 \"%2\", ").arg(it.key()).arg(it.value().value);
|
result += QString("%1 \"%2\", ").arg(it.key()).arg(it.value().value);
|
||||||
|
Loading…
Reference in New Issue
Block a user