diff options
author | Iain <qt-info@nokia.com> | 2009-08-20 12:43:42 (GMT) |
---|---|---|
committer | Iain <qt-info@nokia.com> | 2009-08-20 12:43:42 (GMT) |
commit | 2c9a25772725893127d1f81613a8b42af46d9f40 (patch) | |
tree | b7e6e01998687842ade07f5ecc907cb54e642408 /src/corelib | |
parent | 88b41e99fbb8c526d78da89bb4dbc34e496bd6f8 (diff) | |
parent | adc732da98be7c2c13ffafaf6535e3cc47ebc0c3 (diff) | |
download | Qt-2c9a25772725893127d1f81613a8b42af46d9f40.zip Qt-2c9a25772725893127d1f81613a8b42af46d9f40.tar.gz Qt-2c9a25772725893127d1f81613a8b42af46d9f40.tar.bz2 |
Merge commit 'origin/master' into symbolVisibility
Diffstat (limited to 'src/corelib')
23 files changed, 180 insertions, 70 deletions
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index ab47b5a..78777f1 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -79,13 +79,6 @@ QAnimationGroup takes ownership of the animations it manages, and ensures that they are deleted when the animation group is deleted. - You can also use a \l{The State Machine Framework}{state machine} - to create complex animations. The framework provides a special - state, QAnimationState, that plays an animation upon entry and - transitions to a new state when the animation has finished - playing. This technique can also be combined with using animation - groups. - \sa QAbstractAnimation, QVariantAnimation, {The Animation Framework} */ diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h index 74a0ca8..211c5f5 100644 --- a/src/corelib/arch/qatomic_symbian.h +++ b/src/corelib/arch/qatomic_symbian.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp index b08a468..57d0754 100644 --- a/src/corelib/arch/symbian/qatomic_symbian.cpp +++ b/src/corelib/arch/symbian/qatomic_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -44,33 +44,40 @@ #include <e32debug.h> -// Heap and handle info printer. This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. +QT_BEGIN_NAMESPACE + +// Heap and handle info printer. // This way we can report on heap cells and handles that are really not owned by anything which still exists. // This information can be used to detect whether memory leaks are happening, particularly if these numbers grow as the app is used more. -struct SPrintExitInfo +// This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. The +// reason assumed is that this file appears before any other file declaring static data in the generated +// Symbian MMP file. This particular file was chosen as it is the earliest symbian specific file. +struct QSymbianPrintExitInfo { - SPrintExitInfo() + QSymbianPrintExitInfo() { - RThread().HandleCount(initProcessHandleCount,initThreadHandleCount); + RThread().HandleCount(initProcessHandleCount, initThreadHandleCount); initCells = User::CountAllocCells(); } - ~SPrintExitInfo() + ~QSymbianPrintExitInfo() { RProcess myProc; TFullName fullName = myProc.FileName(); TInt cells = User::CountAllocCells(); TInt processHandleCount=0; TInt threadHandleCount=0; - RThread().HandleCount(processHandleCount,threadHandleCount); + RThread().HandleCount(processHandleCount, threadHandleCount); RDebug::Print(_L("%S exiting with %d allocated cells, %d handles"), - &fullName, - cells - initCells, - (processHandleCount + threadHandleCount) - (initProcessHandleCount + initThreadHandleCount)); + &fullName, + cells - initCells, + (processHandleCount + threadHandleCount) - (initProcessHandleCount + initThreadHandleCount)); } TInt initCells; TInt initProcessHandleCount; TInt initThreadHandleCount; -} printExitInfo; +} symbian_printExitInfo; + +QT_END_NAMESPACE #if defined(Q_CC_RVCT) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 73431e0..c4fbc49 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1169,9 +1169,9 @@ bool qSharedBuild() QSysInfo::symbianVersion() function gives the version of the system on which the application is run. - \value SV_9_2 Symbian OS 9.2 - \value SV_9_3 Symbian OS 9.3 - \value SV_9_4 Symbian OS 9.4 + \value SV_9_2 Symbian OS v9.2 + \value SV_9_3 Symbian OS v9.3 + \value SV_9_4 Symbian OS v9.4 \value SV_Unknown An unknown and currently unsupported platform \sa S60Version, WinVersion, MacVersion @@ -2189,7 +2189,8 @@ void qt_message_output(QtMsgType msgType, const char *buf) TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf)); TInt len = Min(tmp.MaxLength(), ptr.Length()); tmp.Copy(ptr.Left(len)); - User::Panic(tmp, 0); // Panic the current thread + // Panic the current thread. We don't use real panic codes, so 0 has no special meaning. + User::Panic(tmp, 0); #elif (defined(Q_OS_UNIX) || defined(Q_CC_MINGW)) abort(); // trap; generates core dump #else diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 9dc4cd9..3f65ed9 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -186,7 +186,6 @@ namespace QT_NAMESPACE {} #elif defined(__SYMBIAN32__) || defined(SYMBIAN) # define Q_OS_SYMBIAN # define Q_NO_POSIX_SIGNALS -// TODO: should this be in qconfig.h # define QT_NO_GETIFADDRS #elif defined(__CYGWIN__) # define Q_OS_CYGWIN @@ -303,7 +302,7 @@ namespace QT_NAMESPACE {} # ifdef MAC_OS_X_VERSION_MIN_REQUIRED # undef MAC_OS_X_VERSION_MIN_REQUIRED # endif -# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3 +# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 # include <AvailabilityMacros.h> # if !defined(MAC_OS_X_VERSION_10_3) # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 @@ -726,7 +725,6 @@ namespace QT_NAMESPACE {} #elif defined(__WINSCW__) && !defined(Q_CC_NOKIAX86) # define Q_CC_NOKIAX86 -// # define Q_CC_MWERKS // May be required #else @@ -1156,9 +1154,7 @@ class QDataStream; #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) #ifndef Q_DECL_EXPORT -# ifdef Q_OS_WIN -# define Q_DECL_EXPORT __declspec(dllexport) -# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) +# if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) # define Q_DECL_EXPORT __declspec(dllexport) # elif defined(QT_VISIBILITY_AVAILABLE) # define Q_DECL_EXPORT __attribute__((visibility("default"))) @@ -1168,9 +1164,7 @@ class QDataStream; # endif #endif #ifndef Q_DECL_IMPORT -# if defined(Q_OS_WIN) -# define Q_DECL_IMPORT __declspec(dllimport) -# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) +# if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) # define Q_DECL_IMPORT __declspec(dllimport) # else # define Q_DECL_IMPORT @@ -1178,7 +1172,7 @@ class QDataStream; #endif /* - Create Qt DLL if QT_DLL is defined (Windows only) + Create Qt DLL if QT_DLL is defined (Windows and Symbian only) */ #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) @@ -1552,6 +1546,11 @@ inline void qUnused(T &x) { (void)x; } Debugging and error handling */ +/* + On Symbian we do not know beforehand whether we are compiling in + release or debug mode, so check the Symbian build define here, + and set the QT_NO_DEBUG define appropriately. +*/ #if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG) # define QT_NO_DEBUG #endif @@ -2344,16 +2343,9 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1); classes contains a private copy constructor and assignment operator to disable copying (the compiler gives an error message). */ - -#if !defined(Q_NO_DECLARED_NOT_DEFINED) || !defined(QT_MAKEDLL) -# define Q_DISABLE_COPY(Class) \ - Class(const Class &); \ - Class &operator=(const Class &); -#else -# define Q_DISABLE_COPY(Class) \ - Class(const Class &); \ - Class &operator=(const Class &); -#endif +#define Q_DISABLE_COPY(Class) \ + Class(const Class &); \ + Class &operator=(const Class &); class QByteArray; Q_CORE_EXPORT QByteArray qgetenv(const char *varName); diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp index 412372a..72b8b83 100644 --- a/src/corelib/io/qfilesystemwatcher_symbian.cpp +++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qfilesystemwatcher_symbian_p.h index 846541b..a1bd607 100644 --- a/src/corelib/io/qfilesystemwatcher_symbian_p.h +++ b/src/corelib/io/qfilesystemwatcher_symbian_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp index 64519f6..a8c72d3 100644 --- a/src/corelib/io/qprocess_symbian.cpp +++ b/src/corelib/io/qprocess_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index acbac36..4aae53d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5699,6 +5699,10 @@ QString QUrl::fromAce(const QByteArray &domain) Applications (IDNA) specification, which allows for domain names (like \c "example.com") to be written using international characters. + + This function return an empty QByteArra if \a domain is not a valid + hostname. Note, in particular, that IPv6 literals are not valid domain + names. */ QByteArray QUrl::toAce(const QString &domain) { diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp index c7264cf..a7d2694 100644 --- a/src/corelib/kernel/qcore_symbian_p.cpp +++ b/src/corelib/kernel/qcore_symbian_p.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 391774f..2a81b99 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index ed55ef6..d7b9d92 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 28fee9e..69912d0 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 55c8e12..5247290 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -836,8 +836,6 @@ QObject::~QObject() QT_TRY { emit destroyed(this); - if (d->declarativeData) - d->declarativeData->destroyed(this); // ### TODO: Can this throw? } QT_CATCH(...) { // all the signal/slots connections are still in place - if we don't // quit now, we will crash pretty soon. @@ -854,6 +852,8 @@ QObject::~QObject() #endif } + if (d->declarativeData) + d->declarativeData->destroyed(this); { QMutex *signalSlotMutex = 0; diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp index d35c21f..fee6293 100644 --- a/src/corelib/kernel/qsharedmemory_symbian.cpp +++ b/src/corelib/kernel/qsharedmemory_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp index a14db7e..3af441a 100644 --- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp +++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 4cd3386..3a5bb55 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -499,9 +499,12 @@ bool QLibraryPrivate::loadPlugin() if (load()) { instance = (QtPluginInstanceFunction)resolve("qt_plugin_instance"); #if defined(Q_OS_SYMBIAN) - // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal - if (!instance) + if (!instance) { + // If resolving with function name failed (i.e. not STDDLL), + // try resolving using known ordinal, which for + // qt_plugin_instance function is always "2". instance = (QtPluginInstanceFunction)resolve("2"); + } #endif return instance; } diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index b0b285e..30914f4 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -208,6 +208,7 @@ void QThreadPrivate::createEventDispatcher(QThreadData *data) void *QThreadPrivate::start(void *arg) { + // Symbian Open C supports neither thread cancellation nor cleanup_push. #ifndef Q_OS_SYMBIAN pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); pthread_cleanup_push(QThreadPrivate::finish, arg); @@ -242,10 +243,10 @@ void *QThreadPrivate::start(void *arg) #endif thr->run(); -#ifndef Q_OS_SYMBIAN - pthread_cleanup_pop(1); -#else +#ifdef Q_OS_SYMBIAN QThreadPrivate::finish(arg); +#else + pthread_cleanup_pop(1); #endif return 0; @@ -584,6 +585,11 @@ void QThread::terminate() } d->terminated = true; + // "false, false" meaning: + // 1. lockAnyway = false. Don't lock the mutex because it's already locked + // (see above). + // 2. closeNativeSymbianHandle = false. We don't want to close the thread handle, + // because we need it here to terminate the thread. QThreadPrivate::finish(this, false, false); d->data->symbian_thread_handle.Terminate(KErrNone); d->data->symbian_thread_handle.Close(); @@ -627,6 +633,9 @@ void QThread::setTerminationEnabled(bool enabled) d->terminationEnabled = enabled; if (enabled && d->terminatePending) { d->terminated = true; + // "false" meaning: + // - lockAnyway = false. Don't lock the mutex because it's already locked + // (see above). QThreadPrivate::finish(thr, false); locker.unlock(); // don't leave the mutex locked! pthread_exit(NULL); diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index dc9692b..a534560 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 5b8991e..ef6cc39 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 344964b..7a3ee14 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 004e823..4eadc75 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -129,6 +129,21 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QXmlStreamReader::ReadElementTextBehaviour + + This enum specifies the different behaviours of readElementText(). + + \value ErrorOnUnexpectedElement Raise an UnexpectedElementError and return + what was read so far when a child element is encountered. + + \value IncludeChildElements Recursively include the text from child elements. + + \value SkipChildElements Skip child elements. + + \since 4.6 +*/ + +/*! \enum QXmlStreamReader::Error This enum specifies different error cases @@ -621,6 +636,56 @@ QXmlStreamReader::TokenType QXmlStreamReader::tokenType() const return d->type; } +/*! + Reads until the next start element within the current element. Returns true + when a start element was reached. When the end element was reached, or when + an error occurred, false is returned. + + The current element is the element matching the most recently parsed start + element of which a matching end element has not yet been reached. When the + parser has reached the end element, the current element becomes the parent + element. + + This is a convenience function for when you're only concerned with parsing + XML elements. The \l{QXmlStream Bookmarks Example} makes extensive use of + this function. + + \since 4.6 + \sa readNext() + */ +bool QXmlStreamReader::readNextStartElement() +{ + while (readNext() != Invalid) { + if (isEndElement()) + return false; + else if (isStartElement()) + return true; + } + return false; +} + +/*! + Reads until the end of the current element, skipping any child nodes. + This function is useful for skipping unknown elements. + + The current element is the element matching the most recently parsed start + element of which a matching end element has not yet been reached. When the + parser has reached the end element, the current element becomes the parent + element. + + \since 4.6 + */ +void QXmlStreamReader::skipCurrentElement() +{ + int depth = 1; + while (depth && readNext() != Invalid) { + if (isEndElement()) + --depth; + else if (isStartElement()) + ++depth; + } +} + /* * Use the following Perl script to generate the error string index list: ===== PERL SCRIPT ==== @@ -2022,12 +2087,17 @@ void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDe The function concatenates text() when it reads either \l Characters or EntityReference tokens, but skips ProcessingInstruction and \l - Comment. In case anything else is read before reaching EndElement, - the function returns what it read so far and raises an - UnexpectedElementError. If the current token is not StartElement, an - empty string is returned. + Comment. If the current token is not StartElement, an empty string is + returned. + + The \a behaviour defines what happens in case anything else is + read before reaching EndElement. The function can include the text from + child elements (useful for example for HTML), ignore child elements, or + raise an UnexpectedElementError and return what was read so far. + + \since 4.6 */ -QString QXmlStreamReader::readElementText() +QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour) { Q_D(QXmlStreamReader); if (isStartElement()) { @@ -2043,16 +2113,37 @@ QString QXmlStreamReader::readElementText() case ProcessingInstruction: case Comment: break; + case StartElement: + if (behaviour == SkipChildElements) { + skipCurrentElement(); + break; + } else if (behaviour == IncludeChildElements) { + result += readElementText(behaviour); + break; + } + // Fall through (for ErrorOnUnexpectedElement) default: - if (!d->error) - d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data.")); - return result; + if (d->error || behaviour == ErrorOnUnexpectedElement) { + if (!d->error) + d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data.")); + return result; + } } } } return QString(); } +/*! + \overload readElementText() + + Calling this function is equivalent to calling readElementText(ErrorOnUnexpectedElement). + */ +QString QXmlStreamReader::readElementText() +{ + return readElementText(ErrorOnUnexpectedElement); +} + /*! Raises a custom error with an optional error \a message. \sa error(), errorString() diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 89585bc..25c6efe 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -322,6 +322,9 @@ public: bool atEnd() const; TokenType readNext(); + bool readNextStartElement(); + void skipCurrentElement(); + TokenType tokenType() const; QString tokenString() const; @@ -349,6 +352,13 @@ public: qint64 characterOffset() const; QXmlStreamAttributes attributes() const; + + enum ReadElementTextBehaviour { + ErrorOnUnexpectedElement, + IncludeChildElements, + SkipChildElements + }; + QString readElementText(ReadElementTextBehaviour behaviour); QString readElementText(); QStringRef name() const; |