diff options
author | Simon Hausmann <[email protected]> | 2018-01-22 12:28:43 +0100 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2018-01-22 14:27:52 +0000 |
commit | c4f1a676fcaad76829c7cda1f5bea018150b7412 (patch) | |
tree | 1efbe8ab0f7ee33a36900824b145e7f5cf14b393 /src/qml/jsruntime/qv4string.cpp | |
parent | 1ab5d14615f713a87141b66675521d702542d3a6 (diff) |
Fix crash in tst_controls in QQC2
Handle startsWithUpper() for complex sub-strings
Change-Id: Ia7494a880612761ee3caf9113c2ac5faa4edd182
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4string.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 932ccf13ef..40280534c4 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -181,6 +181,27 @@ void Heap::String::simplifyString() const subtype = StringType_Unknown; } +bool Heap::String::startsWithUpper() const +{ + if (subtype == StringType_AddedString) + return static_cast<const Heap::ComplexString *>(this)->left->startsWithUpper(); + + const Heap::String *str = this; + int offset = 0; + if (subtype == StringType_SubString) { + const ComplexString *cs = static_cast<const Heap::ComplexString *>(this); + if (!cs->len) + return false; + // simplification here is not ideal, but hopefully not a common case. + if (cs->left->subtype >= Heap::String::StringType_Complex) + cs->left->simplifyString(); + str = cs->left; + offset = cs->from; + } + Q_ASSERT(str->subtype < Heap::String::StringType_Complex); + return str->text->size > offset && QChar::isUpper(str->text->data()[offset]); +} + void Heap::String::append(const String *data, QChar *ch) { std::vector<const String *> worklist; |