QEvent: fix a narrowing conversion warning

By using an iterator-based for loop.

Change-Id: I9ae12f16bc2a5c2d74c8557a0324438102fec5b1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Ahmad Samir 2023-04-23 16:40:53 +02:00
parent 4538bbf4a6
commit 0d26db5737
1 changed files with 15 additions and 8 deletions

View File

@ -3772,6 +3772,13 @@ static void formatUnicodeString(QDebug d, const QString &s)
d << Qt::dec << '"';
}
static QDebug operator<<(QDebug dbg, const QInputMethodEvent::Attribute &attr)
{
dbg << "[type= " << attr.type << ", start=" << attr.start << ", length=" << attr.length
<< ", value=" << attr.value << ']';
return dbg;
}
static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
{
d << "QInputMethodEvent(";
@ -3787,15 +3794,15 @@ static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
<< e->replacementLength();
}
if (const int attributeCount = e->attributes().size()) {
const auto attributes = e->attributes();
auto it = attributes.cbegin();
const auto end = attributes.cend();
if (it != end) {
d << ", attributes= {";
for (int a = 0; a < attributeCount; ++a) {
const QInputMethodEvent::Attribute &at = e->attributes().at(a);
if (a)
d << ',';
d << "[type= " << at.type << ", start=" << at.start << ", length=" << at.length
<< ", value=" << at.value << ']';
}
d << *it;
++it;
for (; it != end; ++it)
d << ',' << *it;
d << '}';
}
d << ')';