summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-22 08:38:59 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-22 08:38:59 (GMT)
commit252ea664604c85a5e993d28ee32d2aa0da7eca85 (patch)
tree0819bdd6e3614048faa8f2739299fb4be4301795 /src/corelib
parent31ac8ea4a7a5360a01c2fc1f8f930ae8b236c94b (diff)
parentfe48ca11f7da7200c052a7825ad4d46319b13cc5 (diff)
downloadQt-252ea664604c85a5e993d28ee32d2aa0da7eca85.zip
Qt-252ea664604c85a5e993d28ee32d2aa0da7eca85.tar.gz
Qt-252ea664604c85a5e993d28ee32d2aa0da7eca85.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: doc/src/qnamespace.qdoc src/corelib/global/qnamespace.h src/gui/graphicsview/qgraphicsscene.cpp
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp1
-rw-r--r--src/corelib/codecs/qfontlaocodec.cpp3
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp15
-rw-r--r--src/corelib/codecs/qisciicodec.cpp6
-rw-r--r--src/corelib/codecs/qlatincodec.cpp6
-rw-r--r--src/corelib/codecs/qsimplecodec.cpp6
-rw-r--r--src/corelib/codecs/qtsciicodec.cpp3
-rw-r--r--src/corelib/codecs/qutfcodec.cpp6
-rw-r--r--src/corelib/global/qnamespace.h4
-rw-r--r--src/corelib/tools/qbytearray.cpp30
-rw-r--r--src/corelib/tools/qbytearray.h3
-rw-r--r--src/corelib/tools/qlocale.cpp6
-rw-r--r--src/corelib/tools/qstring.cpp29
-rw-r--r--src/corelib/tools/qstring.h3
-rw-r--r--src/corelib/tools/qstringbuilder.h2
15 files changed, 57 insertions, 66 deletions
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index a68301c..7526a81 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -43,6 +43,7 @@
\class QPropertyAnimation
\brief The QPropertyAnimation class animates Qt properties
\since 4.6
+ \mainclass
\ingroup animation
QPropertyAnimation interpolates over \l{Qt's Property System}{Qt
diff --git a/src/corelib/codecs/qfontlaocodec.cpp b/src/corelib/codecs/qfontlaocodec.cpp
index 85017e0..6dd87de 100644
--- a/src/corelib/codecs/qfontlaocodec.cpp
+++ b/src/corelib/codecs/qfontlaocodec.cpp
@@ -97,8 +97,7 @@ QString QFontLaoCodec::convertToUnicode(const char *, int, ConverterState *) con
QByteArray QFontLaoCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const
{
- QByteArray rstring;
- rstring.resize(len);
+ QByteArray rstring(len, Qt::Uninitialized);
uchar *rdata = (uchar *) rstring.data();
const QChar *sdata = uc;
int i = 0;
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 6b9c77b..1bf76ea 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -225,11 +225,10 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
char *inBytes = const_cast<char *>(chars);
#endif
- QByteArray in;
if (remainingCount) {
// we have to prepend the remaining bytes from the previous conversion
inBytesLeft += remainingCount;
- in.resize(inBytesLeft);
+ QByteArray in(inBytesLeft, Qt::Uninitialized);
inBytes = in.data();
memcpy(in.data(), remainingBuffer, remainingCount);
@@ -238,9 +237,8 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
remainingCount = 0;
}
- QByteArray ba;
size_t outBytesLeft = len * 2 + 2;
- ba.resize(outBytesLeft);
+ QByteArray ba(outBytesLeft, Qt::Uninitialized);
char *outBytes = ba.data();
do {
size_t ret = iconv(state->cd, &inBytes, &inBytesLeft, &outBytes, &outBytesLeft);
@@ -328,8 +326,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
state = new IconvState(QIconvCodec::createIconv_t(0, UTF16));
if (state->cd != reinterpret_cast<iconv_t>(-1)) {
size_t outBytesLeft = len + 3; // +3 for the BOM
- QByteArray ba;
- ba.resize(outBytesLeft);
+ QByteArray ba(outBytesLeft, Qt::Uninitialized);
outBytes = ba.data();
#if !defined(NO_BOM)
@@ -358,18 +355,16 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
}
size_t outBytesLeft = len;
- QByteArray ba;
- ba.resize(outBytesLeft);
+ QByteArray ba(outBytesLeft, Qt::Uninitialized);
outBytes = ba.data();
// now feed iconv() the real data
inBytes = const_cast<char *>(reinterpret_cast<const char *>(uc));
inBytesLeft = len * sizeof(QChar);
- QByteArray in;
if (convState && convState->remainingChars) {
// we have one surrogate char to be prepended
- in.resize(sizeof(QChar) + len);
+ QByteArray in(sizeof(QChar) + len, Qt::Uninitialized);
inBytes = in.data();
QChar remaining = convState->state_data[0];
diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp
index a33fd0d..c054313 100644
--- a/src/corelib/codecs/qisciicodec.cpp
+++ b/src/corelib/codecs/qisciicodec.cpp
@@ -187,8 +187,7 @@ QByteArray QIsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
}
int invalid = 0;
- QByteArray result;
- result.resize(2*len); //worst case
+ QByteArray result(2 * len, Qt::Uninitialized); //worst case
uchar *ch = reinterpret_cast<uchar *>(result.data());
@@ -250,8 +249,7 @@ QString QIsciiCodec::convertToUnicode(const char* chars, int len, ConverterState
halant = state->state_data[0];
}
- QString result;
- result.resize(len);
+ QString result(len, Qt::Uninitialized);
QChar *uc = result.data();
const int base = codecs[idx].base;
diff --git a/src/corelib/codecs/qlatincodec.cpp b/src/corelib/codecs/qlatincodec.cpp
index 176ae97..9113555 100644
--- a/src/corelib/codecs/qlatincodec.cpp
+++ b/src/corelib/codecs/qlatincodec.cpp
@@ -62,8 +62,7 @@ QString QLatin1Codec::convertToUnicode(const char *chars, int len, ConverterStat
QByteArray QLatin1Codec::convertFromUnicode(const QChar *ch, int len, ConverterState *state) const
{
const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
- QByteArray r;
- r.resize(len);
+ QByteArray r(len, Qt::Uninitialized);
char *d = r.data();
int invalid = 0;
for (int i = 0; i < len; ++i) {
@@ -151,8 +150,7 @@ QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterSta
QByteArray QLatin15Codec::convertFromUnicode(const QChar *in, int length, ConverterState *state) const
{
const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
- QByteArray r;
- r.resize(length);
+ QByteArray r(length, Qt::Uninitialized);
char *d = r.data();
int invalid = 0;
for (int i = 0; i < length; ++i) {
diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp
index 7a62d4e..0d14f67 100644
--- a/src/corelib/codecs/qsimplecodec.cpp
+++ b/src/corelib/codecs/qsimplecodec.cpp
@@ -653,8 +653,7 @@ QString QSimpleTextCodec::convertToUnicode(const char* chars, int len, Converter
const unsigned char * c = (const unsigned char *)chars;
- QString r;
- r.resize(len);
+ QString r(len, Qt::Uninitialized);
QChar* uc = r.data();
for (int i = 0; i < len; i++) {
@@ -677,8 +676,7 @@ QByteArray QSimpleTextCodec::convertFromUnicode(const QChar *in, int length, Con
delete tmp;
}
- QByteArray r;
- r.resize(length);
+ QByteArray r(length, Qt::Uninitialized);
int i = length;
int u;
const QChar* ucp = in;
diff --git a/src/corelib/codecs/qtsciicodec.cpp b/src/corelib/codecs/qtsciicodec.cpp
index 7f660bf..c24d32d 100644
--- a/src/corelib/codecs/qtsciicodec.cpp
+++ b/src/corelib/codecs/qtsciicodec.cpp
@@ -82,8 +82,7 @@ QByteArray QTsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
}
int invalid = 0;
- QByteArray rstr;
- rstr.resize(len);
+ QByteArray rstr(len, Qt::Uninitialized);
uchar* cursor = (uchar*)rstr.data();
for (int i = 0; i < len; i++) {
QChar ch = uc[i];
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index 12575f9..abae6f7 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -351,8 +351,7 @@ QString QUtf16Codec::convertToUnicode(const char *chars, int len, ConverterState
if (headerdone && endian == Detect)
endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BE : LE;
- QString result;
- result.resize(len); // worst case
+ QString result(len, Qt::Uninitialized); // worst case
QChar *qch = (QChar *)result.unicode();
while (len--) {
if (half) {
@@ -472,8 +471,7 @@ QByteArray QUtf32Codec::convertFromUnicode(const QChar *uc, int len, ConverterSt
endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BE : LE;
}
- QByteArray d;
- d.resize(length);
+ QByteArray d(length, Qt::Uninitialized);
char *data = d.data();
if (!state || !(state->flags & IgnoreHeader)) {
if (endian == BE) {
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index fe11fab..2e2a09d 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1546,6 +1546,10 @@ public:
TitleBarArea // For move
};
+ enum Initialization {
+ Uninitialized
+ };
+
enum TouchPointState {
TouchPointPressed = 0x01,
TouchPointMoved = 0x02,
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 0c45776..5d3386e 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -1304,6 +1304,21 @@ QByteArray::QByteArray(int size, char ch)
}
/*!
+ \internal
+
+ Constructs a byte array of size \a size with uninitialized contents.
+*/
+
+QByteArray::QByteArray(int size, Qt::Initialization)
+{
+ d = static_cast<Data *>(qMalloc(sizeof(Data)+size));
+ d->ref = 1;
+ d->alloc = d->size = size;
+ d->data = d->array;
+ d->array[size] = '\0';
+}
+
+/*!
Sets the size of the byte array to \a size bytes.
If \a size is greater than the current size, the byte array is
@@ -2977,8 +2992,7 @@ QByteArray QByteArray::simplified() const
{
if (d->size == 0)
return *this;
- QByteArray result;
- result.resize(d->size);
+ QByteArray result(d->size, Qt::Uninitialized);
const char *from = d->data;
const char *fromend = from + d->size;
int outc=0;
@@ -3429,8 +3443,7 @@ QByteArray QByteArray::toBase64() const
const char padchar = '=';
int padlen = 0;
- QByteArray tmp;
- tmp.resize(((d->size * 4) / 3) + 3);
+ QByteArray tmp((d->size * 4) / 3 + 3, Qt::Uninitialized);
int i = 0;
char *out = tmp.data();
@@ -3768,8 +3781,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64)
{
unsigned int buf = 0;
int nbits = 0;
- QByteArray tmp;
- tmp.resize((base64.size() * 3) / 4);
+ QByteArray tmp((base64.size() * 3) / 4, Qt::Uninitialized);
int offset = 0;
for (int i = 0; i < base64.size(); ++i) {
@@ -3817,8 +3829,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64)
*/
QByteArray QByteArray::fromHex(const QByteArray &hexEncoded)
{
- QByteArray res;
- res.resize((hexEncoded.size() + 1)/ 2);
+ QByteArray res((hexEncoded.size() + 1)/ 2, Qt::Uninitialized);
uchar *result = (uchar *)res.data() + res.size();
bool odd_digit = true;
@@ -3855,8 +3866,7 @@ QByteArray QByteArray::fromHex(const QByteArray &hexEncoded)
*/
QByteArray QByteArray::toHex() const
{
- QByteArray hex;
- hex.resize(d->size*2);
+ QByteArray hex(d->size * 2, Qt::Uninitialized);
char *hexData = hex.data();
const uchar *data = (const uchar *)d->data;
for (int i = 0; i < d->size; ++i) {
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 5cd4d63..e494ac1 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -42,8 +42,8 @@
#ifndef QBYTEARRAY_H
#define QBYTEARRAY_H
-#include <QtCore/qglobal.h>
#include <QtCore/qatomic.h>
+#include <QtCore/qnamespace.h>
#include <string.h>
#include <stdarg.h>
@@ -127,6 +127,7 @@ public:
QByteArray(const char *);
QByteArray(const char *, int size);
QByteArray(int size, char c);
+ QByteArray(int size, Qt::Initialization);
inline QByteArray(const QByteArray &);
inline ~QByteArray();
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 52fb8a2..cbdd32c 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -185,8 +185,7 @@ static QString languageToCode(QLocale::Language language)
const unsigned char *c = language_code_list + 3*(uint(language));
- QString code;
- code.resize(c[2] == 0 ? 2 : 3);
+ QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized);
code[0] = ushort(c[0]);
code[1] = ushort(c[1]);
@@ -201,8 +200,7 @@ static QString countryToCode(QLocale::Country country)
if (country == QLocale::AnyCountry)
return QString();
- QString code;
- code.resize(2);
+ QString code(2, Qt::Uninitialized);
const unsigned char *c = country_code_list + 2*(uint(country));
code[0] = ushort(c[0]);
code[1] = ushort(c[1]);
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 3b70f44..3ff263d 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1012,14 +1012,13 @@ QString::QString(int size, QChar ch)
}
}
-/*!
- Constructs a string of the given \a size without initializing the
- characters. This is only used in \c QStringBuilder::toString().
+/*! \fn QString::QString(int size, Qt::Initialization)
+ \internal
- \internal
+ Constructs a string of the given \a size without initializing the
+ characters. This is only used in \c QStringBuilder::toString().
*/
-
-QString::QString(int size, Uninitialized)
+QString::QString(int size, Qt::Initialization)
{
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
d->ref = 1;
@@ -3849,8 +3848,7 @@ QString QString::fromUtf8(const char *str, int size)
if (size < 0)
size = qstrlen(str);
- QString result;
- result.resize(size); // worst case
+ QString result(size, Qt::Uninitialized); // worst case
ushort *qch = result.d->data;
uint uc = 0;
uint min_uc = 0;
@@ -3965,8 +3963,7 @@ QString QString::fromUcs4(const uint *unicode, int size)
++size;
}
- QString s;
- s.resize(size*2); // worst case
+ QString s(size * 2, Qt::Uninitialized); // worst case
ushort *uc = s.d->data;
for (int i = 0; i < size; ++i) {
uint u = unicode[i];
@@ -4029,8 +4026,7 @@ QString QString::simplified() const
{
if (d->size == 0)
return *this;
- QString result;
- result.resize(d->size);
+ QString result(d->size, Qt::Uninitialized);
const QChar *from = (const QChar*) d->data;
const QChar *fromend = (const QChar*) from+d->size;
int outc=0;
@@ -4882,8 +4878,7 @@ QString QString::toLower() const
c = QChar::surrogateToUcs4(*(p - 1), c);
const QUnicodeTables::Properties *prop = qGetProp(c);
if (prop->lowerCaseDiff || prop->lowerCaseSpecial) {
- QString s;
- s.resize(d->size);
+ QString s(d->size, Qt::Uninitialized);
memcpy(s.d->data, d->data, (p - d->data)*sizeof(ushort));
ushort *pp = s.d->data + (p - d->data);
while (p < e) {
@@ -4974,8 +4969,7 @@ QString QString::toUpper() const
c = QChar::surrogateToUcs4(*(p - 1), c);
const QUnicodeTables::Properties *prop = qGetProp(c);
if (prop->upperCaseDiff || prop->upperCaseSpecial) {
- QString s;
- s.resize(d->size);
+ QString s(d->size, Qt::Uninitialized);
memcpy(s.d->data, d->data, (p - d->data)*sizeof(ushort));
ushort *pp = s.d->data + (p - d->data);
while (p < e) {
@@ -6272,8 +6266,7 @@ static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int f
+ d.locale_occurrences
*qMax(abs_field_width, larg.length());
- QString result;
- result.resize(result_len);
+ QString result(result_len, Qt::Uninitialized);
QChar *result_buff = (QChar*) result.unicode();
QChar *rc = result_buff;
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 4b2ceb7..6bb0d8e 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -579,8 +579,7 @@ public:
bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; }
bool isRightToLeft() const { if (!d->clean) updateProperties(); return d->righttoleft; }
- struct Uninitialized {};
- QString(int size, Uninitialized);
+ QString(int size, Qt::Initialization);
private:
#if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED)
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 19f14b4..852c072 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -80,7 +80,7 @@ public:
operator QString() const
{
QString s(QConcatenable< QStringBuilder<A, B> >::size(*this),
- QString::Uninitialized());
+ Qt::Uninitialized);
QChar *d = s.data();
QConcatenable< QStringBuilder<A, B> >::appendTo(*this, d);