Use qUtf8Printable() for logging strings

qDebug(), qInfo(), qWarning(), qCritical(), qFatal() expect %s arguments
to be UTF-8 encoded, while qPrintable() converts to local 8-bit encoding.
Therefore qUtf8Printable() should be used for logging strings instead of
qPrintable().
This commit is contained in:
Vladimir Golovnev (qlassez) 2017-08-13 13:56:03 +03:00
parent 219a6b3ad1
commit cff6a64e9f
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
28 changed files with 100 additions and 99 deletions

View file

@ -249,7 +249,7 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
int peerCount = 0;
foreach (const BitTorrent::PeerAddress &addr, peersList) {
if (torrent->connectPeer(addr)) {
qDebug("Adding peer %s...", qPrintable(addr.ip.toString()));
qDebug("Adding peer %s...", qUtf8Printable(addr.ip.toString()));
Logger::instance()->addMessage(tr("Manually adding peer '%1'...").arg(addr.ip.toString()));
peerCount++;
}
@ -442,7 +442,7 @@ void PeerListWidget::handleResolved(const QString &ip, const QString &hostname)
{
QStandardItem *item = m_peerItems.value(ip, 0);
if (item) {
qDebug("Resolved %s -> %s", qPrintable(ip), qPrintable(hostname));
qDebug("Resolved %s -> %s", qUtf8Printable(ip), qUtf8Printable(hostname));
item->setData(hostname, Qt::DisplayRole);
}
}