fix unexpected "int -> QChar -> QString" conversion (#417)

This commit is contained in:
Cyano Hao 2024-05-09 21:09:57 +08:00 committed by GitHub
parent d6c739d72e
commit cc359651ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 6 deletions

View File

@ -578,7 +578,9 @@ void CppScopes::addScope(int line, PStatement scopeStatement)
#ifdef QT_DEBUG #ifdef QT_DEBUG
if (!mScopes.isEmpty() && mScopes.back()->startLine > line) { if (!mScopes.isEmpty() && mScopes.back()->startLine > line) {
qDebug()<<QString("Error: new scope %1 at %2 which is less that last scope %3") qDebug()<<QString("Error: new scope %1 at %2 which is less that last scope %3")
.arg(scopeStatement->fullName, line,mScopes.back()->startLine>line); .arg(scopeStatement->fullName)
.arg(line)
.arg(mScopes.back()->startLine);
} }
#endif #endif
} }

View File

@ -238,7 +238,7 @@ QString variableExpansion(const QString &command, int &pos, const QMap<QString,
unescaped.append("\\u"); unescaped.append("\\u");
} else { } else {
int hex = digits.toUInt(nullptr, 16); int hex = digits.toUInt(nullptr, 16);
QByteArray encoded = QString(hex).toUtf8(); QByteArray encoded = QString(QChar(hex)).toUtf8();
unescaped.append(encoded); unescaped.append(encoded);
} }
break; break;
@ -251,7 +251,8 @@ QString variableExpansion(const QString &command, int &pos, const QMap<QString,
unescaped.append("\\U"); unescaped.append("\\U");
} else { } else {
int hex = digits.toUInt(nullptr, 16); int hex = digits.toUInt(nullptr, 16);
QByteArray encoded = QString(hex).toUtf8(); char32_t s = hex;
QByteArray encoded = QString::fromUcs4(&s, 1).toUtf8();
unescaped.append(encoded); unescaped.append(encoded);
} }
break; break;

View File

@ -258,7 +258,7 @@ void BookmarkModel::save(const QString &filename, const QString& projectFolder)
} else { } else {
PBookmark pTemp = list[idx]; PBookmark pTemp = list[idx];
if (pTemp->timestamp<=bookmark->timestamp) { if (pTemp->timestamp<=bookmark->timestamp) {
bookmark->description = pTemp->timestamp; bookmark->description = pTemp->description;
bookmark->timestamp = pTemp->timestamp; bookmark->timestamp = pTemp->timestamp;
if (forProject == mIsForProject) if (forProject == mIsForProject)
emit dataChanged(createIndex(idx,2),createIndex(idx,2)); emit dataChanged(createIndex(idx,2),createIndex(idx,2));

View File

@ -3239,7 +3239,7 @@ void QSynEdit::recalcCharExtent()
QString QSynEdit::expandAtWideGlyphs(const QString &S) QString QSynEdit::expandAtWideGlyphs(const QString &S)
{ {
QString Result(S.length()*2); // speed improvement QString Result(S.length()*2, QChar(0)); // speed improvement
int j = 0; int j = 0;
for (int i=0;i<S.length();i++) { for (int i=0;i<S.length();i++) {
int CountOfAvgGlyphs = ceil(fontMetrics().horizontalAdvance(S[i])/(double)mCharWidth); int CountOfAvgGlyphs = ceil(fontMetrics().horizontalAdvance(S[i])/(double)mCharWidth);