diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-21 11:09:03 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-21 12:59:10 +0100 |
commit | 2fdf354c66cb650605e0349ebf1228f3aa43dacc (patch) | |
tree | 5c2d9802fa4d8577f513f608ea4f6f65def7d34f /src | |
parent | eb5bb9e7f547a7e222b5dbb848774639ab11f243 (diff) |
Silence warnings about deprecated QString::QString(const char*)
Fix warnings like:
src/qmllocalstorage/qqmllocalstorage.cpp:81:62: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations]
src/src/labs/settings/qqmlsettings.cpp:335:87: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations]
src/labs/settings/qqmlsettings.cpp:346:50: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or n1String [-Wdeprecated-declarations]
src/labs/settings/qqmlsettings.cpp:361:50: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or n1String [-Wdeprecated-declarations]
src/quicklayouts/qquicklayout.cpp:1241:61: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations]
Change-Id: I87d7e28842a4f7f75b02c1e78eb3df400adcab94
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/labs/settings/qqmlsettings.cpp | 8 | ||||
-rw-r--r-- | src/qmllocalstorage/qqmllocalstorage.cpp | 11 | ||||
-rw-r--r-- | src/quicklayouts/qquicklayout.cpp | 4 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/labs/settings/qqmlsettings.cpp b/src/labs/settings/qqmlsettings.cpp index ff8ec5e065..bf1ad021a7 100644 --- a/src/labs/settings/qqmlsettings.cpp +++ b/src/labs/settings/qqmlsettings.cpp @@ -330,9 +330,11 @@ void QQmlSettingsPrivate::load() for (int i = offset; i < count; ++i) { QMetaProperty property = mo->property(i); + const QString propertyName = QString::fromUtf8(property.name()); const QVariant previousValue = readProperty(property); - const QVariant currentValue = instance()->value(property.name(), previousValue); + const QVariant currentValue = instance()->value(propertyName, + previousValue); if (!currentValue.isNull() && (!previousValue.isValid() || (currentValue.canConvert(previousValue.metaType()) @@ -343,7 +345,7 @@ void QQmlSettingsPrivate::load() // ensure that a non-existent setting gets written // even if the property wouldn't change later - if (!instance()->contains(property.name())) + if (!instance()->contains(propertyName)) _q_propertyChanged(); // setup change notifications on first load @@ -358,7 +360,7 @@ void QQmlSettingsPrivate::store() { QHash<const char *, QVariant>::const_iterator it = changedProperties.constBegin(); while (it != changedProperties.constEnd()) { - instance()->setValue(it.key(), it.value()); + instance()->setValue(QString::fromUtf8(it.key()), it.value()); qCDebug(lcSettings) << "QQmlSettings: store" << it.key() << ":" << it.value(); ++it; } diff --git a/src/qmllocalstorage/qqmllocalstorage.cpp b/src/qmllocalstorage/qqmllocalstorage.cpp index 56b48189ba..8ab7c75ef7 100644 --- a/src/qmllocalstorage/qqmllocalstorage.cpp +++ b/src/qmllocalstorage/qqmllocalstorage.cpp @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE } #define V4THROW_REFERENCE(string) { \ - QV4::ScopedString v(scope, scope.engine->newString(string)); \ + QV4::ScopedString v(scope, scope.engine->newString(QLatin1String(string))); \ scope.engine->throwReferenceError(v); \ RETURN_UNDEFINED(); \ } @@ -335,9 +335,12 @@ static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Va // XXX optimize ScopedString s(scope); ScopedValue v(scope); - resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Value::fromInt32(query.numRowsAffected()))); - resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = scope.engine->newString(query.lastInsertId().toString()))); - resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows); + resultObject->put((s = scope.engine->newIdentifier(QLatin1String("rowsAffected"))).getPointer(), + (v = Value::fromInt32(query.numRowsAffected()))); + resultObject->put((s = scope.engine->newIdentifier(QLatin1String("insertId"))).getPointer(), + (v = scope.engine->newString(query.lastInsertId().toString()))); + resultObject->put((s = scope.engine->newIdentifier(QLatin1String("rows"))).getPointer(), + rows); } else { err = true; } diff --git a/src/quicklayouts/qquicklayout.cpp b/src/quicklayouts/qquicklayout.cpp index dbbd25de85..7af6bd86af 100644 --- a/src/quicklayouts/qquicklayout.cpp +++ b/src/quicklayouts/qquicklayout.cpp @@ -1236,9 +1236,9 @@ void QQuickLayout::_q_dumpLayoutTree() const void QQuickLayout::dumpLayoutTreeRecursive(int level, QString &buf) const { - auto formatLine = [&level](const char *fmt) { + auto formatLine = [&level](const char *fmt) -> QString { QString ss(level *4, QLatin1Char(' ')); - return QString::fromLatin1("%1%2\n").arg(ss).arg(fmt); + return ss + QLatin1String(fmt) + QLatin1Char('\n'); }; auto f2s = [](qreal f) { |