From a9af4502e50bcbe80ff93fabb2da7f07a1dcf53b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 22 Sep 2010 10:55:52 +0200 Subject: 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 --- src/corelib/tools/qstring.cpp | 43 +++++++++++++++++++++++-------------------- 1 file 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 -- cgit v0.12