aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-24 11:40:37 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-24 09:49:07 +0000
commit0cf22cc9f74594252bd744d6aee77cd3ee3ae0e8 (patch)
tree01cf88ed492d341b7177fc7285a944d5670edc50
parentff0be5aba1c12be49b305e596a7610d197ca8427 (diff)
shiboken: Fix invalid QStringRefs in type parser
The QStringRefs returned by QXmlStreamAttribute do not point to some XML buffer but into a string within QXmlStreamAttribute itself and thus become invalid when the attribute is removed from the list. Store them in a QString instead. Amends e0e44f0fd5b05ee299bd4e377b0d4a302c442aae. Task-number: PYSIDE-743 Change-Id: I841eb70379af8e006868c6352283bf2970dd127d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
index 78f8115e0..70563286c 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -1504,7 +1504,7 @@ bool Handler::parseAddConversion(const QXmlStreamReader &,
return true;
}
-static bool parseIndex(const QStringRef &index, int *result, QString *errorMessage)
+static bool parseIndex(const QString &index, int *result, QString *errorMessage)
{
bool ok = false;
*result = index.toInt(&ok);
@@ -1513,7 +1513,7 @@ static bool parseIndex(const QStringRef &index, int *result, QString *errorMessa
return ok;
}
-static bool parseArgumentIndex(const QStringRef &index, int *result, QString *errorMessage)
+static bool parseArgumentIndex(const QString &index, int *result, QString *errorMessage)
{
if (index == QLatin1String("return")) {
*result = 0;
@@ -1537,13 +1537,13 @@ bool Handler::parseModifyArgument(const QXmlStreamReader &,
return false;
}
- QStringRef index;
+ QString index;
QString replaceValue;
bool resetAfterUse = false;
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
- index = attributes->takeAt(i).value();
+ index = attributes->takeAt(i).value().toString();
} else if (name == QLatin1String("replace-value")) {
replaceValue = attributes->takeAt(i).value().toString();
} else if (name == invalidateAfterUseAttribute()) {
@@ -1608,7 +1608,7 @@ bool Handler::parseDefineOwnership(const QXmlStreamReader &,
}
TypeSystem::Language lang = TypeSystem::TargetLangCode;
- QStringRef ownership;
+ QString ownership;
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == classAttribute()) {
@@ -1619,7 +1619,7 @@ bool Handler::parseDefineOwnership(const QXmlStreamReader &,
return false;
}
} else if (name == ownershipAttribute()) {
- ownership = attributes->takeAt(i).value();
+ ownership = attributes->takeAt(i).value().toString();
}
}
const TypeSystem::Ownership owner = ownershipFromFromAttribute(ownership);
@@ -1645,7 +1645,7 @@ bool Handler::parseArgumentMap(const QXmlStreamReader &,
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
- if (!parseIndex(attributes->takeAt(i).value(), &pos, &m_error))
+ if (!parseIndex(attributes->takeAt(i).value().toString(), &pos, &m_error))
return false;
if (pos <= 0) {
m_error = QStringLiteral("Argument position %1 must be a positive number").arg(pos);
@@ -1784,7 +1784,7 @@ bool Handler::parseAddFunction(const QXmlStreamReader &,
QString originalSignature;
QString returnType = QLatin1String("void");
bool staticFunction = false;
- QStringRef access;
+ QString access;
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == QLatin1String("signature")) {
@@ -1795,7 +1795,7 @@ bool Handler::parseAddFunction(const QXmlStreamReader &,
staticFunction = convertBoolean(attributes->takeAt(i).value(),
staticAttribute(), false);
} else if (name == accessAttribute()) {
- access = attributes->takeAt(i).value();
+ access = attributes->takeAt(i).value().toString();
}
}
@@ -1847,8 +1847,8 @@ bool Handler::parseModifyFunction(const QXmlStreamReader &,
}
QString originalSignature;
- QStringRef access;
- QStringRef removal;
+ QString access;
+ QString removal;
QString rename;
QString association;
bool deprecated = false;
@@ -1860,13 +1860,13 @@ bool Handler::parseModifyFunction(const QXmlStreamReader &,
if (name == QLatin1String("signature")) {
originalSignature = attributes->takeAt(i).value().toString();
} else if (name == accessAttribute()) {
- access = attributes->takeAt(i).value();
+ access = attributes->takeAt(i).value().toString();
} else if (name == renameAttribute()) {
rename = attributes->takeAt(i).value().toString();
} else if (name == QLatin1String("associated-to")) {
association = attributes->takeAt(i).value().toString();
} else if (name == removeAttribute()) {
- removal = attributes->takeAt(i).value();
+ removal = attributes->takeAt(i).value().toString();
} else if (name == deprecatedAttribute()) {
deprecated = convertBoolean(attributes->takeAt(i).value(),
deprecatedAttribute(), false);
@@ -2014,7 +2014,7 @@ bool Handler::parseParentOwner(const QXmlStreamReader &,
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
- const QStringRef index = attributes->takeAt(i).value();
+ const QString index = attributes->takeAt(i).value().toString();
if (!parseArgumentIndex(index, &ao.index, &m_error))
return false;
} else if (name == actionAttribute()) {
@@ -2128,13 +2128,13 @@ bool Handler::parseInclude(const QXmlStreamReader &,
TypeEntry *entry, QXmlStreamAttributes *attributes)
{
QString fileName;
- QStringRef location;
+ QString location;
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == QLatin1String("file-name"))
fileName = attributes->takeAt(i).value().toString();
else if (name == locationAttribute())
- location = attributes->takeAt(i).value();
+ location = attributes->takeAt(i).value().toString();
}
const Include::IncludeType loc = locationFromAttribute(location);
if (loc == Include::InvalidInclude) {