Use QStringLiteral more judiciously

Replace it with QL1S in QStringBuilder expressions
and in overloaded functions.

Replace patterns 'QString::number() + QStringLiteral'
and 'QStringLiteral + QString::number()' with
QString::asprintf.

Saves some text size.

Change-Id: Ib39b2332264dfc3df04e77f2c101b47a1030cef4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Anton Kudryavtsev 2016-07-06 11:32:54 +03:00
parent 145d8462e3
commit 2788fccd29
26 changed files with 58 additions and 59 deletions

View File

@ -1123,7 +1123,7 @@ void QMessagePattern::setPattern(const QString &pattern)
if (m.hasMatch()) { if (m.hasMatch()) {
int depth = m.capturedRef(1).toInt(); int depth = m.capturedRef(1).toInt();
if (depth <= 0) if (depth <= 0)
error += QStringLiteral("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n"); error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n");
else else
backtraceDepth = depth; backtraceDepth = depth;
} }
@ -1135,7 +1135,7 @@ void QMessagePattern::setPattern(const QString &pattern)
backtraceParams.backtraceSeparator = backtraceSeparator; backtraceParams.backtraceSeparator = backtraceSeparator;
backtraceArgs.append(backtraceParams); backtraceArgs.append(backtraceParams);
#else #else
error += QStringLiteral("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n"); error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n");
#endif #endif
} }
@ -1156,7 +1156,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (lexeme == QLatin1String(endifTokenC)) { else if (lexeme == QLatin1String(endifTokenC)) {
tokens[i] = endifTokenC; tokens[i] = endifTokenC;
if (!inIf && !nestedIfError) if (!inIf && !nestedIfError)
error += QStringLiteral("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"); error += QLatin1String("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n");
inIf = false; inIf = false;
} else { } else {
tokens[i] = emptyTokenC; tokens[i] = emptyTokenC;
@ -1172,9 +1172,9 @@ void QMessagePattern::setPattern(const QString &pattern)
} }
} }
if (nestedIfError) if (nestedIfError)
error += QStringLiteral("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n"); error += QLatin1String("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n");
else if (inIf) else if (inIf)
error += QStringLiteral("QT_MESSAGE_PATTERN: missing %{endif}\n"); error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");
if (!error.isEmpty()) { if (!error.isEmpty()) {
#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT) #if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16())); OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));

View File

@ -387,7 +387,7 @@ QStringList QFileSelectorPrivate::platformSelectors()
# endif # endif
QString productName = QSysInfo::productType(); QString productName = QSysInfo::productType();
# ifdef Q_OS_MACOS # ifdef Q_OS_MACOS
if (productName != QStringLiteral("osx")) if (productName != QLatin1String("osx"))
ret << QStringLiteral("osx"); // compatibility ret << QStringLiteral("osx"); // compatibility
# endif # endif
if (productName != QLatin1String("unknown")) if (productName != QLatin1String("unknown"))

View File

@ -819,7 +819,7 @@ static const ushort * const fragmentInUrl = userNameInUrl + 6;
static inline void parseDecodedComponent(QString &data) static inline void parseDecodedComponent(QString &data)
{ {
data.replace(QLatin1Char('%'), QStringLiteral("%25")); data.replace(QLatin1Char('%'), QLatin1String("%25"));
} }
static inline QString static inline QString
@ -1477,7 +1477,7 @@ QString QUrlPrivate::toLocalFile(QUrl::FormattingOptions options) const
// magic for shared drive on windows // magic for shared drive on windows
if (!host.isEmpty()) { if (!host.isEmpty()) {
tmp = QStringLiteral("//") + host; tmp = QLatin1String("//") + host;
#ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only. #ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only.
if (scheme == webDavScheme()) if (scheme == webDavScheme())
tmp += webDavSslTag(); tmp += webDavSslTag();

View File

@ -2269,7 +2269,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString
} }
// prepend ACE prefix // prepend ACE prefix
output->insert(outLen, QStringLiteral("xn--")); output->insert(outLen, QLatin1String("xn--"));
return; return;
} }

View File

@ -3581,7 +3581,7 @@ QString QDateTime::toString(Qt::DateFormat format) const
.arg(tm.toString(Qt::TextDate)) .arg(tm.toString(Qt::TextDate))
.arg(dt.year()); .arg(dt.year());
if (timeSpec() != Qt::LocalTime) { if (timeSpec() != Qt::LocalTime) {
buf += QStringLiteral(" GMT"); buf += QLatin1String(" GMT");
if (d->m_spec == Qt::OffsetFromUTC) if (d->m_spec == Qt::OffsetFromUTC)
buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc); buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
} }

View File

@ -86,7 +86,7 @@ QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
QCoreApplication::addLibraryPath(platformPluginPath); QCoreApplication::addLibraryPath(platformPluginPath);
list = directLoader()->keyMap().values(); list = directLoader()->keyMap().values();
if (!list.isEmpty()) { if (!list.isEmpty()) {
const QString postFix = QStringLiteral(" (from ") const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(platformPluginPath) + QDir::toNativeSeparators(platformPluginPath)
+ QLatin1Char(')'); + QLatin1Char(')');
const QStringList::iterator end = list.end(); const QStringList::iterator end = list.end();

View File

@ -88,7 +88,7 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
QCoreApplication::addLibraryPath(platformPluginPath); QCoreApplication::addLibraryPath(platformPluginPath);
list += directLoader()->keyMap().values(); list += directLoader()->keyMap().values();
if (!list.isEmpty()) { if (!list.isEmpty()) {
const QString postFix = QStringLiteral(" (from ") const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(platformPluginPath) + QDir::toNativeSeparators(platformPluginPath)
+ QLatin1Char(')'); + QLatin1Char(')');
const QStringList::iterator end = list.end(); const QStringList::iterator end = list.end();

View File

@ -111,7 +111,7 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con
doc->addResource(QTextDocument::ImageResource, url, pm); doc->addResource(QTextDocument::ImageResource, url, pm);
} }
if (name.contains(QStringLiteral("@2x"))) if (name.contains(QLatin1String("@2x")))
pm.setDevicePixelRatio(sourcePixelRatio); pm.setDevicePixelRatio(sourcePixelRatio);
return pm; return pm;

View File

@ -468,7 +468,7 @@ long QSslSocketPrivate::sslLibraryVersionNumber()
QString QSslSocketPrivate::sslLibraryVersionString() QString QSslSocketPrivate::sslLibraryVersionString()
{ {
return QStringLiteral("Secure Transport, ") + QSysInfo::prettyProductName(); return QLatin1String("Secure Transport, ") + QSysInfo::prettyProductName();
} }
long QSslSocketPrivate::sslLibraryBuildVersionNumber() long QSslSocketPrivate::sslLibraryBuildVersionNumber()

View File

@ -66,7 +66,7 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2"); static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2");
static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher"); static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher");
static const QString TempFileTemplate = QDir::tempPath() + QStringLiteral("/qt-trayicon-XXXXXX.png"); static const QString TempFileTemplate = QDir::tempPath() + QLatin1String("/qt-trayicon-XXXXXX.png");
static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications"); static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications");
static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications"); static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications");
static const QString DefaultAction = QStringLiteral("default"); static const QString DefaultAction = QStringLiteral("default");
@ -156,7 +156,7 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon)
QDBusConnection session = QDBusConnection::sessionBus(); QDBusConnection session = QDBusConnection::sessionBus();
uint pid = session.interface()->servicePid(KDEWatcherService).value(); uint pid = session.interface()->servicePid(KDEWatcherService).value();
QString processName = QLockFilePrivate::processNameByPid(pid); QString processName = QLockFilePrivate::processNameByPid(pid);
necessary = processName.endsWith(QStringLiteral("indicator-application-service")); necessary = processName.endsWith(QLatin1String("indicator-application-service"));
necessity_checked = true; necessity_checked = true;
} }
if (!necessary) if (!necessary)

View File

@ -64,7 +64,7 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key,
QByteArray device = qgetenv("TSLIB_TSDEVICE"); QByteArray device = qgetenv("TSLIB_TSDEVICE");
if (specification.startsWith(QStringLiteral("/dev/"))) if (specification.startsWith(QLatin1String("/dev/")))
device = specification.toLocal8Bit(); device = specification.toLocal8Bit();
if (device.isEmpty()) if (device.isEmpty())

View File

@ -101,7 +101,7 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
if (desktop == QByteArray("KDE")) { if (desktop == QByteArray("KDE")) {
// Konqueror launcher // Konqueror launcher
if (checkExecutable(QStringLiteral("kfmclient"), browser)) { if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
browser->append(QStringLiteral(" exec")); browser->append(QLatin1String(" exec"));
return true; return true;
} }
} else if (desktop == QByteArray("GNOME")) { } else if (desktop == QByteArray("GNOME")) {
@ -121,7 +121,7 @@ static inline bool launch(const QString &launcher, const QUrl &url)
if (debug) if (debug)
qDebug("Launching %s", qPrintable(command)); qDebug("Launching %s", qPrintable(command));
#if defined(QT_NO_PROCESS) #if defined(QT_NO_PROCESS)
const bool ok = ::system(qPrintable(command + QStringLiteral(" &"))); const bool ok = ::system(qPrintable(command + QLatin1String(" &")));
#else #else
const bool ok = QProcess::startDetached(command); const bool ok = QProcess::startDetached(command);
#endif #endif

View File

@ -170,7 +170,7 @@ QStringList QGenericUnixTheme::xdgIconThemePaths()
{ {
QStringList paths; QStringList paths;
// Add home directory first in search path // Add home directory first in search path
const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons")); const QFileInfo homeIconDir(QDir::homePath() + QLatin1String("/.icons"));
if (homeIconDir.isDir()) if (homeIconDir.isDir())
paths.prepend(homeIconDir.absoluteFilePath()); paths.prepend(homeIconDir.absoluteFilePath());
@ -247,8 +247,8 @@ public:
static QString kdeGlobals(const QString &kdeDir, int kdeVersion) static QString kdeGlobals(const QString &kdeDir, int kdeVersion)
{ {
if (kdeVersion > 4) if (kdeVersion > 4)
return kdeDir + QStringLiteral("/kdeglobals"); return kdeDir + QLatin1String("/kdeglobals");
return kdeDir + QStringLiteral("/share/config/kdeglobals"); return kdeDir + QLatin1String("/share/config/kdeglobals");
} }
void refresh(); void refresh();
@ -559,22 +559,22 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
if (!kdeDirsVar.isEmpty()) if (!kdeDirsVar.isEmpty())
kdeDirs += kdeDirsVar.split(QLatin1Char(':'), QString::SkipEmptyParts); kdeDirs += kdeDirsVar.split(QLatin1Char(':'), QString::SkipEmptyParts);
const QString kdeVersionHomePath = QDir::homePath() + QStringLiteral("/.kde") + QLatin1String(kdeVersionBA); const QString kdeVersionHomePath = QDir::homePath() + QLatin1String("/.kde") + QLatin1String(kdeVersionBA);
if (QFileInfo(kdeVersionHomePath).isDir()) if (QFileInfo(kdeVersionHomePath).isDir())
kdeDirs += kdeVersionHomePath; kdeDirs += kdeVersionHomePath;
const QString kdeHomePath = QDir::homePath() + QStringLiteral("/.kde"); const QString kdeHomePath = QDir::homePath() + QLatin1String("/.kde");
if (QFileInfo(kdeHomePath).isDir()) if (QFileInfo(kdeHomePath).isDir())
kdeDirs += kdeHomePath; kdeDirs += kdeHomePath;
const QString kdeRcPath = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA) + QStringLiteral("rc"); const QString kdeRcPath = QLatin1String("/etc/kde") + QLatin1String(kdeVersionBA) + QLatin1String("rc");
if (QFileInfo(kdeRcPath).isReadable()) { if (QFileInfo(kdeRcPath).isReadable()) {
QSettings kdeSettings(kdeRcPath, QSettings::IniFormat); QSettings kdeSettings(kdeRcPath, QSettings::IniFormat);
kdeSettings.beginGroup(QStringLiteral("Directories-default")); kdeSettings.beginGroup(QStringLiteral("Directories-default"));
kdeDirs += kdeSettings.value(QStringLiteral("prefixes")).toStringList(); kdeDirs += kdeSettings.value(QStringLiteral("prefixes")).toStringList();
} }
const QString kdeVersionPrefix = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA); const QString kdeVersionPrefix = QLatin1String("/etc/kde") + QLatin1String(kdeVersionBA);
if (QFileInfo(kdeVersionPrefix).isDir()) if (QFileInfo(kdeVersionPrefix).isDir())
kdeDirs += kdeVersionPrefix; kdeDirs += kdeVersionPrefix;

View File

@ -278,7 +278,7 @@ QString TableGenerator::findComposeFile()
// check if users home directory has a file named .XCompose // check if users home directory has a file named .XCompose
if (cleanState()) { if (cleanState()) {
QString path = qgetenv("HOME") + QStringLiteral("/.XCompose"); QString path = qgetenv("HOME") + QLatin1String("/.XCompose");
if (QFile::exists(path)) if (QFile::exists(path))
return path; return path;
} }

View File

@ -79,7 +79,7 @@ QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
QCoreApplication::addLibraryPath(pluginPath); QCoreApplication::addLibraryPath(pluginPath);
list = directLoader()->keyMap().values(); list = directLoader()->keyMap().values();
if (!list.isEmpty()) { if (!list.isEmpty()) {
const QString postFix = QStringLiteral(" (from ") const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(pluginPath) + QDir::toNativeSeparators(pluginPath)
+ QLatin1Char(')'); + QLatin1Char(')');
const QStringList::iterator end = list.end(); const QStringList::iterator end = list.end();

View File

@ -509,28 +509,29 @@ QString QWindowsContext::registerWindowClass(const QWindow *w)
break; break;
} }
// Create a unique name for the flag combination // Create a unique name for the flag combination
QString cname = QStringLiteral("Qt5QWindow"); QString cname;
cname += QLatin1String("Qt5QWindow");
switch (type) { switch (type) {
case Qt::Tool: case Qt::Tool:
cname += QStringLiteral("Tool"); cname += QLatin1String("Tool");
break; break;
case Qt::ToolTip: case Qt::ToolTip:
cname += QStringLiteral("ToolTip"); cname += QLatin1String("ToolTip");
break; break;
case Qt::Popup: case Qt::Popup:
cname += QStringLiteral("Popup"); cname += QLatin1String("Popup");
break; break;
default: default:
break; break;
} }
if (style & CS_DROPSHADOW) if (style & CS_DROPSHADOW)
cname += QStringLiteral("DropShadow"); cname += QLatin1String("DropShadow");
if (style & CS_SAVEBITS) if (style & CS_SAVEBITS)
cname += QStringLiteral("SaveBits"); cname += QLatin1String("SaveBits");
if (style & CS_OWNDC) if (style & CS_OWNDC)
cname += QStringLiteral("OwnDC"); cname += QLatin1String("OwnDC");
if (icon) if (icon)
cname += QStringLiteral("Icon"); cname += QLatin1String("Icon");
return registerWindowClass(cname, qWindowsWndProc, style, GetSysColorBrush(COLOR_WINDOW), icon); return registerWindowClass(cname, qWindowsWndProc, style, GetSysColorBrush(COLOR_WINDOW), icon);
} }
@ -828,8 +829,8 @@ static inline QString errorMessageFromComError(const _com_error &comError)
return result; return result;
} }
if (const WORD wCode = comError.WCode()) if (const WORD wCode = comError.WCode())
return QStringLiteral("IDispatch error #") + QString::number(wCode); return QString::asprintf("IDispatch error #%u", uint(wCode));
return QStringLiteral("Unknown error 0x0") + QString::number(comError.Error(), 16); return QString::asprintf("Unknown error 0x0%x", uint(comError.Error()));
} }
#endif // !Q_OS_WINCE #endif // !Q_OS_WINCE

View File

@ -698,7 +698,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData
QByteArray data = getData(CF_UNICODETEXT, pDataObj); QByteArray data = getData(CF_UNICODETEXT, pDataObj);
if (!data.isEmpty()) { if (!data.isEmpty()) {
str = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData())); str = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()));
str.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); str.replace(QLatin1String("\r\n"), QLatin1String("\n"));
} else { } else {
data = getData(CF_TEXT, pDataObj); data = getData(CF_TEXT, pDataObj);
if (!data.isEmpty()) { if (!data.isEmpty()) {

View File

@ -94,9 +94,8 @@ static inline QString mailCommand()
keyName = QString::fromWCharArray(command); keyName = QString::fromWCharArray(command);
RegCloseKey(handle); RegCloseKey(handle);
} }
if (keyName.isEmpty()) const QLatin1String mailto = keyName.isEmpty() ? QLatin1String("mailto") : QLatin1String();
keyName = QStringLiteral("mailto"); keyName += mailto + QLatin1String("\\Shell\\Open\\Command");
keyName += QStringLiteral("\\Shell\\Open\\Command");
if (debug) if (debug)
qDebug() << __FUNCTION__ << "keyName=" << keyName; qDebug() << __FUNCTION__ << "keyName=" << keyName;
command[0] = 0; command[0] = 0;
@ -134,7 +133,7 @@ static inline bool launchMail(const QUrl &url)
} }
// Pass the url as the parameter. Should use QProcess::startDetached(), // Pass the url as the parameter. Should use QProcess::startDetached(),
// but that cannot handle a Windows command line [yet]. // but that cannot handle a Windows command line [yet].
command.replace(QStringLiteral("%1"), url.toString(QUrl::FullyEncoded)); command.replace(QLatin1String("%1"), url.toString(QUrl::FullyEncoded));
if (debug) if (debug)
qDebug() << __FUNCTION__ << "Launching" << command; qDebug() << __FUNCTION__ << "Launching" << command;
//start the process //start the process

View File

@ -246,11 +246,11 @@ QString QWindowsTabletSupport::description() const
.arg(implementationVersion >> 8).arg(implementationVersion & 0xFF) .arg(implementationVersion >> 8).arg(implementationVersion & 0xFF)
.arg(opts, 0, 16); .arg(opts, 0, 16);
if (opts & CXO_MESSAGES) if (opts & CXO_MESSAGES)
result += QStringLiteral(" CXO_MESSAGES"); result += QLatin1String(" CXO_MESSAGES");
if (opts & CXO_CSRMESSAGES) if (opts & CXO_CSRMESSAGES)
result += QStringLiteral(" CXO_CSRMESSAGES"); result += QLatin1String(" CXO_CSRMESSAGES");
if (m_tiltSupport) if (m_tiltSupport)
result += QStringLiteral(" tilt"); result += QLatin1String(" tilt");
return result; return result;
} }

View File

@ -346,7 +346,7 @@ QWindowsTheme::~QWindowsTheme()
static inline QStringList iconThemeSearchPaths() static inline QStringList iconThemeSearchPaths()
{ {
const QFileInfo appDir(QCoreApplication::applicationDirPath() + QStringLiteral("/icons")); const QFileInfo appDir(QCoreApplication::applicationDirPath() + QLatin1String("/icons"));
return appDir.isDir() ? QStringList(appDir.absoluteFilePath()) : QStringList(); return appDir.isDir() ? QStringList(appDir.absoluteFilePath()) : QStringList();
} }

View File

@ -102,7 +102,7 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode)
quint32 size; quint32 size;
const wchar_t *textStr = result.GetRawBuffer(&size); const wchar_t *textStr = result.GetRawBuffer(&size);
QString text = QString::fromWCharArray(textStr, size); QString text = QString::fromWCharArray(textStr, size);
text.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); text.replace(QLatin1String("\r\n"), QLatin1String("\n"));
m_mimeData.setText(text); m_mimeData.setText(text);
return &m_mimeData; return &m_mimeData;

View File

@ -144,7 +144,7 @@ template<> inline char *toString(const QRectF &s)
template<> inline char *toString(const QUrl &uri) template<> inline char *toString(const QUrl &uri)
{ {
if (!uri.isValid()) if (!uri.isValid())
return qstrdup(qPrintable(QStringLiteral("Invalid URL: ") + uri.errorString())); return qstrdup(qPrintable(QLatin1String("Invalid URL: ") + uri.errorString()));
return qstrdup(uri.toEncoded().constData()); return qstrdup(uri.toEncoded().constData());
} }

View File

@ -926,7 +926,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
QBenchmarkTestMethodData::current = &benchmarkData; QBenchmarkTestMethodData::current = &benchmarkData;
const QByteArray &name = m_methods[index].name(); const QByteArray &name = m_methods[index].name();
QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QStringLiteral("()"); QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QLatin1String("()");
char member[512]; char member[512];
QTestTable table; QTestTable table;

View File

@ -824,12 +824,12 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
AttributeFormatter attrs; AttributeFormatter attrs;
QString family = charFormatFont.family(); QString family = charFormatFont.family();
if (!family.isEmpty()) { if (!family.isEmpty()) {
family = family.replace('\\',QStringLiteral("\\\\")); family = family.replace('\\', QLatin1String("\\\\"));
family = family.replace(':',QStringLiteral("\\:")); family = family.replace(':', QLatin1String("\\:"));
family = family.replace(',',QStringLiteral("\\,")); family = family.replace(',', QLatin1String("\\,"));
family = family.replace('=',QStringLiteral("\\=")); family = family.replace('=', QLatin1String("\\="));
family = family.replace(';',QStringLiteral("\\;")); family = family.replace(';', QLatin1String("\\;"));
family = family.replace('\"',QStringLiteral("\\\"")); family = family.replace('\"', QLatin1String("\\\""));
attrs["font-family"] = QString::fromLatin1("\"%1\"").arg(family); attrs["font-family"] = QString::fromLatin1("\"%1\"").arg(family);
} }

View File

@ -307,7 +307,7 @@ private:
if (develMode) { if (develMode) {
// Write a PID file to help runner // Write a PID file to help runner
const QString pidFileName = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)) const QString pidFileName = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation))
.absoluteFilePath(QString::number(uint(GetCurrentProcessId())) + QStringLiteral(".pid")); .absoluteFilePath(QString::asprintf("%u.pid", uint(GetCurrentProcessId())));
CREATEFILE2_EXTENDED_PARAMETERS params = { CREATEFILE2_EXTENDED_PARAMETERS params = {
sizeof(CREATEFILE2_EXTENDED_PARAMETERS), sizeof(CREATEFILE2_EXTENDED_PARAMETERS),
FILE_ATTRIBUTE_NORMAL FILE_ATTRIBUTE_NORMAL

View File

@ -1295,8 +1295,7 @@ static QString extractEncodingDecl(const QString &text, bool *needMoreText)
*needMoreText = false; *needMoreText = false;
int l = text.length(); int l = text.length();
const QString declStart = QStringLiteral("<?xml"); const QLatin1String snip("<?xml", std::min(l, 5));
const QStringRef snip = declStart.leftRef(l);
if (l > 0 && !text.startsWith(snip)) if (l > 0 && !text.startsWith(snip))
return QString(); return QString();