aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-11-24 11:30:42 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-11-29 13:33:13 +0100
commit12cfd8bc1fe621ade4ccc1e4999394966fcd945e (patch)
tree3417aaae68efdf65d3d700945af65e78078c2d71
parent085cb301aeb18f182a93afc6ab52d6569b00f99b (diff)
Fix usages of QLatin1String (deprecation candidate)
Use QLatin1StringView or literals. Task-number: PYSIDE-2537 Change-Id: I03cb9ae80dacd84da9e53648dd179ad79e9189b1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-rw-r--r--sources/pyside6/PySide6/glue/qtuitools.cpp4
-rw-r--r--sources/pyside6/libpyside/pyside.cpp2
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp2
-rw-r--r--sources/pyside6/plugins/designer/designercustomwidgets.cpp7
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp6
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp6
6 files changed, 13 insertions, 14 deletions
diff --git a/sources/pyside6/PySide6/glue/qtuitools.cpp b/sources/pyside6/PySide6/glue/qtuitools.cpp
index 9e52436e7..9fee3f0a4 100644
--- a/sources/pyside6/PySide6/glue/qtuitools.cpp
+++ b/sources/pyside6/PySide6/glue/qtuitools.cpp
@@ -142,8 +142,8 @@ QXmlStreamReader reader(&uiFile);
while (!reader.atEnd() && baseClassName.isEmpty() && className.isEmpty()) {
auto token = reader.readNext();
if (token == QXmlStreamReader::StartElement && reader.name() == u"widget") {
- baseClassName = reader.attributes().value(QLatin1String("class")).toUtf8();
- className = reader.attributes().value(QLatin1String("name")).toUtf8();
+ baseClassName = reader.attributes().value(QLatin1StringView("class")).toUtf8();
+ className = reader.attributes().value(QLatin1StringView("name")).toUtf8();
}
}
diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp
index 572341e85..891279473 100644
--- a/sources/pyside6/libpyside/pyside.cpp
+++ b/sources/pyside6/libpyside/pyside.cpp
@@ -849,7 +849,7 @@ bool registerInternalQtConf()
QString executablePath = QString::fromWCharArray(Py_GetProgramFullPath());
#else
// PYSIDE-535: FIXME: Add this function when available.
- QString executablePath = QLatin1String("missing Py_GetProgramFullPath");
+ QString executablePath = QLatin1StringView("missing Py_GetProgramFullPath");
#endif // PYPY_VERSION
QString appDirPath = QFileInfo(executablePath).absolutePath();
diff --git a/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp b/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp
index 8e1381a4e..63cefedb5 100644
--- a/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp
@@ -45,7 +45,7 @@ std::optional<int> qmlMetaCallErrorHandler(QObject *object)
// PYSIDE-464: The error is only valid before PyErr_Restore,
// PYSIDE-464: therefore we take local copies.
Shiboken::AutoDecRef objStr(PyObject_Str(errValue));
- const QString errString = QLatin1String(Shiboken::String::toCString(objStr));
+ const QString errString = QString::fromUtf8(Shiboken::String::toCString(objStr));
const bool isSyntaxError = errType == PyExc_SyntaxError;
const bool isTypeError = errType == PyExc_TypeError;
PyErr_Restore(errType, errValue, errTraceback);
diff --git a/sources/pyside6/plugins/designer/designercustomwidgets.cpp b/sources/pyside6/plugins/designer/designercustomwidgets.cpp
index 6491251b9..89a7e6f60 100644
--- a/sources/pyside6/plugins/designer/designercustomwidgets.cpp
+++ b/sources/pyside6/plugins/designer/designercustomwidgets.cpp
@@ -54,7 +54,7 @@ static QString pyStr(PyObject *o)
static QString pyErrorMessage()
{
- QString result = QLatin1String("<error information not available>");
+ QString result = "<error information not available>"_L1;
PyObject *ptype = {};
PyObject *pvalue = {};
PyObject *ptraceback = {};
@@ -86,7 +86,7 @@ static bool runPyScript(const char *script, QString *errorMessage)
{
PyObject *main = PyImport_AddModule("__main__");
if (main == nullptr) {
- *errorMessage = QLatin1String("Internal error: Cannot retrieve __main__");
+ *errorMessage = "Internal error: Cannot retrieve __main__"_L1;
return false;
}
PyObject *globalDictionary = PyModule_GetDict(main);
@@ -117,8 +117,7 @@ static bool runPyScriptFile(const QString &fileName, QString *errorMessage)
file.close();
const bool ok = runPyScript(script.constData(), errorMessage);
if (!ok && !errorMessage->isEmpty()) {
- errorMessage->prepend(QLatin1String("Error running ") + fileName
- + QLatin1String(": "));
+ errorMessage->prepend("Error running "_L1 + fileName + ": "_L1);
}
return ok;
}
diff --git a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
index bab82ffa2..4829e6c33 100644
--- a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
@@ -125,7 +125,7 @@ void TestCodeInjections::testTextStream()
str << "\n2nd table\n|" << AlignedField("bla", 3, QTextStream::AlignLeft)
<< '|' << AlignedField(QString{}, 0, QTextStream::AlignLeft) << "|\n";
-static const char expected[] = R"(void foo(int a, int b) {
+constexpr auto expected = R"(void foo(int a, int b) {
if (a == b)
return a;
#if Q_OS_WIN
@@ -141,9 +141,9 @@ static const char expected[] = R"(void foo(int a, int b) {
2nd table
|bla||
-)";
+)"_L1;
- QCOMPARE(str.toString(), QLatin1String(expected));
+ QCOMPARE(str.toString(), expected);
}
void TestCodeInjections::testTextStreamRst()
diff --git a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
index 9cae84c89..731ce161c 100644
--- a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
@@ -21,10 +21,10 @@ void TestConversionRuleTag::testConversionRuleTagWithFile()
{
// FIXME PYSIDE7 remove
// temp file used later
- const char conversionData[] = "Hi! I'm a conversion rule.";
+ constexpr auto conversionData = "Hi! I'm a conversion rule."_L1;
QTemporaryFile file;
file.open();
- QCOMPARE(file.write(conversionData), qint64(sizeof(conversionData)-1));
+ QCOMPARE(file.write(conversionData.constData()), conversionData.size());
file.close();
const char cppCode[] = "struct A {};\n";
@@ -43,7 +43,7 @@ void TestConversionRuleTag::testConversionRuleTagWithFile()
QVERIFY(typeEntry->isValue());
auto vte = std::static_pointer_cast<const ValueTypeEntry>(typeEntry);
QVERIFY(vte->hasTargetConversionRule());
- QCOMPARE(vte->targetConversionRule(), QLatin1String(conversionData));
+ QCOMPARE(vte->targetConversionRule(), conversionData);
}
void TestConversionRuleTag::testConversionRuleTagReplace()