diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-27 14:22:55 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-27 14:22:55 (GMT) |
commit | 3f626c3e14f2fe5fdecc38d4265d74f8315b3490 (patch) | |
tree | 357b32156e211a33841e44b7a224313c7072ee46 /src/corelib | |
parent | 57ce77e953b618739f6f1aec67f8e0de97e05b08 (diff) | |
parent | 6396e7a15079cb157caef319348a0bcd0b95a6a7 (diff) | |
download | Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.zip Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.tar.gz Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.tar.bz2 |
Merge remote branch 'origin/master' into 4.7
Conflicts:
src/corelib/kernel/qmetatype.cpp
src/declarative/graphicsitems/qdeclarativeevents.cpp
src/declarative/graphicsitems/qdeclarativeflickable.cpp
src/declarative/graphicsitems/qdeclarativegridview.cpp
src/declarative/qml/qdeclarativescript.cpp
src/declarative/util/qdeclarativeanimation.cpp
src/declarative/util/qdeclarativebehavior.cpp
src/declarative/util/qdeclarativeeasefollow.cpp
src/declarative/util/qdeclarativefontloader.cpp
src/declarative/util/qdeclarativelistmodel.cpp
src/declarative/util/qdeclarativespringfollow.cpp
src/declarative/util/qdeclarativestategroup.cpp
src/declarative/util/qdeclarativesystempalette.cpp
src/declarative/util/qdeclarativetimer.cpp
src/declarative/util/qmlstateoperations.cpp
src/multimedia/qml/qdeclarativeaudio.cpp
src/multimedia/qml/qdeclarativevideo.cpp
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/concurrent/qfuturewatcher.cpp | 7 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 5 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 6 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.h | 3 | ||||
-rw-r--r-- | src/corelib/io/qdatastream.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qdir.cpp | 7 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qresource.cpp | 9 | ||||
-rw-r--r-- | src/corelib/io/qurl.cpp | 25 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 26 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 8 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 57 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 12 | ||||
-rw-r--r-- | src/corelib/tools/qeasingcurve.cpp | 69 | ||||
-rw-r--r-- | src/corelib/tools/qeasingcurve.h | 11 | ||||
-rw-r--r-- | src/corelib/tools/qhash.h | 3 | ||||
-rw-r--r-- | src/corelib/tools/qlist.h | 34 | ||||
-rw-r--r-- | src/corelib/tools/qmap.h | 3 | ||||
-rw-r--r-- | src/corelib/tools/qscopedpointer.cpp | 55 |
20 files changed, 308 insertions, 43 deletions
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp index 3065205..3b808b8 100644 --- a/src/corelib/concurrent/qfuturewatcher.cpp +++ b/src/corelib/concurrent/qfuturewatcher.cpp @@ -499,6 +499,13 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event) /*! \fn void QFutureWatcher::setFuture(const QFuture<T> &future) Starts watching the given \a future. + + One of the signals might be emitted for the current state of the + \a future. For example, if the future is already stopped, the + finished signal will be emitted. + + To avoid a race condition, it is important to call this function + \i after doing the connections. */ /*! \fn QFuture<T> QFutureWatcher::future() const diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7e7d7d8..4d48b60 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -814,7 +814,7 @@ namespace QT_NAMESPACE {} # define Q_WS_MAC32 # endif # elif defined(Q_OS_SYMBIAN) -# if (defined(__SERIES60_31__) || defined(__S60_32__) || defined(__S60_50__)) && !defined(QT_NO_S60) +# if !defined(QT_NO_S60) # define Q_WS_S60 # endif # elif !defined(Q_WS_QWS) @@ -2414,10 +2414,11 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #if defined(Q_OS_SYMBIAN) -#ifdef SYMBIAN_GRAPHICS_USE_GCE +#ifdef SYMBIAN_BUILD_GCE //RWsPointerCursor is fixed, so don't use low performance sprites #define Q_SYMBIAN_FIXED_POINTER_CURSORS #define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE +#define Q_SYMBIAN_WINDOW_SIZE_CACHE //enabling new graphics resources #define QT_SYMBIAN_SUPPORTS_SGIMAGE #define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index d5041c9..9490225 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -266,6 +266,11 @@ QLibraryInfo::location(LibraryLocation loc) path = QT_CONFIGURE_PLUGINS_PATH; break; #endif +#ifdef QT_CONFIGURE_IMPORTS_PATH + case ImportsPath: + path = QT_CONFIGURE_IMPORTS_PATH; + break; +#endif #ifdef QT_CONFIGURE_DATA_PATH case DataPath: path = QT_CONFIGURE_DATA_PATH; @@ -470,6 +475,7 @@ QLibraryInfo::location(LibraryLocation loc) \value LibrariesPath The location of installed librarires. \value BinariesPath The location of installed Qt binaries (tools and applications). \value PluginsPath The location of installed Qt plugins. + \value ImportsPath The location of installed QML extensions to import. \value DataPath The location of general Qt data. \value TranslationsPath The location of translation information for Qt strings. \value SettingsPath The location for Qt settings. diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index e64b760..4a7ba06 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -76,7 +76,8 @@ public: TranslationsPath, SettingsPath, DemosPath, - ExamplesPath + ExamplesPath, + ImportsPath }; static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path() diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index fc35bfa..2731ae1 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -159,10 +159,9 @@ QT_BEGIN_NAMESPACE \section1 Reading and writing Qt collection classes - The Qt collection classes can also be serialized to a QDataStream. + The Qt container classes can also be serialized to a QDataStream. These include QList, QLinkedList, QVector, QSet, QHash, and QMap. - These classes have have stream operators declared as non-member of - the class. + The stream operators are declared as non-members of the classes. \target Serializing Qt Classes \section1 Reading and writing other Qt classes. diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 7cfdddf..505889e 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -960,13 +960,14 @@ void QDir::setNameFilters(const QStringList &nameFilters) /*! \obsolete + + Use QDir::addSearchPath() with a prefix instead. + Adds \a path to the search paths searched in to find resources that are not specified with an absolute path. The default search path is to search only in the root (\c{:/}). - Use QDir::addSearchPath() with a prefix instead. - - \sa {The Qt Resource System}, QResource::addSearchPath() + \sa {The Qt Resource System} */ void QDir::addResourceSearchPath(const QString &path) { diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 9179485..d2fa744 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1270,7 +1270,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla int pageSize = getpagesize(); int extra = offset % pageSize; - if (size + extra > (size_t)-1) { + if (quint64(size + extra) > quint64((size_t)-1)) { q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); return 0; } diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 4e14ba8..662100a 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1003,8 +1003,8 @@ QByteArray QIODevice::readAll() to a maximum of \a maxSize - 1 bytes, stores the characters in \a data, and returns the number of bytes read. If a line could not be read but no error ocurred, this function returns 0. If an error - occurs, this function returns what it could the length of what - could be read, or -1 if nothing was read. + occurs, this function returns the length of what could be read, or + -1 if nothing was read. A terminating '\0' byte is always appended to \a data, so \a maxSize must be larger than 1. diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index adfbb15..6d33c8b 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -555,16 +555,15 @@ QStringList QResource::children() const /*! \obsolete + Use QDir::addSearchPath() with a prefix instead. + Adds \a path to the search paths searched in to find resources that are not specified with an absolute path. The \a path must be an absolute path (start with \c{/}). The default search path is to search only in the root (\c{:/}). The last path added will be consulted first upon next QResource creation. - - Use QDir::addSearchPath() with a prefix instead. */ - void QResource::addSearchPath(const QString &path) { @@ -578,6 +577,10 @@ QResource::addSearchPath(const QString &path) } /*! + \obsolete + + Use QDir::searchPaths() instead. + Returns the current search path list. This list is consulted when creating a relative resource. diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 32f7ac2..626bd3f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -444,17 +444,19 @@ static bool QT_FASTCALL _unreserved(const char **ptr) } // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) -static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData) +static bool QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData) { bool first = true; + bool isSchemeValid = true; parseData->scheme = *ptr; for (;;) { char ch = **ptr; if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { ; - } else if (!first && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.')) { - ; + } else if ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') { + if (first) + isSchemeValid = false; } else { break; } @@ -464,11 +466,14 @@ static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData) } if (**ptr != ':') { + isSchemeValid = true; *ptr = parseData->scheme; } else { parseData->schemeLength = *ptr - parseData->scheme; ++(*ptr); // skip ':' } + + return isSchemeValid; } // IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) @@ -3750,7 +3755,19 @@ void QUrlPrivate::parse(ParseOptions parseOptions) const #endif // optional scheme - _scheme(ptr, &parseData); + bool isSchemeValid = _scheme(ptr, &parseData); + + if (isSchemeValid == false) { + that->isValid = false; + char ch = *((*ptr)++); + that->errorInfo.setParams(*ptr, QT_TRANSLATE_NOOP(QUrl, "unexpected URL scheme"), + 0, ch); + QURL_SETFLAG(that->stateFlags, Validated | Parsed); +#if defined (QURL_DEBUG) + qDebug("QUrlPrivate::parse(), unrecognized: %c%s", ch, *ptr); +#endif + return; + } // hierpart _hierPart(ptr, &parseData); diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index fba8dd9..779b69b 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -48,6 +48,7 @@ #include "qstringlist.h" #include "qvector.h" #include "qlocale.h" +#include "qeasingcurve.h" #ifdef QT_BOOTSTRAPPED # ifndef QT_NO_GEOM_VARIANT @@ -176,6 +177,7 @@ QT_BEGIN_NAMESPACE \value QVector3D QVector3D \value QVector4D QVector4D \value QQuaternion QQuaternion + \value QEasingCurve QEasingCurve \value User Base value for user types @@ -259,6 +261,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ QT_ADD_STATIC_METATYPE("QPointF", QMetaType::QPointF), QT_ADD_STATIC_METATYPE("QRegExp", QMetaType::QRegExp), QT_ADD_STATIC_METATYPE("QVariantHash", QMetaType::QVariantHash), + QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve), /* All GUI types */ QT_ADD_STATIC_METATYPE("QColorGroup", 63), @@ -695,6 +698,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) stream << *static_cast<const NS(QRegExp)*>(data); break; #endif +#ifndef QT_BOOTSTRAPPED + case QMetaType::QEasingCurve: + stream << *static_cast<const NS(QEasingCurve)*>(data); + break; +#endif #ifdef QT3_SUPPORT case QMetaType::QColorGroup: #endif @@ -892,6 +900,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) stream >> *static_cast< NS(QRegExp)*>(data); break; #endif +#ifndef QT_BOOTSTRAPPED + case QMetaType::QEasingCurve: + stream >> *static_cast< NS(QEasingCurve)*>(data); + break; +#endif #ifdef QT3_SUPPORT case QMetaType::QColorGroup: #endif @@ -1036,6 +1049,10 @@ void *QMetaType::construct(int type, const void *copy) case QMetaType::QRegExp: return new NS(QRegExp)(*static_cast<const NS(QRegExp)*>(copy)); #endif +#ifndef QT_BOOTSTRAPPED + case QMetaType::QEasingCurve: + return new NS(QEasingCurve)(*static_cast<const NS(QEasingCurve)*>(copy)); +#endif case QMetaType::Void: return 0; default: @@ -1127,6 +1144,10 @@ void *QMetaType::construct(int type, const void *copy) case QMetaType::QRegExp: return new NS(QRegExp); #endif +#ifndef QT_BOOTSTRAPPED + case QMetaType::QEasingCurve: + return new NS(QEasingCurve); +#endif case QMetaType::Void: return 0; default: @@ -1282,6 +1303,11 @@ void QMetaType::destroy(int type, void *data) delete static_cast< NS(QRegExp)* >(data); break; #endif +#ifndef QT_BOOTSTRAPPED + case QMetaType::QEasingCurve: + delete static_cast< NS(QEasingCurve)* >(data); + break; +#endif case QMetaType::Void: break; default: { diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index c23caed..33126e8 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -69,7 +69,7 @@ public: QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17, QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22, QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27, - QVariantHash = 28, LastCoreType = 28 /* QVariantHash */, + QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve, FirstGuiType = 63 /* QColorGroup */, #ifdef QT3_SUPPORT @@ -81,12 +81,12 @@ public: QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81, QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85, QQuaternion = 86, - LastGuiType = 86 /* QQuaternion */, + LastGuiType = QQuaternion, FirstCoreExtType = 128 /* VoidStar */, VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132, UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137, - LastCoreExtType = 137 /* QWidgetStar */, + LastCoreExtType = QWidgetStar, // This logic must match the one in qglobal.h #if defined(QT_COORD_TYPE) @@ -290,6 +290,7 @@ class QPointF; #ifndef QT_NO_REGEXP class QRegExp; #endif +class QEasingCurve; class QWidget; class QObject; @@ -359,6 +360,7 @@ Q_DECLARE_BUILTIN_METATYPE(QPointF, QPointF) #ifndef QT_NO_REGEXP Q_DECLARE_BUILTIN_METATYPE(QRegExp, QRegExp) #endif +Q_DECLARE_BUILTIN_METATYPE(QEasingCurve, QEasingCurve) #ifdef QT3_SUPPORT Q_DECLARE_BUILTIN_METATYPE(QColorGroup, QColorGroup) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e1b5825..227a60d 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -46,6 +46,7 @@ #include "qdebug.h" #include "qmap.h" #include "qdatetime.h" +#include "qeasingcurve.h" #include "qlist.h" #include "qstring.h" #include "qstringlist.h" @@ -146,6 +147,11 @@ static void construct(QVariant::Private *x, const void *copy) v_construct<QRegExp>(x, copy); break; #endif +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + v_construct<QEasingCurve>(x, copy); + break; +#endif case QVariant::Int: x->data.i = copy ? *static_cast<const int *>(copy) : 0; break; @@ -259,6 +265,11 @@ static void clear(QVariant::Private *d) v_clear<QRegExp>(d); break; #endif +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + v_clear<QEasingCurve>(d); + break; +#endif case QVariant::LongLong: case QVariant::ULongLong: case QVariant::Double: @@ -317,6 +328,9 @@ static bool isNull(const QVariant::Private *d) case QVariant::PointF: return v_cast<QPointF>(d)->isNull(); #endif +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: +#endif case QVariant::Url: case QVariant::Locale: case QVariant::RegExp: @@ -435,6 +449,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return *v_cast<QTime>(a) == *v_cast<QTime>(b); case QVariant::DateTime: return *v_cast<QDateTime>(a) == *v_cast<QDateTime>(b); +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + return *v_cast<QEasingCurve>(a) == *v_cast<QEasingCurve>(b); +#endif case QVariant::ByteArray: return *v_cast<QByteArray>(a) == *v_cast<QByteArray>(b); case QVariant::BitArray: @@ -1097,6 +1115,11 @@ static void streamDebug(QDebug dbg, const QVariant &v) case QVariant::DateTime: dbg.nospace() << v.toDateTime(); break; +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + dbg.nospace() << v.toEasingCurve(); + break; +#endif case QVariant::ByteArray: dbg.nospace() << v.toByteArray(); break; @@ -1265,6 +1288,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler; \value Date a QDate \value DateTime a QDateTime \value Double a double + \value EasingCurve a QEasingCurve \value Font a QFont \value Hash a QVariantHash \value Icon a QIcon @@ -1483,6 +1507,12 @@ QVariant::QVariant(const char *val) */ /*! + \fn QVariant::QVariant(const QEasingCurve &val) + + Constructs a new variant with an easing curve value, \a val. +*/ + +/*! \fn QVariant::QVariant(const QByteArray &val) Constructs a new variant with a bytearray value, \a val. @@ -1681,6 +1711,10 @@ QVariant::QVariant(const QTime &val) { d.is_null = false; d.type = Time; v_construct<QTime>(&d, val); } QVariant::QVariant(const QDateTime &val) { d.is_null = false; d.type = DateTime; v_construct<QDateTime>(&d, val); } +#ifndef QT_BOOTSTRAPPED +QVariant::QVariant(const QEasingCurve &val) +{ d.is_null = false; d.type = EasingCurve; v_construct<QEasingCurve>(&d, val); } +#endif QVariant::QVariant(const QList<QVariant> &list) { d.is_null = false; d.type = List; v_construct<QVariantList>(&d, list); } QVariant::QVariant(const QMap<QString, QVariant> &map) @@ -1870,7 +1904,7 @@ QVariant::Type QVariant::nameToType(const char *name) } #ifndef QT_NO_DATASTREAM -enum { MapFromThreeCount = 35 }; +enum { MapFromThreeCount = 36 }; static const ushort map_from_three[MapFromThreeCount] = { QVariant::Invalid, @@ -1907,7 +1941,8 @@ static const ushort map_from_three[MapFromThreeCount] = QVariant::KeySequence, QVariant::Pen, QVariant::LongLong, - QVariant::ULongLong + QVariant::ULongLong, + QVariant::EasingCurve }; /*! @@ -2165,6 +2200,21 @@ QDateTime QVariant::toDateTime() const } /*! + \fn QEasingCurve QVariant::toEasingCurve() const + + Returns the variant as a QEasingCurve if the variant has type() \l + EasingCurve; otherwise returns a default easing curve. + + \sa canConvert(), convert() +*/ +#ifndef QT_BOOTSTRAPPED +QEasingCurve QVariant::toEasingCurve() const +{ + return qVariantToHelper<QEasingCurve>(d, EasingCurve, handler); +} +#endif + +/*! \fn QByteArray QVariant::toByteArray() const Returns the variant as a QByteArray if the variant has type() \l @@ -2605,8 +2655,9 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QRegExp*/ 0, -/*QHash*/ 0 +/*QHash*/ 0, +/*QEasingCurve*/ 0 }; /*! diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 1a9e43a..9628dbf 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -60,6 +60,7 @@ class QBitArray; class QDataStream; class QDate; class QDateTime; +class QEasingCurve; class QLine; class QLineF; class QLocale; @@ -128,9 +129,10 @@ class Q_CORE_EXPORT QVariant LineF = 24, Point = 25, PointF = 26, - RegExp = 27, + RegExp = 27, Hash = 28, - LastCoreType = Hash, + EasingCurve = 29, + LastCoreType = EasingCurve, // value 62 is internally reserved #ifdef QT3_SUPPORT @@ -219,6 +221,9 @@ class Q_CORE_EXPORT QVariant #ifndef QT_NO_REGEXP QVariant(const QRegExp ®Exp); #endif +#ifndef QT_BOOTSTRAPPED + QVariant(const QEasingCurve &easing); +#endif QVariant(Qt::GlobalColor color); QVariant& operator=(const QVariant &other); @@ -280,6 +285,9 @@ class Q_CORE_EXPORT QVariant #ifndef QT_NO_REGEXP QRegExp toRegExp() const; #endif +#ifndef QT_BOOTSTRAPPED + QEasingCurve toEasingCurve() const; +#endif #ifdef QT3_SUPPORT inline QT3_SUPPORT int &asInt(); diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index b6a2df4..d4b2c27 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -600,11 +600,11 @@ QEasingCurve::QEasingCurve(Type type) Construct a copy of \a other. */ QEasingCurve::QEasingCurve(const QEasingCurve &other) -: d_ptr(new QEasingCurvePrivate) + : d_ptr(new QEasingCurvePrivate) { // ### non-atomic, requires malloc on shallow copy *d_ptr = *other.d_ptr; - if(other.d_ptr->config) + if (other.d_ptr->config) d_ptr->config = other.d_ptr->config->copy(); } @@ -629,7 +629,7 @@ QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other) } *d_ptr = *other.d_ptr; - if(other.d_ptr->config) + if (other.d_ptr->config) d_ptr->config = other.d_ptr->config->copy(); return *this; @@ -845,6 +845,67 @@ QDebug operator<<(QDebug debug, const QEasingCurve &item) } return debug; } -#endif +#endif // QT_NO_DEBUG_STREAM + +#ifndef QT_NO_DATASTREAM +/*! + \fn QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing) + \relates QEasingCurve + + Writes the given \a easing curve to the given \a stream and returns a + reference to the stream. + + \sa {Format of the QDataStream Operators} +*/ + +QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing) +{ + stream << quint8(easing.d_ptr->type); + stream << quint64(quintptr(easing.d_ptr->func)); + + bool hasConfig = easing.d_ptr->config; + stream << hasConfig; + if (hasConfig) { + stream << easing.d_ptr->config->_p; + stream << easing.d_ptr->config->_a; + stream << easing.d_ptr->config->_o; + } + return stream; +} + +/*! + \fn QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing) + \relates QQuaternion + + Reads an easing curve from the given \a stream into the given \a quaternion + and returns a reference to the stream. + + \sa {Format of the QDataStream Operators} +*/ + +QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing) +{ + QEasingCurve::Type type; + quint8 int_type; + stream >> int_type; + type = static_cast<QEasingCurve::Type>(int_type); + easing.setType(type); + + quint64 ptr_func; + stream >> ptr_func; + easing.d_ptr->func = QEasingCurve::EasingFunction(quintptr(ptr_func)); + + bool hasConfig; + stream >> hasConfig; + if (hasConfig) { + QEasingCurveFunction *config = curveToFunctionObject(type); + stream >> config->_p; + stream >> config->_a; + stream >> config->_o; + easing.d_ptr->config = config; + } + return stream; +} +#endif // QT_NO_DATASTREAM QT_END_NAMESPACE diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index ae8822e..173fba4 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -100,13 +100,24 @@ public: qreal valueForProgress(qreal progress) const; private: QEasingCurvePrivate *d_ptr; +#ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item); +#endif +#ifndef QT_NO_DATASTREAM + friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&); + friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &); +#endif }; #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item); #endif +#ifndef QT_NO_DATASTREAM +Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&); +Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &); +#endif + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index f1030ae..3374c80 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -625,6 +625,7 @@ template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const { QList<Key> res; + res.reserve(size()); // May be too much, but assume short lifetime const_iterator i = begin(); if (i != end()) { for (;;) { @@ -644,6 +645,7 @@ template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::keys() const { QList<Key> res; + res.reserve(size()); const_iterator i = begin(); while (i != end()) { res.append(i.key()); @@ -688,6 +690,7 @@ template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values() const { QList<T> res; + res.reserve(size()); const_iterator i = begin(); while (i != end()) { res.append(i.value()); diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 3a29e13..c6dd106 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -525,7 +525,8 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t) PodNode cpy = *reinterpret_cast<const PodNode *>(&t); Node *n = reinterpret_cast<Node *>(p.append()); QT_TRY { - node_construct(n, *reinterpret_cast<const T *>(&cpy)); + void *ptr = &cpy; + node_construct(n, *reinterpret_cast<T *>(ptr)); } QT_CATCH(...) { --d->end; QT_RETHROW; @@ -559,7 +560,8 @@ inline void QList<T>::prepend(const T &t) PodNode cpy = *reinterpret_cast<const PodNode *>(&t); Node *n = reinterpret_cast<Node *>(p.prepend()); QT_TRY { - node_construct(n, *reinterpret_cast<const T *>(&cpy)); + void *ptr = &cpy; + node_construct(n, *reinterpret_cast<T *>(ptr)); } QT_CATCH(...) { ++d->begin; QT_RETHROW; @@ -593,7 +595,8 @@ inline void QList<T>::insert(int i, const T &t) PodNode cpy = *reinterpret_cast<const PodNode *>(&t); Node *n = reinterpret_cast<Node *>(p.insert(i)); QT_TRY { - node_construct(n, *reinterpret_cast<const T *>(&cpy)); + void *ptr = &cpy; + node_construct(n, *reinterpret_cast<T *>(ptr)); } QT_CATCH(...) { p.remove(i); QT_RETHROW; @@ -808,15 +811,22 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::iterator QList<T>::erase(typename QList< template <typename T> Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l) { - Node *n = (d->ref != 1) - ? detach_helper_grow(INT_MAX, l.size()) - : reinterpret_cast<Node *>(p.append2(l.p)); - QT_TRY{ - node_copy(n, reinterpret_cast<Node *>(p.end()), reinterpret_cast<Node *>(l.p.begin())); - } QT_CATCH(...) { - // restore the old end - d->end -= int(reinterpret_cast<Node *>(p.end()) - n); - QT_RETHROW; + if (!l.isEmpty()) { + if (isEmpty()) { + *this = l; + } else { + Node *n = (d->ref != 1) + ? detach_helper_grow(INT_MAX, l.size()) + : reinterpret_cast<Node *>(p.append2(l.p)); + QT_TRY { + node_copy(n, reinterpret_cast<Node *>(p.end()), + reinterpret_cast<Node *>(l.p.begin())); + } QT_CATCH(...) { + // restore the old end + d->end -= int(reinterpret_cast<Node *>(p.end()) - n); + QT_RETHROW; + } + } } return *this; } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 2e21547..df0ae46 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -773,6 +773,7 @@ template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QMap<Key, T>::uniqueKeys() const { QList<Key> res; + res.reserve(size()); // May be too much, but assume short lifetime const_iterator i = begin(); if (i != end()) { for (;;) { @@ -792,6 +793,7 @@ template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QMap<Key, T>::keys() const { QList<Key> res; + res.reserve(size()); const_iterator i = begin(); while (i != end()) { res.append(i.key()); @@ -836,6 +838,7 @@ template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values() const { QList<T> res; + res.reserve(size()); const_iterator i = begin(); while (i != end()) { res.append(i.value()); diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 12badf0..e7dd769 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -225,4 +225,59 @@ QT_BEGIN_NAMESPACE Swap this pointer with \a other. */ +/*! + \class QScopedArrayPointer + + \brief The QScopedArrayPointer class stores a pointer to a + dynamically allocated array of objects, and deletes it upon + destruction. + + \since 4.6 + \reentrant + \ingroup misc + + A QScopedArrayPointer is a QScopedPointer that defaults to + deleting the object it is pointing to with the delete[] operator. It + also features operator[] for convenience, so we can write: + + \code + void foo() + { + QScopedArrayPointer<int> i(new int[10]); + i[2] = 42; + ... + return; // our integer array is now deleted using delete[] + } + \endcode +*/ + +/*! + \fn QScopedArrayPointer::QScopedArrayPointer(T *p = 0) + + Constructs this QScopedArrayPointer instance and sets its pointer + to \a p. +*/ + +/*! + \fn T *QScopedArrayPointer::operator[](int i) + + Provides access to entry \a i of the scoped pointer's array of + objects. + + If the contained pointer is \c null, behavior is undefined. + + \sa isNull() +*/ + +/*! + \fn T *QScopedArrayPointer::operator[](int i) const + + Provides access to entry \a i of the scoped pointer's array of + objects. + + If the contained pointer is \c null, behavior is undefined. + + \sa isNull() +*/ + QT_END_NAMESPACE |