summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-23 22:57:09 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-23 22:57:09 (GMT)
commit520cca521ed320ab6751041d9a7bf9c18ee98fa1 (patch)
tree5ed54c2339f6c025fa19ef2d7f817bc2b1c01f58 /src/declarative
parentcb3cd645082bda7b5142ceff31e5795f2d047c39 (diff)
downloadQt-520cca521ed320ab6751041d9a7bf9c18ee98fa1.zip
Qt-520cca521ed320ab6751041d9a7bf9c18ee98fa1.tar.gz
Qt-520cca521ed320ab6751041d9a7bf9c18ee98fa1.tar.bz2
Fix illegal access in QmlStyledText and add auto tests
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/util/qmlstyledtext.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp
index 1f31214..6d01e3c 100644
--- a/src/declarative/util/qmlstyledtext.cpp
+++ b/src/declarative/util/qmlstyledtext.cpp
@@ -111,6 +111,8 @@ QmlStyledText::~QmlStyledText()
void QmlStyledText::parse(const QString &string, QTextLayout &layout)
{
+ if (string.isEmpty())
+ return;
QmlStyledText styledText(string, layout);
styledText.d->parse();
}
@@ -142,8 +144,10 @@ void QmlStyledTextPrivate::parse()
++ch;
if (*ch == slash) {
++ch;
- if (parseCloseTag(ch, text))
- formatStack.pop();
+ if (parseCloseTag(ch, text)) {
+ if (formatStack.count())
+ formatStack.pop();
+ }
} else {
QTextCharFormat format;
if (formatStack.count())
@@ -164,7 +168,8 @@ void QmlStyledTextPrivate::parse()
} else {
++textLength;
}
- ++ch;
+ if (!ch->isNull())
+ ++ch;
}
if (textLength)
drawText.append(QStringRef(&text, textStart, textLength));
@@ -191,20 +196,15 @@ bool QmlStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QSt
QStringRef tag(&textIn, tagStart, tagLength);
const QChar char0 = tag.at(0);
if (char0 == QLatin1Char('b')) {
- if (tagLength == 1) {
+ if (tagLength == 1)
format.setFontWeight(QFont::Bold);
- return true;
- } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
+ else if (tagLength == 2 && tag.at(1) == QLatin1Char('r'))
textOut.append(QChar(QChar::LineSeparator));
- return true;
- }
} else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1) {
+ if (tagLength == 1)
format.setFontItalic(true);
- return true;
- }
}
- return false;
+ return true;
} else if (ch->isSpace()) {
// may have params.
QStringRef tag(&textIn, tagStart, tagLength);