diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-22 08:55:52 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-22 09:01:18 (GMT) |
commit | a9af4502e50bcbe80ff93fabb2da7f07a1dcf53b (patch) | |
tree | 3930c3622321bdccde01d5a01856a8bd3640659d /src/corelib/tools | |
parent | 9333dd84757086c93b95a60e66f891883c36974e (diff) | |
download | Qt-a9af4502e50bcbe80ff93fabb2da7f07a1dcf53b.zip Qt-a9af4502e50bcbe80ff93fabb2da7f07a1dcf53b.tar.gz Qt-a9af4502e50bcbe80ff93fabb2da7f07a1dcf53b.tar.bz2 |
Make the de-inlined isRightToLeft not get called from updateProperties
Before Qt 4.7, QString::isRightToLeft was an inline function that
called QString::updateProperties(). In Qt 4.7, QString::isRightToLeft
was de-inlined and is now called from QString::updateProperties().
According to the Binary Compatibility Guidelines, it's ok to
de-inline a function provided that it's ok the old method is called.
Under some rare circumstances nowadays, the old method could be called
from updateProperties(), which would result in an infinite loop
(updateProperties -> isRightToLeft -> updateProperties -> ...)
This is usually prevented by -fvisibility-inlines-hidden in GCC
(automatic in Qt) and also by -Wl,-Bsymbolic-functions (not automatic,
must pass -reduced-relocations to configure).
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3521b31..5be885b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6941,6 +6941,27 @@ QString QString::multiArg(int numArgs, const QString **args) const return result; } +static bool isStringRightToLeft(const ushort *p, const ushort *end) +{ + bool righttoleft = false; + while (p < end) { + switch(QChar::direction(*p)) + { + case QChar::DirL: + goto end; + case QChar::DirR: + case QChar::DirAL: + righttoleft = true; + goto end; + default: + break; + } + ++p; + } + end: + return righttoleft; +} + /*! \internal */ void QString::updateProperties() const @@ -6957,31 +6978,13 @@ void QString::updateProperties() const p++; } - d->righttoleft = isRightToLeft(); + d->righttoleft = isStringRightToLeft(d->data, d->data + d->size); d->clean = true; } bool QString::isRightToLeft() const { - ushort *p = d->data; - const ushort * const end = p + d->size; - bool righttoleft = false; - while (p < end) { - switch(QChar::direction(*p)) - { - case QChar::DirL: - goto end; - case QChar::DirR: - case QChar::DirAL: - righttoleft = true; - goto end; - default: - break; - } - ++p; - } - end: - return righttoleft; + return isStringRightToLeft(d->data, d->data + d->size); } /*! \fn bool QString::isSimpleText() const |