mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
pass the source text length to QString::fromUtf8() from QTranslator::translate()
otherwise QString::fromUtf8() will call qstrlen() to figure out the string length Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b3e5a0e7d1
commit
baeeb19d75
1 changed files with 3 additions and 3 deletions
|
@ -247,13 +247,13 @@ bool QTranslator::loadFromData(const QByteArray &data)
|
|||
*/
|
||||
QString QTranslator::translate(const char *context, const char *sourceText) const
|
||||
{
|
||||
const int sourcelen = qstrlen(sourceText);
|
||||
if (isEmpty()) {
|
||||
return QString::fromUtf8(sourceText);
|
||||
return QString::fromUtf8(sourceText, sourcelen);
|
||||
}
|
||||
|
||||
Q_D(const QTranslator);
|
||||
const int contextlen = qstrlen(context);
|
||||
const int sourcelen = qstrlen(sourceText);
|
||||
foreach (const QTranslatorCache &it, d->cache) {
|
||||
// this search method assumes plurals and regular messages are unique strings
|
||||
if (isCharEqual(it.trmsgctxt.constData(), it.trmsgctxt.size(), context, contextlen)
|
||||
|
@ -268,7 +268,7 @@ QString QTranslator::translate(const char *context, const char *sourceText) cons
|
|||
return d->converter.toUnicode(it.trmsgstr.constData(), it.trmsgstr.size());
|
||||
}
|
||||
}
|
||||
return QString::fromUtf8(sourceText);
|
||||
return QString::fromUtf8(sourceText, sourcelen);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Add table
Reference in a new issue