summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qdiriterator.cpp4
-rw-r--r--src/corelib/io/qiodevice.cpp7
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp2
-rw-r--r--src/corelib/io/qurl.cpp6
-rw-r--r--src/corelib/kernel/kernel.pri3
-rw-r--r--src/corelib/kernel/qobject.cpp79
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp4
-rw-r--r--src/corelib/kernel/qtimer.cpp2
-rw-r--r--src/corelib/kernel/qvariant.cpp5
-rw-r--r--src/corelib/tools/qbytearraymatcher.h2
-rw-r--r--src/corelib/tools/qdumper.cpp1157
-rw-r--r--src/corelib/tools/qhash.h5
-rw-r--r--src/corelib/tools/qlocale.cpp4
-rw-r--r--src/corelib/tools/qmap.h2
-rw-r--r--src/corelib/tools/qrect.cpp2
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h21
-rw-r--r--src/corelib/tools/qsize.cpp2
-rw-r--r--src/corelib/tools/qstringlist.cpp2
-rw-r--r--src/corelib/tools/qvector.h170
-rw-r--r--src/corelib/tools/tools.pri1
21 files changed, 178 insertions, 1304 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index b14f436..81bfb27 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -201,8 +201,8 @@ void QDirIteratorPrivate::advance()
QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
- if (currentFileInfo.isSymLink())
- subDir = currentFileInfo.canonicalFilePath();
+ if (nextFileInfo.isSymLink())
+ subDir = nextFileInfo.canonicalFilePath();
#endif
pushSubDirectory(subDir, it->nameFilters(), it->filters());
}
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index b6c4eb1..2ccc6ea 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -949,9 +949,9 @@ QByteArray QIODevice::readAll()
QByteArray tmp;
if (d->isSequential() || size() == 0) {
- // Read it in chunks, bytesAvailable() is unreliable for sequential
- // devices.
- const int chunkSize = 4096;
+ // Read it in chunks. Use bytesAvailable() as an unreliable hint for
+ // sequential devices, but try to read 4K as a minimum.
+ int chunkSize = qMax(qint64(4096), bytesAvailable());
qint64 totalRead = 0;
forever {
tmp.resize(tmp.size() + chunkSize);
@@ -960,6 +960,7 @@ QByteArray QIODevice::readAll()
if (readBytes <= 0)
return tmp;
totalRead += readBytes;
+ chunkSize = qMax(qint64(4096), bytesAvailable());
}
} else {
// Read it all in one go.
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 779a742..3b704f6 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -449,7 +449,7 @@ QString QResource::absoluteFilePath() const
}
/*!
- Returns true if the resource really exists in the resource heirarchy,
+ Returns true if the resource really exists in the resource hierarchy,
false otherwise.
*/
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 484e79a..14fc2d4 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -2295,7 +2295,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
As mentioned in the \l{Fallback Mechanism} section, QSettings
stores settings for an application in up to four locations,
depending on whether the settings are user-specific or
- system-wide and whether the the settings are application-specific
+ system-wide and whether the settings are application-specific
or organization-wide. For simplicity, we're assuming the
organization is called MySoft and the application is called Star
Runner.
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 9ce9a2e..d1a5cdd 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -4759,6 +4759,12 @@ void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &que
Inserts the pair \a key = \a value into the query string of the
URL.
+ The key/value pair is encoded before it is added to the query. The
+ pair is converted into separate strings internally. The \a key and
+ \a value is first encoded into UTF-8 and then delimited by the
+ character returned by valueDelimiter(). Each key/value pair is
+ delimited by the character returned by pairDelimiter().
+
\sa addEncodedQueryItem()
*/
void QUrl::addQueryItem(const QString &key, const QString &value)
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 3988289..93e7333 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -55,7 +55,8 @@ SOURCES += \
kernel/qcoreglobaldata.cpp \
kernel/qsharedmemory.cpp \
kernel/qsystemsemaphore.cpp \
- kernel/qmetaobjectbuilder.cpp
+ kernel/qmetaobjectbuilder.cpp \
+ kernel/qpointer.cpp
win32 {
SOURCES += \
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e6aeeef..1bf2358 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -58,6 +58,7 @@
#include <qsemaphore.h>
#include <private/qorderedmutexlocker_p.h>
+#include <private/qmutexpool_p.h>
#include <new>
@@ -91,12 +92,35 @@ static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
return types;
}
+QBasicAtomicPointer<QMutexPool> signalSlotMutexes = Q_BASIC_ATOMIC_INITIALIZER(0);
+QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0);
+
+/** \internal
+ * mutex to be locked when accessing the connectionlists or the senders list
+ */
+static QMutex *signalSlotLock(const QObject *o)
+{
+ if (!signalSlotMutexes) {
+ QMutexPool *mp = new QMutexPool;
+ if (!signalSlotMutexes.testAndSetOrdered(0, mp)) {
+ delete mp;
+ }
+ }
+ return signalSlotMutexes->get(o);
+}
+
extern "C" Q_CORE_EXPORT void qt_addObject(QObject *)
{
+ objectCount.ref();
}
extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
{
+ if(!objectCount.deref()) {
+ QMutexPool *old = signalSlotMutexes;
+ signalSlotMutexes.testAndSetAcquire(old, 0);
+ delete old;
+ }
}
QObjectPrivate::QObjectPrivate(int version)
@@ -225,7 +249,7 @@ bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const
int signal_index = q->metaObject()->indexOfSignal(signal);
if (signal_index < 0)
return false;
- QMutexLocker locker(&threadData->mutex);
+ QMutexLocker locker(signalSlotLock(q));
if (connectionLists) {
if (signal_index < connectionLists->count()) {
const ConnectionList &connectionList = connectionLists->at(signal_index);
@@ -247,7 +271,7 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const
int signal_index = q->metaObject()->indexOfSignal(signal);
if (signal_index < 0)
return returnValue;
- QMutexLocker locker(&threadData->mutex);
+ QMutexLocker locker(signalSlotLock(q));
if (connectionLists) {
if (signal_index < connectionLists->count()) {
const ConnectionList &connectionList = connectionLists->at(signal_index);
@@ -265,7 +289,7 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const
QObjectList QObjectPrivate::senderList() const
{
QObjectList returnValue;
- QMutexLocker locker(&threadData->mutex);
+ QMutexLocker locker(signalSlotLock(q_func()));
for (int i = 0; i < senders.count(); ++i)
returnValue << senders.at(i)->sender;
return returnValue;
@@ -714,7 +738,7 @@ QObject::~QObject()
emit destroyed(this);
{
- QMutexLocker locker(&d->threadData->mutex);
+ QMutexLocker locker(signalSlotLock(this));
// set ref to zero to indicate that this object has been deleted
if (d->currentSender != 0)
@@ -733,7 +757,7 @@ QObject::~QObject()
continue;
}
- QMutex *m = &c->receiver->d_func()->threadData->mutex;
+ QMutex *m = signalSlotLock(c->receiver);
bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
c = connectionList[i];
if (c->receiver)
@@ -754,23 +778,26 @@ QObject::~QObject()
}
// disconnect all senders
- for (int i = 0; i < d->senders.count(); ++i) {
+ for (int i = 0; i < d->senders.count(); ) {
QObjectPrivate::Connection *s = d->senders[i];
- if (!s->sender)
- continue;
- QMutex *m = &s->sender->d_func()->threadData->mutex;
+ QMutex *m = signalSlotLock(s->sender);
bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
- s = d->senders[i];
- s->receiver = 0;
- if (s->sender) {
- QObjectConnectionListVector *senderLists = s->sender->d_func()->connectionLists;
- if (senderLists)
- senderLists->dirty = true;
+ if (m < locker.mutex()) {
+ if (i >= d->senders.count() || s != d->senders[i]) {
+ if (needToUnlock)
+ m->unlock();
+ continue;
+ }
}
+ s->receiver = 0;
+ QObjectConnectionListVector *senderLists = s->sender->d_func()->connectionLists;
+ if (senderLists)
+ senderLists->dirty = true;
if (needToUnlock)
m->unlock();
+ ++i;
}
d->senders.clear();
@@ -2259,7 +2286,7 @@ QObject *QObject::sender() const
{
Q_D(const QObject);
- QMutexLocker(&d->threadData->mutex);
+ QMutexLocker(signalSlotLock(this));
if (!d->currentSender)
return 0;
@@ -2315,7 +2342,7 @@ int QObject::receivers(const char *signal) const
}
Q_D(const QObject);
- QMutexLocker locker(&d->threadData->mutex);
+ QMutexLocker locker(signalSlotLock(this));
if (d->connectionLists) {
if (signal_index < d->connectionLists->count()) {
const QObjectPrivate::ConnectionList &connectionList =
@@ -2762,8 +2789,8 @@ bool QMetaObject::connect(const QObject *sender, int signal_index,
c->connectionType = type;
c->argumentTypes = types;
- QOrderedMutexLocker locker(&s->d_func()->threadData->mutex,
- &r->d_func()->threadData->mutex);
+ QOrderedMutexLocker locker(signalSlotLock(sender),
+ signalSlotLock(receiver));
s->d_func()->addConnection(signal_index, c);
r->d_func()->senders.append(c);
@@ -2788,8 +2815,8 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index,
QObject *s = const_cast<QObject *>(sender);
QObject *r = const_cast<QObject *>(receiver);
- QMutex *senderMutex = &s->d_func()->threadData->mutex;
- QMutex *receiverMutex = r ? &r->d_func()->threadData->mutex : 0;
+ QMutex *senderMutex = signalSlotLock(sender);
+ QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0;
QOrderedMutexLocker locker(senderMutex, receiverMutex);
QObjectConnectionListVector *connectionLists = s->d_func()->connectionLists;
@@ -2809,7 +2836,7 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index,
if (c->receiver
&& (r == 0 || (c->receiver == r
&& (method_index < 0 || c->method == method_index)))) {
- QMutex *m = &c->receiver->d_func()->threadData->mutex;
+ QMutex *m = signalSlotLock(c->receiver);
bool needToUnlock = false;
if (!receiverMutex && senderMutex != m) {
// need to relock this receiver and sender in the correct order
@@ -2836,7 +2863,7 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index,
if (c->receiver
&& (r == 0 || (c->receiver == r
&& (method_index < 0 || c->method == method_index)))) {
- QMutex *m = &c->receiver->d_func()->threadData->mutex;
+ QMutex *m = signalSlotLock(c->receiver);
bool needToUnlock = false;
if (!receiverMutex && senderMutex != m) {
// need to relock this receiver and sender in the correct order
@@ -2977,7 +3004,7 @@ static void blocking_activate(QObject *sender, int signal, QObjectPrivate::Conne
#else
QSemaphore semaphore;
queued_activate(sender, signal, c, argv, &semaphore);
- QMutex *mutex = &QThreadData::get2(sender->thread())->mutex;
+ QMutex *mutex = signalSlotLock(sender);
mutex->unlock();
semaphore.acquire();
mutex->lock();
@@ -2997,7 +3024,7 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
argv ? argv : empty_argv);
}
- QMutexLocker locker(&sender->d_func()->threadData->mutex);
+ QMutexLocker locker(signalSlotLock(sender));
QThreadData *currentThreadData = QThreadData::current();
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
@@ -3349,7 +3376,7 @@ void QObject::dumpObjectInfo()
objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data());
Q_D(QObject);
- QMutexLocker locker(&d->threadData->mutex);
+ QMutexLocker locker(signalSlotLock(this));
// first, look for connections where this object is the sender
qDebug(" SIGNALS OUT");
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index 9853079..87e154f 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -129,6 +129,10 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
detached from the segment, and no references to the segment
remain. Do not mix using QtSharedMemory and QSharedMemory. Port
everything to QSharedMemory.
+
+ \warning QSharedMemory changes the key in a Qt-specific way.
+ It is therefore currently not possible to use the shared memory of
+ non-Qt applications with QSharedMemory.
*/
/*!
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 01e81ab..4b3feb0 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE
In multithreaded applications, you can use QTimer in any thread
that has an event loop. To start an event loop from a non-GUI
- thread, use QThread::exec(). Qt uses the the timer's
+ thread, use QThread::exec(). Qt uses the timer's
\l{QObject::thread()}{thread affinity} to determine which thread
will emit the \l{QTimer::}{timeout()} signal. Because of this, you
must start and stop the timer in its thread; it is not possible to
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index b504604..2ff9818 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1021,7 +1021,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
static void streamDebug(QDebug dbg, const QVariant &v)
{
- switch (v.type()) {
+ switch (v.userType()) {
case QVariant::Int:
dbg.nospace() << v.toInt();
break;
@@ -1034,6 +1034,9 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QVariant::ULongLong:
dbg.nospace() << v.toULongLong();
break;
+ case QMetaType::Float:
+ dbg.nospace() << qVariantValue<float>(v);
+ break;
case QVariant::Double:
dbg.nospace() << v.toDouble();
break;
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index 633e92c..970cbcc 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -70,7 +70,7 @@ public:
inline QByteArray pattern() const
{
if (q_pattern.isNull())
- return QByteArray((const char*)p.p, p.l);
+ return QByteArray(reinterpret_cast<const char*>(p.p), p.l);
return q_pattern;
}
diff --git a/src/corelib/tools/qdumper.cpp b/src/corelib/tools/qdumper.cpp
deleted file mode 100644
index c3b8524..0000000
--- a/src/corelib/tools/qdumper.cpp
+++ /dev/null
@@ -1,1157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** 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 qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdatetime.h>
-#include <qdebug.h>
-#include <qdir.h>
-#include <qfileinfo.h>
-#include <qhash.h>
-#include <qmap.h>
-#include <qmetaobject.h>
-#include <qobject.h>
-#include <qstring.h>
-#include <qvariant.h>
-#include <qvector.h>
-
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_DUMPER)
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef Q_OS_WIN
-# include <windows.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-
-// This is used to abort evaluation of custom data dumpers in a "coordinated"
-// way. Abortion will happen anyway when we try to access a non-initialized
-// non-trivial object, so there is no way to prevent this from occuring at all
-// conceptionally. Gdb will catch SIGSEGV and return to the calling frame.
-// This is just fine provided we only _read_ memory in the custom handlers
-// below.
-
-volatile int qProvokeSegFaultHelper;
-
-static void qCheckAccess(const void *d)
-{
- // provoke segfault when address is not readable
- qProvokeSegFaultHelper = *(char*)d;
-}
-
-static void qCheckPointer(const void *d)
-{
- if (!d)
- return;
- qProvokeSegFaultHelper = *(char*)d;
-}
-
-static void qProvokeSegFault()
-{
- // provoke segfault unconditionally
- qCheckAccess(0);
-}
-
-static char qDumpInBuffer[100];
-static char qDumpBuffer[1000];
-#ifdef Q_OS_WIN
-static char qDumpBuffer2[sizeof(qDumpBuffer) + 100];
-#endif
-
-static char toHex(int n)
-{
- return n < 10 ? '0' + n : 'a' - 10 + n;
-}
-
-
-struct QDumper
-{
- explicit QDumper();
- ~QDumper();
- void flush();
- QDumper &operator<<(long c);
- QDumper &operator<<(int i);
- QDumper &operator<<(unsigned long c);
- QDumper &operator<<(unsigned int i);
- QDumper &operator<<(const void *p);
- void put(char c);
- void addCommaIfNeeded();
- void putEncoded(unsigned c);
- QDumper &operator<<(const char *str);
- QDumper &operator<<(const QString &str);
- void disarm();
-
- void beginHash(); // start of data hash output
- void endHash(); // start of data hash output
-
- // the dumper arguments
- int protocolVersion; // dumper protocol version
- int token; // some token to show on success
- const char *outertype; // object type
- const char *iname; // object name used for display
- const char *exp; // object expression
- const char *innertype; // 'inner type' for class templates
- const void *data; // pointer to raw data
- bool dumpChildren; // do we want to see children?
-
- // handling of nested templates
- void setupTemplateParameters();
- enum { maxTemplateParameters = 10 };
- const char *templateParameters[maxTemplateParameters + 1];
- int templateParametersCount;
-
- // internal state
- bool success; // are we finished?
- size_t pos;
-};
-
-
-QDumper::QDumper()
-{
- success = false;
- pos = 0;
-}
-
-QDumper::~QDumper()
-{
- flush();
- put(0); // our end marker
-#ifdef Q_OS_WIN
- sprintf(qDumpBuffer2, "@@CDD/%d/done\n", token);
- OutputDebugStringA(qDumpBuffer2);
-#else
- fprintf(stderr, "%d/done\n", token);
-#endif
- qDumpInBuffer[0] = 0;
-}
-
-void QDumper::flush()
-{
- qDumpBuffer[pos++] = 0;
-#ifdef Q_OS_WIN
- sprintf(qDumpBuffer2, "@@CDD#%d#%d,%s\n", token, int(pos - 1), qDumpBuffer);
- OutputDebugStringA(qDumpBuffer2);
-#else
- fprintf(stderr, "%d#%d,%s\n", token, int(pos - 1), qDumpBuffer);
-#endif
- pos = 0;
-}
-
-void QDumper::setupTemplateParameters()
-{
- char *s = const_cast<char *>(innertype);
-
- templateParametersCount = 1;
- templateParameters[0] = s;
- for (int i = 1; i != maxTemplateParameters + 1; ++i)
- templateParameters[i] = 0;
-
- while (*s) {
- while (*s && *s != '@')
- ++s;
- if (*s) {
- *s = '\0';
- ++s;
- templateParameters[templateParametersCount++] = s;
- }
- }
-}
-
-QDumper &QDumper::operator<<(unsigned long c)
-{
- static char buf[100];
- sprintf(buf, "%lu", c);
- return (*this) << buf;
-}
-
-QDumper &QDumper::operator<<(unsigned int i)
-{
- static char buf[100];
- sprintf(buf, "%u", i);
- return (*this) << buf;
-}
-
-QDumper &QDumper::operator<<(long c)
-{
- static char buf[100];
- sprintf(buf, "%ld", c);
- return (*this) << buf;
-}
-
-QDumper &QDumper::operator<<(int i)
-{
- static char buf[100];
- sprintf(buf, "%d", i);
- return (*this) << buf;
-}
-
-QDumper &QDumper::operator<<(const void *p)
-{
- static char buf[100];
- sprintf(buf, "%p", p);
- // we get a '0x' prefix only on some implementations.
- // if it isn't there, write it out manually.
- if (buf[1] != 'x') {
- put('0');
- put('x');
- }
- return (*this) << buf;
-}
-
-void QDumper::put(char c)
-{
- if (pos >= sizeof(qDumpBuffer) - 100)
- flush();
- qDumpBuffer[pos++] = c;
-}
-
-void QDumper::addCommaIfNeeded()
-{
- if (pos == 0)
- return;
- if (qDumpBuffer[pos - 1] == '}' || qDumpBuffer[pos - 1] == '"')
- put(',');
-}
-
-void QDumper::putEncoded(unsigned c)
-{
- if (c >= 32 && c <= 126 && c != '"' && c != '\\') {
- put(c);
- } else {
- put('\\');
- put('u');
- put(toHex((c >> 12) & 0xf));
- put(toHex((c >> 8) & 0xf));
- put(toHex((c >> 4) & 0xf));
- put(toHex( c & 0xf));
- }
-}
-
-QDumper &QDumper::operator<<(const char *str)
-{
- while (*str)
- put(*(str++));
- return *this;
-}
-
-QDumper &QDumper::operator<<(const QString &str)
-{
- int n = str.size();
- if (n < 0) {
- qProvokeSegFault();
- } else {
- //(*this) << "[" << n << "]";
- if (n > 1000000)
- n = 1000000;
- //put(' ');
- put('\\');
- put('"');
- for (int i = 0; i != n; ++i)
- putEncoded(str[i].unicode());
- put('\\');
- put('"');
- if (n < str.size())
- (*this) << "<incomplete string>";
- }
- return *this;
-}
-
-void QDumper::disarm()
-{
- flush();
- success = true;
-}
-
-void QDumper::beginHash()
-{
- addCommaIfNeeded();
- put('{');
-}
-
-void QDumper::endHash()
-{
- put('}');
-}
-
-
-//
-// Some helpers to keep the dumper code short
-//
-
-// dump property=value pair
-#undef P
-#define P(dumper,name,value) \
- do { \
- dumper.addCommaIfNeeded(); \
- dumper << (name) << "=\"" << value << "\""; \
- } while (0)
-
-// simple string property
-#undef S
-#define S(dumper, name, value) \
- dumper.beginHash(); \
- P(dumper, "name", name); \
- P(dumper, "value", value); \
- P(dumper, "type", "QString"); \
- P(dumper, "numchild", "0"); \
- dumper.endHash();
-
-// simple integer property
-#undef I
-#define I(dumper, name, value) \
- dumper.beginHash(); \
- P(dumper, "name", name); \
- P(dumper, "value", value); \
- P(dumper, "type", "int"); \
- P(dumper, "numchild", "0"); \
- dumper.endHash();
-
-// simple boolean property
-#undef BL
-#define BL(dumper, name, value) \
- dumper.beginHash(); \
- P(dumper, "name", name); \
- P(dumper, "value", (value ? "true" : "false")); \
- P(dumper, "type", "bool"); \
- P(dumper, "numchild", "0"); \
- dumper.endHash();
-
-#undef TT
-#define TT(type, value) \
- "<tr><td>" << type << "</td><td> : </td><td>" << value << "</td></tr>"
-
-static void qDumpUnknown(QDumper &d)
-{
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "<internal error>");
- P(d, "type", d.outertype);
- P(d, "numchild", "0");
- d.disarm();
-}
-
-static void qDumpQPropertyList(QDumper &d)
-{
- const QObject *ob = (const QObject *)d.data;
- const QMetaObject *mo = ob->metaObject();
- P(d, "iname", d.iname);
- P(d, "addr", "<synthetic>");
- P(d, "type", "QObject");
- P(d, "numchild", mo->propertyCount());
- if (d.dumpChildren) {
- d << ",children=[";
- for (int i = mo->propertyCount(); --i >= 0; ) {
- const QMetaProperty & prop = mo->property(i);
- d.beginHash();
- P(d, "name", prop.name());
- if (QLatin1String(prop.typeName()) == QLatin1String("QString")) {
- P(d, "value", prop.read(ob).toString());
- P(d, "numchild", "0");
- } else if (QLatin1String(prop.typeName()) == QLatin1String("bool")) {
- P(d, "value", (prop.read(ob).toBool() ? "true" : "false"));
- P(d, "numchild", "0");
- } else if (QLatin1String(prop.typeName()) == QLatin1String("int")) {
- P(d, "value", prop.read(ob).toInt());
- P(d, "numchild", "0");
- } else {
- P(d, "exp", "((" << mo->className() << "*)" << ob
- << ")->" << prop.name() << "()");
- }
- P(d, "type", prop.typeName());
- P(d, "numchild", "1");
- d.endHash();
- }
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQObject(QDumper &d)
-{
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", (void*)d.data);
- P(d, "type", "QObject");
- P(d, "numchild", 4);
- if (d.dumpChildren) {
- const QMetaObject *mo = ob->metaObject();
- const QObjectList &children = ob->children();
- d << ",children=[";
- S(d, "objectName", ob->objectName());
- d.beginHash();
- P(d, "name", "properties");
- // FIXME: Note that when simply using '(QObject*)'
- // in the cast below, Gdb/MI _sometimes misparses
- // expressions further down in the tree.
- P(d, "exp", "*(class QObject*)" << d.data);
- P(d, "type", "QPropertyList");
- P(d, "value", "<" << mo->propertyCount() << " items>");
- P(d, "numchild", mo->propertyCount());
- d.endHash();
- d.beginHash();
- P(d, "name", "children");
- P(d, "exp", "((class QObject*)" << d.data << ")->children()");
- P(d, "type", "QList<QObject *>");
- P(d, "value", "<" << children.size() << " items>");
- P(d, "numchild", children.size());
- d.endHash();
- d.beginHash();
- P(d, "name", "parent");
- P(d, "exp", "((class QObject*)" << d.data << ")->parent()");
- P(d, "type", "QObject *");
- P(d, "numchild", (ob->parent() ? "1" : "0"));
- d.endHash();
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQDir(QDumper &d)
-{
- const QDir &dir = *reinterpret_cast<const QDir *>(d.data);
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", dir.path());
- P(d, "type", "QDir");
- P(d, "numchild", "3");
- if (d.dumpChildren) {
- d << ",children=[";
- S(d, "absolutePath", dir.absolutePath());
- S(d, "canonicalPath", dir.canonicalPath());
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQFileInfo(QDumper &d)
-{
- const QFileInfo &info = *reinterpret_cast<const QFileInfo *>(d.data);
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", info.filePath());
- P(d, "type", "QDir");
- P(d, "numchild", "3");
- if (d.dumpChildren) {
- d << ",children=[";
- S(d, "absolutePath", info.absolutePath());
- S(d, "absoluteFilePath", info.absoluteFilePath());
- S(d, "canonicalPath", info.canonicalPath());
- S(d, "canonicalFilePath", info.canonicalFilePath());
- S(d, "completeBaseName", info.completeBaseName());
- S(d, "completeSuffix", info.completeSuffix());
- S(d, "baseName", info.baseName());
-#ifdef Q_OS_MACX
- BL(d, "isBundle", info.isBundle());
- S(d, "bundleName", info.bundleName());
-#endif
- S(d, "completeSuffix", info.completeSuffix());
- S(d, "fileName", info.fileName());
- S(d, "filePath", info.filePath());
- S(d, "group", info.group());
- S(d, "owner", info.owner());
- S(d, "path", info.path());
-
- I(d, "groupid", (long)info.groupId());
- I(d, "ownerid", (long)info.ownerId());
- //QFile::Permissions permissions () const
- I(d, "permissions", info.permissions());
-
- //QDir absoluteDir () const
- //QDir dir () const
-
- BL(d, "caching", info.caching());
- BL(d, "exists", info.exists());
- BL(d, "isAbsolute", info.isAbsolute());
- BL(d, "isDir", info.isDir());
- BL(d, "isExecutable", info.isExecutable());
- BL(d, "isFile", info.isFile());
- BL(d, "isHidden", info.isHidden());
- BL(d, "isReadable", info.isReadable());
- BL(d, "isRelative", info.isRelative());
- BL(d, "isRoot", info.isRoot());
- BL(d, "isSymLink", info.isSymLink());
- BL(d, "isWritable", info.isWritable());
-
-#ifndef QT_NO_DATESTRING
- d.beginHash();
- P(d, "name", "created");
- P(d, "value", info.created().toString());
- P(d, "exp", "((QFileInfo*)" << d.data << ")->created()");
- P(d, "type", "QDateTime");
- P(d, "numchild", "1");
- d.endHash();
-
- d.beginHash();
- P(d, "name", "lastModified");
- P(d, "value", info.lastModified().toString());
- P(d, "exp", "((QFileInfo*)" << d.data << ")->lastModified()");
- P(d, "type", "QDateTime");
- P(d, "numchild", "1");
- d.endHash();
-
- d.beginHash();
- P(d, "name", "lastRead");
- P(d, "value", info.lastRead().toString());
- P(d, "exp", "((QFileInfo*)" << d.data << ")->lastRead()");
- P(d, "type", "QDateTime");
- P(d, "numchild", "1");
- d.endHash();
-#endif
-
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQDateTime(QDumper &d)
-{
-#ifdef QT_NO_DATESTRING
- qDumpUnknown(d);
-#else
- const QDateTime &date = *reinterpret_cast<const QDateTime *>(d.data);
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", date.toString());
- P(d, "type", "QDateTime");
- P(d, "numchild", "3");
- if (d.dumpChildren) {
- d << ",children=[";
- BL(d, "isNull", date.isNull());
- I(d, "toTime_t", (long)date.toTime_t());
- S(d, "toString", date.toString());
- S(d, "toString_(ISO)", date.toString(Qt::ISODate));
- S(d, "toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
- S(d, "toString_(Locale)", date.toString(Qt::LocaleDate));
- S(d, "toString", date.toString());
-
- d.beginHash();
- P(d, "name", "toUTC");
- P(d, "exp", "((QDateTime*)" << d.data << ")->toTimeSpec(Qt::UTC)");
- P(d, "type", "QDateTime");
- P(d, "numchild", "1");
- d.endHash();
-
- d.beginHash();
- P(d, "name", "toLocalTime");
- P(d, "exp", "((QDateTime*)" << d.data << ")->toTimeSpec(Qt::LocalTime)");
- P(d, "type", "QDateTime");
- P(d, "numchild", "1");
- d.endHash();
-
- d << "]";
- }
- d.disarm();
-#endif // ifdef QT_NO_DATESTRING
-}
-
-static void qDumpQString(QDumper &d)
-{
- const QString &str = *reinterpret_cast<const QString *>(d.data);
-
- // Try to provoke segfaults early to prevent the frontend
- // from asking for unavailable child details
- if (!str.isEmpty()) {
- volatile ushort dummy = 0;
- dummy += str.at(0).unicode();
- dummy += str.at(str.size() - 1).unicode();
- }
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", str);
- P(d, "type", "QString");
- P(d, "numchild", "0");
- d.disarm();
-}
-
-static void qDumpQStringList(QDumper &d)
-{
- const QStringList &list = *reinterpret_cast<const QStringList *>(d.data);
- int n = list.size();
- if (n < 0)
- qProvokeSegFault();
- if (n > 0) {
- qCheckAccess(&list.front());
- qCheckAccess(&list.back());
- }
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "<" << n << " items>");
- P(d, "valuedisabled", "true");
- P(d, "numchild", n);
- if (d.dumpChildren) {
- if (n > 100)
- n = 100;
- d << ",children=[";
- for (int i = 0; i != n; ++i) {
- S(d, "[" << i << "]", list[i]);
- }
- if (n < list.size()) {
- d.beginHash();
- P(d, "value", "<incomplete>");
- P(d, "type", " ");
- P(d, "numchild", "0");
- d.endHash();
- }
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQVariantHelper(const void *data, QString *value,
- QString *exp, int *numchild)
-{
- const QVariant &v = *reinterpret_cast<const QVariant *>(data);
- switch (v.type()) {
- case QVariant::Invalid:
- *value = QLatin1String("<invalid>");
- *numchild = 0;
- break;
- case QVariant::String:
- *value = QLatin1Char('"') + v.toString() + QLatin1Char('"');
- *numchild = 0;
- break;
- case QVariant::StringList:
- *exp = QString(QLatin1String("((QVariant*)%1)->d.data.c"))
- .arg((qulonglong)data);
- *numchild = v.toStringList().size();
- break;
- case QVariant::Int:
- *value = QString::number(v.toInt());
- *numchild= 0;
- break;
- case QVariant::Double:
- *value = QString::number(v.toDouble());
- *numchild = 0;
- break;
- default:
- // FIXME
- //*exp = QString("qVariantValue<" << v.typeName() << ">"
- // << "(*(QVariant*)" << data << ")");
- break;
- }
-}
-
-static void qDumpQVariant(QDumper &d)
-{
- const QVariant &v = *reinterpret_cast<const QVariant *>(d.data);
- QString value;
- QString exp;
- int numchild = 0;
- qDumpQVariantHelper(d.data, &value, &exp, &numchild);
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "(" << v.typeName() << ") " << qPrintable(value));
- P(d, "type", "QVariant");
- P(d, "numchild", 1);
- if (d.dumpChildren) {
- d << ",children=[";
- d.beginHash();
- P(d, "name", "value");
- if (!exp.isEmpty())
- P(d, "exp", qPrintable(exp));
- if (!value.isEmpty())
- P(d, "value", qPrintable(value));
- P(d, "type", v.typeName());
- P(d, "numchild", numchild);
- d.endHash();
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQList(QDumper &d)
-{
- // This uses the knowledge that QList<T> has only a single member
- // of type union { QListData p; QListData::Data *d; };
- const QListData &ldata = *reinterpret_cast<const QListData*>(d.data);
- const QListData::Data *pdata = *reinterpret_cast<const QListData::Data* const*>(d.data);
- int nn = ldata.size();
- if (nn < 0)
- qProvokeSegFault();
- if (nn > 0) {
- qCheckAccess(ldata.d->array);
- //qCheckAccess(ldata.d->array[0]);
- //qCheckAccess(ldata.d->array[nn - 1]);
- }
-
- int n = nn;
- P(d, "iname", d.iname);
- P(d, "value", "<" << n << " items>");
- P(d, "valuedisabled", "true");
- P(d, "numchild", n);
- if (d.dumpChildren) {
- if (n > 100)
- n = 100;
- d << ",children=[";
- for (int i = 0; i != n; ++i) {
- d.beginHash();
- P(d, "name", "[" << i << "]");
- // The exact condition here is:
- // QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic
- // but this data is not available in the compiled binary.
- // So as first approximation only do the 'isLarge' check:
- void *p = &(ldata.d->array[i + pdata->begin]);
- unsigned long voidpsize = sizeof(void*);
- P(d, "exp", "(sizeof(" << d.innertype << ")>" << voidpsize <<
- "?(**(" << d.innertype << "**)(" << p << "))"
- ":(*(" << d.innertype << "*)(" << p << ")))");
- P(d, "type", d.innertype);
- d.endHash();
- }
- if (n < nn) {
- d << ",{";
- P(d, "value", "<incomplete>");
- d.endHash();
- }
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQVector(QDumper &d)
-{
- // Use 'int' as representative value. No way (and no need)
- // to deduce proper type here.
- const QVector<int> &vec = *reinterpret_cast<const QVector<int> *>(d.data);
- const int nn = vec.size();
-
- // Try to provoke segfaults early to prevent the frontend
- // from asking for unavailable child details
- if (nn < 0)
- qProvokeSegFault();
- if (nn > 0) {
- qCheckAccess(&vec.front());
- qCheckAccess(&vec.back());
- }
-
- //int innersize = 0;
- //scanf(qDumpInBuffer, "%d", &innersize);
-
- int n = nn;
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "<" << n << " items>");
- P(d, "valuedisabled", "true");
- P(d, "numchild", n);
- if (d.dumpChildren) {
- if (n > 100)
- n = 100;
- d << ",children=[";
- for (int i = 0; i != n; ++i) {
- if (i)
- d << ",";
- d.beginHash();
- P(d, "name", "[" << i << "]");
- P(d, "exp", "(" << d.exp << ".d->array[" << i << "])");
- P(d, "type", d.innertype);
- d.endHash();
- }
- if (n < nn) {
- d << ",{";
- P(d, "value", "<incomplete>");
- d.endHash();
- }
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQHashNode(QDumper &d)
-{
- struct NodeOS { void *next; uint k; uint v; } nodeOS; // int-key optimization, small value
- struct NodeOL { void *next; uint k; void *v; } nodeOL; // int-key optimiatzion, large value
- struct NodeNS { void *next; uint h; uint k; uint v; } nodeNS; // no optimization, small value
- struct NodeNL { void *next; uint h; uint k; void *v; } nodeNL; // no optimization, large value
- struct NodeL { void *next; uint h; void *k; void *v; } nodeL; // complex key
-
- // offsetof(...,...) not yet in Standard C++
- const ulong nodeOSk ( (char *)&nodeOS.k - (char *)&nodeOS );
- const ulong nodeOSv ( (char *)&nodeOS.v - (char *)&nodeOS );
- const ulong nodeOLk ( (char *)&nodeOL.k - (char *)&nodeOL );
- const ulong nodeOLv ( (char *)&nodeOL.v - (char *)&nodeOL );
- const ulong nodeNSk ( (char *)&nodeNS.k - (char *)&nodeNS );
- const ulong nodeNSv ( (char *)&nodeNS.v - (char *)&nodeNS );
- const ulong nodeNLk ( (char *)&nodeNL.k - (char *)&nodeNL );
- const ulong nodeNLv ( (char *)&nodeNL.v - (char *)&nodeNL );
- const ulong nodeLk ( (char *)&nodeL.k - (char *)&nodeL );
- const ulong nodeLv ( (char *)&nodeL.v - (char *)&nodeL );
-
- const QHashData *h = reinterpret_cast<const QHashData *>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "");
- P(d, "numchild", 2);
- if (d.dumpChildren) {
- // there is a hash specialization in cast the key are integers or shorts
- bool isOptimizedIntKey = qstrcmp(keyType, "int") == 0
-#if defined(Q_BYTE_ORDER) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- || qstrcmp(keyType, "short") == 0
- || qstrcmp(keyType, "ushort") == 0
-#endif
- || qstrcmp(keyType, "uint") == 0;
-
- d << ",children=[";
- d.beginHash();
- P(d, "name", "key");
- P(d, "type", keyType);
- unsigned long intsize = sizeof(int);
- if (isOptimizedIntKey) {
- P(d, "exp", "*(" << keyType << "*)"
- "(((sizeof(" << valueType << ")>" << intsize << ")?"
- << nodeOLk << ":" << nodeOSk <<
- ")+(char*)" << h << ")");
- } else {
- P(d, "exp", "*(" << keyType << "*)"
- "(((sizeof(" << keyType << ")>" << intsize << ")?"
- << nodeLk << ":"
- "((sizeof(" << valueType << ")>" << intsize << ")?"
- << nodeNLk << ":" << nodeNSk << "))+(char*)" << h << ")");
- }
- d.endHash();
- d.beginHash();
- P(d, "name", "value");
- P(d, "type", valueType);
- if (isOptimizedIntKey) {
- P(d, "exp", "*(" << valueType << "*)"
- "(((sizeof(" << valueType << ")>" << intsize << ")?"
- << nodeOLv << ":" << nodeOSv << ")+(char*)" << h << ")");
- } else {
- P(d, "exp", "*(" << valueType << "*)"
- "(((sizeof(" << keyType << ")>" << intsize << ")?" << nodeLv << ":"
- "((sizeof(" << valueType << ")>" << intsize << ")?"
- << nodeNLv << ":" << nodeNSv << "))+(char*)" << h << ")");
- }
- d.endHash();
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQHash(QDumper &d)
-{
- QHashData *h = *reinterpret_cast<QHashData *const*>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- qCheckPointer(h->fakeNext);
- qCheckPointer(h->buckets);
-
- int n = h->size;
-
- if (n < 0)
- qProvokeSegFault();
- if (n > 0) {
- qCheckPointer(h->fakeNext);
- qCheckPointer(*h->buckets);
- }
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "<" << n << " items>");
- P(d, "numchild", n);
- if (d.dumpChildren) {
- if (n > 100)
- n = 100;
- d << ",children=[";
-
- QHashData::Node *node = h->firstNode();
- QHashData::Node *end = reinterpret_cast<QHashData::Node *>(h);
- int i = 0;
-
- while (node != end) {
- d.beginHash();
- P(d, "name", "[" << i << "]");
- P(d, "type", "QHashNode<" << keyType << "," << valueType << " >");
- P(d, "exp", "*(QHashNode<" << keyType << "," << valueType << " >*)" << node);
- d.endHash();
-
- ++i;
- node = QHashData::nextNode(node);
- }
- d << "]";
- }
- d.disarm();
-}
-
-static void qDumpQMapNode(QDumper &d)
-{
- const QMapData *h = reinterpret_cast<const QMapData *>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- qCheckAccess(h->backward);
- qCheckAccess(h->forward[0]);
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "");
- P(d, "numchild", 2);
- if (d.dumpChildren) {
- unsigned long voidpsize = sizeof(void*);
- d << ",children=[";
- d.beginHash();
- P(d, "name", "key");
- P(d, "type", keyType);
- P(d, "exp", "*(" << keyType << "*)"
- << "("
- << 2 * voidpsize
- << "-sizeof('QMap<" << keyType << "," << valueType << ">::Node')"
- << "+(char*)" << h
- << ")");
- d.endHash();
- d.beginHash();
- P(d, "name", "value");
- P(d, "type", valueType);
- P(d, "exp", "*(" << valueType << "*)"
- << "("
- << "(size_t)&(('QMap<" << keyType << "," << valueType << ">::Node'*)0)->value"
- << "+" << 2 * voidpsize
- << "-sizeof('QMap<" << keyType << "," << valueType << ">::Node')"
- << "+(char*)" << h
- << ")");
- d.endHash();
- d << "]";
- }
-
- d.disarm();
-}
-
-static void qDumpQMap(QDumper &d)
-{
- QMapData *h = *reinterpret_cast<QMapData *const*>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- int n = h->size;
-
- if (n < 0)
- qProvokeSegFault();
- if (n > 0) {
- qCheckAccess(h->backward);
- qCheckAccess(h->forward[0]);
- qCheckPointer(h->backward->backward);
- qCheckPointer(h->forward[0]->backward);
- }
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "<" << n << " items>");
- P(d, "numchild", n);
- if (d.dumpChildren) {
- if (n > 100)
- n = 100;
- d << ",children=[";
-
- QMapData::Node *node = reinterpret_cast<QMapData::Node *>(h->forward[0]);
- QMapData::Node *end = reinterpret_cast<QMapData::Node *>(h);
- int i = 0;
-
- while (node != end) {
- d.beginHash();
- P(d, "name", "[" << i << "]");
- P(d, "type", "QMap<" << keyType << "," << valueType << ">::Node");
- P(d, "exp", "*('QMap<" << keyType << "," << valueType << ">::Node'*)" << node);
- d.endHash();
-
- ++i;
- node = node->forward[0];
- }
- d << "]";
- }
-
- d.disarm();
-}
-
-static void qDumpQSet(QDumper &d)
-{
- // This uses the knowledge that QHash<T> has only a single member
- // of union { QHashData *d; QHashNode<Key, T> *e; };
- QHashData *hd = *(QHashData**)d.data;
- QHashData::Node *node = hd->firstNode();
-
- int n = hd->size;
- if (n < 0)
- qProvokeSegFault();
- if (n > 0) {
- qCheckAccess(node);
- qCheckPointer(node->next);
- }
-
- P(d, "iname", d.iname);
- P(d, "addr", d.data);
- P(d, "value", "<" << n << " items>");
- P(d, "valuedisabled", "true");
- P(d, "numchild", 2 * n);
- if (d.dumpChildren) {
- if (n > 100)
- n = 100;
- d << ",children=[";
- int i = 0;
- for (int bucket = 0; bucket != hd->numBuckets; ++bucket) {
- for (node = hd->buckets[bucket]; node->next; node = node->next) {
- d.beginHash();
- P(d, "name", "[" << i << "]");
- P(d, "type", d.innertype);
- P(d, "exp", "(('QHashNode<" << d.innertype
- << ",QHashDummyValue>'*)"
- << static_cast<const void*>(node) << ")->key"
- );
- d.endHash();
- ++i;
- }
- }
- d << "]";
- }
- d.disarm();
-}
-
-static void handleProtocolVersion2(QDumper & d)
-{
- if (!d.outertype[0]) {
- qDumpUnknown(d);
- return;
- }
-
- d.setupTemplateParameters();
- // d.outertype[0] is usally 'Q', so don't use it
- switch (d.outertype[1]) {
- case 'D':
- if (qstrcmp(d.outertype, "QDateTime") == 0)
- qDumpQDateTime(d);
- else if (qstrcmp(d.outertype, "QDir") == 0)
- qDumpQDir(d);
- break;
- case 'F':
- if (qstrcmp(d.outertype, "QFileInfo") == 0)
- qDumpQFileInfo(d);
- break;
- case 'H':
- if (qstrcmp(d.outertype, "QHash") == 0)
- qDumpQHash(d);
- else if (qstrcmp(d.outertype, "QHashNode") == 0)
- qDumpQHashNode(d);
- break;
- case 'L':
- if (qstrcmp(d.outertype, "QList") == 0)
- qDumpQList(d);
- break;
- case 'M':
- if (qstrcmp(d.outertype, "QMap") == 0)
- qDumpQMap(d);
- else if (qstrcmp(d.outertype, "QMap::Node") == 0)
- qDumpQMapNode(d);
- break;
- case 'O':
- if (qstrcmp(d.outertype, "QObject") == 0)
- qDumpQObject(d);
- break;
- case 'P':
- if (qstrcmp(d.outertype, "QPropertyList") == 0)
- qDumpQPropertyList(d);
- break;
- case 'S':
- if (qstrcmp(d.outertype, "QSet") == 0)
- qDumpQSet(d);
- else if (qstrcmp(d.outertype, "QString") == 0)
- qDumpQString(d);
- else if (qstrcmp(d.outertype, "QStringList") == 0)
- qDumpQStringList(d);
- break;
- case 'V':
- if (qstrcmp(d.outertype, "QVariant") == 0)
- qDumpQVariant(d);
- else if (qstrcmp(d.outertype, "QVector") == 0)
- qDumpQVector(d);
- break;
- }
-
- if (!d.success)
- qDumpUnknown(d);
-}
-
-} // anonymous namespace
-
-
-extern "C" Q_CORE_EXPORT void qDumpObjectData(
- int protocolVersion,
- int token,
- const char *outertype,
- const char *iname,
- const char *exp,
- const char *innertype,
- const void *data,
- bool dumpChildren)
-{
- if (protocolVersion == 1) {
- // used to test whether error output gets through
- //fprintf(stderr, "using stderr, qDebug follows: %d\n", token);
- //qDebug() << "using qDebug, stderr already used: " << token;
- }
-
- else if (protocolVersion == 2) {
- QDumper d;
- d.protocolVersion = protocolVersion;
- d.token = token;
- d.outertype = outertype ? outertype : "";
- d.iname = iname ? iname : "";
- d.exp = exp ? exp : "";
- d.innertype = innertype ? innertype : "";
- d.data = data ? data : "";
- d.dumpChildren = dumpChildren;
- handleProtocolVersion2(d);
- }
-
- else {
- qDebug() << "Unsupported protocol version" << protocolVersion;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // !Q_OS_WINCE && !QT_NO_QDUMPER
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index a18b531..632c422 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -97,10 +97,7 @@ Q_CORE_EXPORT uint qHash(const QBitArray &key);
#endif
template <class T> inline uint qHash(const T *key)
{
- if (sizeof(const T *) > sizeof(uint))
- return qHash(reinterpret_cast<quint64>(key));
- else
- return uint(reinterpret_cast<ulong>(key));
+ return qHash(reinterpret_cast<quintptr>(key));
}
#if defined(Q_CC_MSVC)
#pragma warning( pop )
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index a2154a9..66e3921 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -1589,7 +1589,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
defaults to the default locale (see setDefault()).
\endlist
- The "C" locale is identical to \l{English}/\l{UnitedStates}.
+ The "C" locale is identical in behavior to \l{English}/\l{UnitedStates}.
Use language() and country() to determine the actual language and
country values used.
@@ -1632,7 +1632,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
This enumerated type is used to specify a language.
- \value C The "C" locale is English/UnitedStates.
+ \value C The "C" locale is identical in behavior to English/UnitedStates.
\value Abkhazian
\value Afan
\value Afar
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 5f13e5a..32c8d17 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -990,7 +990,7 @@ Q_INLINE_TEMPLATE int QMultiMap<Key, T>::remove(const Key &key, const T &value)
{
int n = 0;
typename QMap<Key, T>::iterator i(find(key));
- typename QMap<Key, T>::const_iterator end(QMap<Key, T>::constEnd());
+ typename QMap<Key, T>::iterator end(QMap<Key, T>::end());
while (i != end && !qMapLessThanKey<Key>(key, i.key())) {
if (i.value() == value) {
i = erase(i);
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index 3930a0d..5602170 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -901,7 +901,7 @@ void QRect::moveCenter(const QPoint &p)
/*!
\fn bool QRect::contains(const QPoint &point, bool proper) const
- Returns true if the the given \a point is inside or on the edge of
+ Returns true if the given \a point is inside or on the edge of
the rectangle, otherwise returns false. If \a proper is true, this
function only returns true if the given \a point is \e inside the
rectangle (i.e., not on the edge).
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index f1b35ee..ad2d9f2 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -238,6 +238,7 @@ namespace QtSharedPointer {
template <class X> friend class ExternalRefCount;
template <class X> friend class QWeakPointer;
template <class X, class Y> friend QSharedPointer<X> qSharedPointerCastHelper(const QSharedPointer<Y> &src, X *);
+ template <class X, class Y> friend QSharedPointer<X> qSharedPointerDynamicCastHelper(const QSharedPointer<Y> &src, X *);
template <class X, class Y> friend QSharedPointer<X> qSharedPointerConstCastHelper(const QSharedPointer<Y> &src, X *);
template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::qStrongRefFromWeakHelper(const QWeakPointer<Y> &src, X *);
#endif
@@ -509,6 +510,14 @@ namespace QtSharedPointer {
return result;
}
template <class X, class T>
+ Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCastHelper(const QSharedPointer<T> &src, X *)
+ {
+ QSharedPointer<X> result;
+ register T *ptr = src.data();
+ result.internalSet(src.d, dynamic_cast<X *>(ptr));
+ return result;
+ }
+ template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCastHelper(const QSharedPointer<T> &src, X *)
{
QSharedPointer<X> result;
@@ -544,9 +553,7 @@ template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src)
{
X *x = 0;
- if (QtSharedPointer::qVerifyDynamicCast(src.data(), x))
- return QtSharedPointer::qSharedPointerCastHelper(src, x);
- return QSharedPointer<X>();
+ return QtSharedPointer::qSharedPointerDynamicCastHelper(src, x);
}
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src)
@@ -558,17 +565,13 @@ template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src)
{
X *x = 0;
- if (QtSharedPointer::qVerifyConstCast(src.data(), x))
- return QtSharedPointer::qSharedPointerConstCastHelper(src, x);
- return QSharedPointer<X>();
+ return QtSharedPointer::qSharedPointerConstCastHelper(src, x);
}
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src)
{
X *x = 0;
- if (QtSharedPointer::qVerifyConstCast(src.data(), x))
- return QtSharedPointer::qSharedPointerCastHelper(src, x);
- return QSharedPointer<X>();
+ return QtSharedPointer::qSharedPointerConstCastHelper(src, x);
}
template <class X, class T>
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index 76a5484..bbf6c2a 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -781,7 +781,7 @@ void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode)
\fn QDataStream &operator<<(QDataStream &stream, const QSizeF &size)
\relates QSizeF
- Writes the the given \a size to the given \a stream and returns a
+ Writes the given \a size to the given \a stream and returns a
reference to the stream.
\sa {Format of the QDataStream Operators}
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index 386321f1..e22f122 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -397,7 +397,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r
\fn QString QStringList::join(const QString &separator) const
Joins all the string list's strings into a single string with each
- element separated by the the given \a separator (which can be an
+ element separated by the given \a separator (which can be an
empty string).
\sa QString::split()
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 1f047b8..7bdcba0 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -82,19 +82,9 @@ struct Q_CORE_EXPORT QVectorData
};
template <typename T>
-struct QVectorTypedData
-{
- QBasicAtomicInt ref;
- int alloc;
- int size;
-#if defined(QT_ARCH_SPARC) && defined(Q_CC_GNU) && defined(__LP64__) && defined(QT_BOOTSTRAPPED)
- // workaround for bug in gcc 3.4.2
- uint sharable;
- uint capacity;
-#else
- uint sharable : 1;
- uint capacity : 1;
-#endif
+struct QVectorTypedData : private QVectorData
+{ // private inheritance as we must not access QVectorData member thought QVectorTypedData
+ // as this would break strict aliasing rules. (in the case of shared_null)
T array[1];
};
@@ -104,14 +94,14 @@ template <typename T>
class QVector
{
typedef QVectorTypedData<T> Data;
- union { QVectorData *p; QVectorTypedData<T> *d; };
+ union { QVectorData *d; Data *p; };
public:
- inline QVector() : p(&QVectorData::shared_null) { d->ref.ref(); }
+ inline QVector() : d(&QVectorData::shared_null) { d->ref.ref(); }
explicit QVector(int size);
QVector(int size, const T &t);
inline QVector(const QVector<T> &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
- inline ~QVector() { if (!d) return; if (!d->ref.deref()) free(d); }
+ inline ~QVector() { if (!d) return; if (!d->ref.deref()) free(p); }
QVector<T> &operator=(const QVector<T> &v);
bool operator==(const QVector<T> &v) const;
inline bool operator!=(const QVector<T> &v) const { return !(*this == v); }
@@ -130,9 +120,9 @@ public:
inline bool isDetached() const { return d->ref == 1; }
inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
- inline T *data() { detach(); return d->array; }
- inline const T *data() const { return d->array; }
- inline const T *constData() const { return d->array; }
+ inline T *data() { detach(); return p->array; }
+ inline const T *data() const { return p->array; }
+ inline const T *constData() const { return p->array; }
void clear();
const T &at(int i) const;
@@ -225,12 +215,12 @@ public:
typedef T* iterator;
typedef const T* const_iterator;
#endif
- inline iterator begin() { detach(); return d->array; }
- inline const_iterator begin() const { return d->array; }
- inline const_iterator constBegin() const { return d->array; }
- inline iterator end() { detach(); return d->array + d->size; }
- inline const_iterator end() const { return d->array + d->size; }
- inline const_iterator constEnd() const { return d->array + d->size; }
+ inline iterator begin() { detach(); return p->array; }
+ inline const_iterator begin() const { return p->array; }
+ inline const_iterator constBegin() const { return p->array; }
+ inline iterator end() { detach(); return p->array + d->size; }
+ inline const_iterator end() const { return p->array + d->size; }
+ inline const_iterator constEnd() const { return p->array + d->size; }
iterator insert(iterator before, int n, const T &x);
inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
iterator erase(iterator begin, iterator end);
@@ -327,11 +317,11 @@ inline void QVector<T>::clear()
template <typename T>
inline const T &QVector<T>::at(int i) const
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range");
- return d->array[i]; }
+ return p->array[i]; }
template <typename T>
inline const T &QVector<T>::operator[](int i) const
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
- return d->array[i]; }
+ return p->array[i]; }
template <typename T>
inline T &QVector<T>::operator[](int i)
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
@@ -369,7 +359,7 @@ QVector<T> &QVector<T>::operator=(const QVector<T> &v)
{
v.d->ref.ref();
if (!d->ref.deref())
- free(d);
+ free(p);
d = v.d;
if (!d->sharable)
detach_helper();
@@ -385,31 +375,31 @@ inline QVectorData *QVector<T>::malloc(int aalloc)
template <typename T>
QVector<T>::QVector(int asize)
{
- p = malloc(asize);
+ d = malloc(asize);
d->ref = 1;
d->alloc = d->size = asize;
d->sharable = true;
d->capacity = false;
if (QTypeInfo<T>::isComplex) {
- T* b = d->array;
- T* i = d->array + d->size;
+ T* b = p->array;
+ T* i = p->array + d->size;
while (i != b)
new (--i) T;
} else {
- qMemSet(d->array, 0, asize * sizeof(T));
+ qMemSet(p->array, 0, asize * sizeof(T));
}
}
template <typename T>
QVector<T>::QVector(int asize, const T &t)
{
- p = malloc(asize);
+ d = malloc(asize);
d->ref = 1;
d->alloc = d->size = asize;
d->sharable = true;
d->capacity = false;
- T* i = d->array + d->size;
- while (i != d->array)
+ T* i = p->array + d->size;
+ while (i != p->array)
new (--i) T(t);
}
@@ -418,7 +408,7 @@ void QVector<T>::free(Data *x)
{
if (QTypeInfo<T>::isComplex) {
T* b = x->array;
- T* i = b + x->size;
+ T* i = b + reinterpret_cast<QVectorData *>(x)->size;
while (i-- != b)
i->~T();
}
@@ -429,13 +419,13 @@ template <typename T>
void QVector<T>::realloc(int asize, int aalloc)
{
T *j, *i, *b;
- union { QVectorData *p; Data *d; } x;
+ union { QVectorData *d; Data *p; } x;
x.d = d;
if (QTypeInfo<T>::isComplex && aalloc == d->alloc && d->ref == 1) {
// pure resize
- i = d->array + d->size;
- j = d->array + asize;
+ i = p->array + d->size;
+ j = p->array + asize;
if (i > j) {
while (i-- != j)
i->~T();
@@ -450,22 +440,22 @@ void QVector<T>::realloc(int asize, int aalloc)
if (aalloc != d->alloc || d->ref != 1) {
// (re)allocate memory
if (QTypeInfo<T>::isStatic) {
- x.p = malloc(aalloc);
+ x.d = malloc(aalloc);
} else if (d->ref != 1) {
- x.p = QVectorData::malloc(sizeOfTypedData(), aalloc, sizeof(T), p);
+ x.d = QVectorData::malloc(sizeOfTypedData(), aalloc, sizeof(T), d);
} else {
if (QTypeInfo<T>::isComplex) {
// call the destructor on all objects that need to be
// destroyed when shrinking
if (asize < d->size) {
- j = d->array + asize;
- i = d->array + d->size;
+ j = p->array + asize;
+ i = p->array + d->size;
while (i-- != j)
i->~T();
- i = d->array + asize;
+ i = p->array + asize;
}
}
- x.p = p = static_cast<QVectorData *>(qRealloc(p, sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ x.d = d = static_cast<QVectorData *>(qRealloc(d, sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
}
x.d->ref = 1;
x.d->sharable = true;
@@ -474,31 +464,31 @@ void QVector<T>::realloc(int asize, int aalloc)
}
if (QTypeInfo<T>::isComplex) {
if (asize < d->size) {
- j = d->array + asize;
- i = x.d->array + asize;
+ j = p->array + asize;
+ i = x.p->array + asize;
} else {
// construct all new objects when growing
- i = x.d->array + asize;
- j = x.d->array + d->size;
+ i = x.p->array + asize;
+ j = x.p->array + d->size;
while (i != j)
new (--i) T;
- j = d->array + d->size;
+ j = p->array + d->size;
}
if (i != j) {
// copy objects from the old array into the new array
- b = x.d->array;
+ b = x.p->array;
while (i != b)
new (--i) T(*--j);
}
} else if (asize > d->size) {
// initialize newly allocated memory to 0
- qMemSet(x.d->array + d->size, 0, (asize - d->size) * sizeof(T));
+ qMemSet(x.p->array + d->size, 0, (asize - d->size) * sizeof(T));
}
x.d->size = asize;
x.d->alloc = aalloc;
if (d != x.d) {
if (!d->ref.deref())
- free(d);
+ free(p);
d = x.d;
}
}
@@ -506,15 +496,15 @@ void QVector<T>::realloc(int asize, int aalloc)
template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const
{
- if (i < 0 || i >= p->size) {
+ if (i < 0 || i >= d->size) {
return T();
}
- return d->array[i];
+ return p->array[i];
}
template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const
{
- return ((i < 0 || i >= p->size) ? defaultValue : d->array[i]);
+ return ((i < 0 || i >= d->size) ? defaultValue : p->array[i]);
}
template <typename T>
@@ -525,14 +515,14 @@ void QVector<T>::append(const T &t)
realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + 1, sizeof(T),
QTypeInfo<T>::isStatic));
if (QTypeInfo<T>::isComplex)
- new (d->array + d->size) T(copy);
+ new (p->array + d->size) T(copy);
else
- d->array[d->size] = copy;
+ p->array[d->size] = copy;
} else {
if (QTypeInfo<T>::isComplex)
- new (d->array + d->size) T(t);
+ new (p->array + d->size) T(t);
else
- d->array[d->size] = t;
+ p->array[d->size] = t;
}
++d->size;
}
@@ -540,27 +530,27 @@ void QVector<T>::append(const T &t)
template <typename T>
Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, const T &t)
{
- int offset = before - d->array;
+ int offset = before - p->array;
if (n != 0) {
const T copy(t);
if (d->ref != 1 || d->size + n > d->alloc)
realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + n, sizeof(T),
QTypeInfo<T>::isStatic));
if (QTypeInfo<T>::isStatic) {
- T *b = d->array + d->size;
- T *i = d->array + d->size + n;
+ T *b = p->array + d->size;
+ T *i = p->array + d->size + n;
while (i != b)
new (--i) T;
- i = d->array + d->size;
+ i = p->array + d->size;
T *j = i + n;
- b = d->array + offset;
+ b = p->array + offset;
while (i != b)
*--j = *--i;
i = b+n;
while (i != b)
*--i = copy;
} else {
- T *b = d->array + offset;
+ T *b = p->array + offset;
T *i = b + n;
memmove(i, b, (d->size - offset) * sizeof(T));
while (i != b)
@@ -568,29 +558,29 @@ Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before, size_type n,
}
d->size += n;
}
- return d->array + offset;
+ return p->array + offset;
}
template <typename T>
Q_TYPENAME QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
{
- int f = abegin - d->array;
- int l = aend - d->array;
+ int f = abegin - p->array;
+ int l = aend - p->array;
int n = l - f;
detach();
if (QTypeInfo<T>::isComplex) {
- qCopy(d->array+l, d->array+d->size, d->array+f);
- T *i = d->array+d->size;
- T* b = d->array+d->size-n;
+ qCopy(p->array+l, p->array+d->size, p->array+f);
+ T *i = p->array+d->size;
+ T* b = p->array+d->size-n;
while (i != b) {
--i;
i->~T();
}
} else {
- memmove(d->array + f, d->array + l, (d->size-l)*sizeof(T));
+ memmove(p->array + f, p->array + l, (d->size-l)*sizeof(T));
}
d->size -= n;
- return d->array + f;
+ return p->array + f;
}
template <typename T>
@@ -600,9 +590,9 @@ bool QVector<T>::operator==(const QVector<T> &v) const
return false;
if (d == v.d)
return true;
- T* b = d->array;
+ T* b = p->array;
T* i = b + d->size;
- T* j = v.d->array + d->size;
+ T* j = v.p->array + d->size;
while (i != b)
if (!(*--i == *--j))
return false;
@@ -615,8 +605,8 @@ QVector<T> &QVector<T>::fill(const T &from, int asize)
const T copy(from);
resize(asize < 0 ? d->size : asize);
if (d->size) {
- T *i = d->array + d->size;
- T *b = d->array;
+ T *i = p->array + d->size;
+ T *b = p->array;
while (i != b)
*--i = copy;
}
@@ -629,9 +619,9 @@ QVector<T> &QVector<T>::operator+=(const QVector &l)
int newSize = d->size + l.d->size;
realloc(d->size, newSize);
- T *w = d->array + newSize;
- T *i = l.d->array + l.d->size;
- T *b = l.d->array;
+ T *w = p->array + newSize;
+ T *i = l.p->array + l.d->size;
+ T *b = l.p->array;
while (i != b) {
if (QTypeInfo<T>::isComplex)
new (--w) T(*--i);
@@ -648,11 +638,11 @@ int QVector<T>::indexOf(const T &t, int from) const
if (from < 0)
from = qMax(from + d->size, 0);
if (from < d->size) {
- T* n = d->array + from - 1;
- T* e = d->array + d->size;
+ T* n = p->array + from - 1;
+ T* e = p->array + d->size;
while (++n != e)
if (*n == t)
- return n - d->array;
+ return n - p->array;
}
return -1;
}
@@ -665,8 +655,8 @@ int QVector<T>::lastIndexOf(const T &t, int from) const
else if (from >= d->size)
from = d->size-1;
if (from >= 0) {
- T* b = d->array;
- T* n = d->array + from + 1;
+ T* b = p->array;
+ T* n = p->array + from + 1;
while (n != b) {
if (*--n == t)
return n - b;
@@ -678,8 +668,8 @@ int QVector<T>::lastIndexOf(const T &t, int from) const
template <typename T>
bool QVector<T>::contains(const T &t) const
{
- T* b = d->array;
- T* i = d->array + d->size;
+ T* b = p->array;
+ T* i = p->array + d->size;
while (i != b)
if (*--i == t)
return true;
@@ -690,8 +680,8 @@ template <typename T>
int QVector<T>::count(const T &t) const
{
int c = 0;
- T* b = d->array;
- T* i = d->array + d->size;
+ T* b = p->array;
+ T* i = p->array + d->size;
while (i != b)
if (*--i == t)
++c;
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 2a1c1fc..90287cb 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -47,7 +47,6 @@ SOURCES += \
tools/qbytearraymatcher.cpp \
tools/qcryptographichash.cpp \
tools/qdatetime.cpp \
- tools/qdumper.cpp \
tools/qeasingcurve.cpp \
tools/qhash.cpp \
tools/qline.cpp \