summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-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.cpp3
-rw-r--r--src/corelib/codecs/qtsciicodec.cpp3
-rw-r--r--src/corelib/codecs/qutfcodec.cpp3
-rw-r--r--src/corelib/global/qglobal.h12
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp4
-rw-r--r--src/corelib/statemachine/qstate.cpp17
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp104
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h1
-rw-r--r--src/corelib/tools/qbytearray.cpp30
-rw-r--r--src/corelib/tools/qbytearray.h3
-rw-r--r--src/corelib/tools/qstring.cpp11
-rw-r--r--src/corelib/tools/qstring.h2
17 files changed, 105 insertions, 120 deletions
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 aa7521d..0d14f67 100644
--- a/src/corelib/codecs/qsimplecodec.cpp
+++ b/src/corelib/codecs/qsimplecodec.cpp
@@ -676,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 fe826ad..abae6f7 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -471,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/qglobal.h b/src/corelib/global/qglobal.h
index 3e6771c..0721c39 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1143,6 +1143,11 @@ class QDataStream;
# else
# define Q_OPENGL_EXPORT Q_DECL_IMPORT
# endif
+# if defined(QT_BUILD_OPENVG_LIB)
+# define Q_OPENVG_EXPORT Q_DECL_EXPORT
+# else
+# define Q_OPENVG_EXPORT Q_DECL_IMPORT
+# endif
# if defined(QT_BUILD_XML_LIB)
# define Q_XML_EXPORT Q_DECL_EXPORT
# else
@@ -1182,6 +1187,7 @@ class QDataStream;
# define Q_SVG_EXPORT Q_DECL_IMPORT
# define Q_CANVAS_EXPORT Q_DECL_IMPORT
# define Q_OPENGL_EXPORT Q_DECL_IMPORT
+# define Q_OPENVG_EXPORT Q_DECL_IMPORT
# define Q_XML_EXPORT Q_DECL_IMPORT
# define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
# define Q_SCRIPT_EXPORT Q_DECL_IMPORT
@@ -1207,6 +1213,7 @@ class QDataStream;
# define Q_NETWORK_EXPORT Q_DECL_EXPORT
# define Q_SVG_EXPORT Q_DECL_EXPORT
# define Q_OPENGL_EXPORT Q_DECL_EXPORT
+# define Q_OPENVG_EXPORT Q_DECL_EXPORT
# define Q_XML_EXPORT Q_DECL_EXPORT
# define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
# define Q_SCRIPT_EXPORT Q_DECL_EXPORT
@@ -2252,6 +2259,7 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
#define QT_MODULE_TEST 0x04000
#define QT_MODULE_DBUS 0x08000
#define QT_MODULE_SCRIPTTOOLS 0x10000
+#define QT_MODULE_OPENVG 0x20000
/* Qt editions */
#define QT_EDITION_CONSOLE (QT_MODULE_CORE \
@@ -2271,6 +2279,7 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
| QT_MODULE_GUI \
| QT_MODULE_NETWORK \
| QT_MODULE_OPENGL \
+ | QT_MODULE_OPENVG \
| QT_MODULE_SQL \
| QT_MODULE_XML \
| QT_MODULE_XMLPATTERNS \
@@ -2314,6 +2323,9 @@ QT_LICENSED_MODULE(Network)
#if (QT_EDITION & QT_MODULE_OPENGL)
QT_LICENSED_MODULE(OpenGL)
#endif
+#if (QT_EDITION & QT_MODULE_OPENVG)
+QT_LICENSED_MODULE(OpenVG)
+#endif
#if (QT_EDITION & QT_MODULE_SQL)
QT_LICENSED_MODULE(Sql)
#endif
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 398cd48..2023327 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1543,7 +1543,7 @@ public:
TitleBarArea // For move
};
- enum Uninitialized {
+ enum Initialization {
Uninitialized
};
}
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index b0247f8..e6a471c 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -643,8 +643,8 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
/*!
Sends \a event to \a receiver: \a {receiver}->event(\a event).
Returns the value that is returned from the receiver's event
- handler. Note that this function is called for all events send to
- any object is all threads.
+ handler. Note that this function is called for all events sent to
+ any object in any thread.
For certain types of events (e.g. mouse and key events),
the event will be propagated to the receiver's parent and so on up to
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index c42c9c9..83dd869 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -240,7 +240,7 @@ void QState::assignProperty(QObject *object, const char *name,
}
/*!
- Returns this state group's error state.
+ Returns this state's error state.
\sa QStateMachine::errorState(), QStateMachine::setErrorState()
*/
@@ -253,7 +253,9 @@ QAbstractState *QState::errorState() const
/*!
Sets this state's error state to be the given \a state. If the error state
is not set, or if it is set to 0, the state will inherit its parent's error
- state recursively.
+ state recursively. If no error state is set for the state itself or any of
+ its ancestors, an error will cause the machine to stop executing and an error
+ will be printed to the console.
\sa QStateMachine::setErrorState(), QStateMachine::errorState()
*/
@@ -333,10 +335,13 @@ QSignalTransition *QState::addTransition(QObject *sender, const char *signal,
return 0;
}
int offset = (*signal == '0'+QSIGNAL_CODE) ? 1 : 0;
- if (sender->metaObject()->indexOfSignal(signal+offset) == -1) {
- qWarning("QState::addTransition: no such signal %s::%s",
- sender->metaObject()->className(), signal+offset);
- return 0;
+ const QMetaObject *meta = sender->metaObject();
+ if (meta->indexOfSignal(signal+offset) == -1) {
+ if (meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1) {
+ qWarning("QState::addTransition: no such signal %s::%s",
+ meta->className(), signal+offset);
+ return 0;
+ }
}
QSignalTransition *trans = new QSignalTransition(sender, signal, QList<QAbstractState*>() << target);
addTransition(trans);
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 758bdbe..bf3ee31 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -156,16 +156,14 @@ QT_BEGIN_NAMESPACE
transitions, e.g., \l{QSignalTransition}s as in this example. See
the QState class description for further details.
- If an error is encountered, the machine will enter the
- \l{errorState}{error state}, which is a special state created by
- the machine. The types of errors possible are described by the
+ If an error is encountered, the machine will look for an
+ \l{errorState}{error state}, and if one is available, it will
+ enter this state. The types of errors possible are described by the
\l{QStateMachine::}{Error} enum. After the error state is entered,
the type of the error can be retrieved with error(). The execution
- of the state graph will not stop when the error state is entered.
- So it is possible to handle the error, for instance, by connecting
- to the \l{QAbstractState::}{entered()} signal of the error state.
- It is also possible to set a custom error state with
- setErrorState().
+ of the state graph will not stop when the error state is entered. If
+ no error state applies to the erroneous state, the machine will stop
+ executing and an error message will be printed to the console.
\omit This stuff will be moved elsewhere
This is
@@ -238,7 +236,6 @@ QStateMachinePrivate::QStateMachinePrivate()
error = QStateMachine::NoError;
globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
rootState = 0;
- initialErrorStateForRoot = 0;
signalEventGenerator = 0;
#ifndef QT_NO_ANIMATION
animationsEnabled = true;
@@ -984,27 +981,25 @@ void QStateMachinePrivate::unregisterRestorable(QObject *object, const QByteArra
QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context)
{
- // If the user sets the root state's error state to 0, we return the initial error state
- if (context == 0)
- return initialErrorStateForRoot;
-
// Find error state recursively in parent hierarchy if not set explicitly for context state
QAbstractState *errorState = 0;
-
- QState *s = qobject_cast<QState*>(context);
- if (s)
- errorState = s->errorState();
+ if (context != 0) {
+ QState *s = qobject_cast<QState*>(context);
+ if (s != 0)
+ errorState = s->errorState();
- if (!errorState)
- errorState = findErrorState(context->parentState());
+ if (errorState == 0)
+ errorState = findErrorState(context->parentState());
+ }
return errorState;
}
void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractState *currentContext)
{
+ Q_Q(QStateMachine);
+
error = errorCode;
-
switch (errorCode) {
case QStateMachine::NoInitialStateError:
Q_ASSERT(currentContext != 0);
@@ -1036,16 +1031,19 @@ void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractSta
QAbstractState *currentErrorState = findErrorState(currentContext);
// Avoid infinite loop if the error state itself has an error
- if (currentContext == currentErrorState) {
- Q_ASSERT(currentContext != initialErrorStateForRoot); // RootErrorState is broken
- currentErrorState = initialErrorStateForRoot;
- }
+ if (currentContext == currentErrorState)
+ currentErrorState = 0;
- Q_ASSERT(currentErrorState != 0);
Q_ASSERT(currentErrorState != rootState);
-
- QState *lca = findLCA(QList<QAbstractState*>() << currentErrorState << currentContext);
- addStatesToEnter(currentErrorState, lca, pendingErrorStates, pendingErrorStatesForDefaultEntry);
+
+ if (currentErrorState != 0) {
+ QState *lca = findLCA(QList<QAbstractState*>() << currentErrorState << currentContext);
+ addStatesToEnter(currentErrorState, lca, pendingErrorStates, pendingErrorStatesForDefaultEntry);
+ } else {
+ qWarning("Unrecoverable error detected in running state machine: %s",
+ qPrintable(errorString));
+ q->stop();
+ }
}
#ifndef QT_NO_ANIMATION
@@ -1148,9 +1146,6 @@ void QStateMachinePrivate::_q_start()
return;
}
QAbstractState *initial = rootState->initialState();
- if (initial == 0)
- setError(QStateMachine::NoInitialStateError, rootState);
-
configuration.clear();
qDeleteAll(internalEventQueue);
internalEventQueue.clear();
@@ -1316,11 +1311,15 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio
QByteArray signal = QSignalTransitionPrivate::get(transition)->signal;
if (signal.startsWith('0'+QSIGNAL_CODE))
signal.remove(0, 1);
- int signalIndex = sender->metaObject()->indexOfSignal(signal);
+ const QMetaObject *meta = sender->metaObject();
+ int signalIndex = meta->indexOfSignal(signal);
if (signalIndex == -1) {
- qWarning("QSignalTransition: no such signal: %s::%s",
- sender->metaObject()->className(), signal.constData());
- return;
+ signalIndex = meta->indexOfSignal(QMetaObject::normalizedSignature(signal));
+ if (signalIndex == -1) {
+ qWarning("QSignalTransition: no such signal: %s::%s",
+ meta->className(), signal.constData());
+ return;
+ }
}
QVector<int> &connectedSignalIndexes = connections[sender];
if (connectedSignalIndexes.size() <= signalIndex)
@@ -1479,27 +1478,6 @@ QStateMachine::~QStateMachine()
namespace {
-class RootErrorState : public QAbstractState
-{
-public:
- RootErrorState(QState *parent)
- : QAbstractState(parent)
- {
- setObjectName(QString::fromLatin1("DefaultErrorState"));
- }
-
- void onEntry(QEvent *)
- {
- QAbstractStatePrivate *d = QAbstractStatePrivate::get(this);
- QStateMachine *machine = d->machine();
-
- qWarning("Unrecoverable error detected in running state machine: %s",
- qPrintable(machine->errorString()));
- }
-
- void onExit(QEvent *) {}
-};
-
class RootState : public QState
{
public:
@@ -1522,9 +1500,7 @@ QState *QStateMachine::rootState() const
Q_D(const QStateMachine);
if (!d->rootState) {
const_cast<QStateMachinePrivate*>(d)->rootState = new RootState(0);
- const_cast<QStateMachinePrivate*>(d)->initialErrorStateForRoot = new RootErrorState(d->rootState);
d->rootState->setParent(const_cast<QStateMachine*>(this));
- d->rootState->setErrorState(d->initialErrorStateForRoot);
}
return d->rootState;
}
@@ -1548,17 +1524,13 @@ QAbstractState *QStateMachine::errorState() const
If the erroneous state has an error state set, this will be entered by the machine. If no error
state has been set, the state machine will search the parent hierarchy recursively for an
error state. The error state of the root state can thus be seen as a global error state that
- applies for the states for which a more specific error state has not been set.
+ applies for all states for which a more specific error state has not been set.
Before entering the error state, the state machine will set the error code returned by error() and
- error message returned by errorString().
-
- The default error state will print a warning to the console containing the information returned by
- errorString(). By setting a new error state on either the state machine itself, or on specific
- states, you can fine tune error handling in the state machine.
+ error message returned by errorString().
- If the root state's error state is set to 0, or if the error state selected by the machine itself
- contains an error, the default error state will be used.
+ If there is no error state available for the erroneous state, the state machine will print a
+ warning message on the console and stop executing.
\sa QState::setErrorState(), rootState()
*/
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index f3c6a27..1335b93 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -175,7 +175,6 @@ public:
QString errorString;
QSet<QAbstractState *> pendingErrorStates;
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry;
- QAbstractState *initialErrorStateForRoot;
#ifndef QT_NO_ANIMATION
bool animationsEnabled;
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/qstring.cpp b/src/corelib/tools/qstring.cpp
index dba3d2a..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, enum Qt::Uninitialized)
+QString::QString(int size, Qt::Initialization)
{
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
d->ref = 1;
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 67716b8..6bb0d8e 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -579,7 +579,7 @@ public:
bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; }
bool isRightToLeft() const { if (!d->clean) updateProperties(); return d->righttoleft; }
- QString(int size, enum Qt::Uninitialized);
+ QString(int size, Qt::Initialization);
private:
#if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED)