Commit Graph

4310 Commits

Author SHA1 Message Date
João Abecasis
4c8a4058c3 Change meaning of offset in QByteArrayData
It used to be an index into the first element in 'd' that came after
'offset'. It is now the byte offset from the beginning of the
QByteArrayData structure.

By no longer using an actual array to access characters, we also steer
clear of GCC bug #43247:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247

This aligns this data structure with QArrayData. The intention is to
have QVector, QString and QByteArray share the same memory layout and
possibly code.

Change-Id: I8546e5f51cd2161ba09bd4ada174b7f5e6f09db7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-21 00:37:58 +01:00
João Abecasis
ebeebe2126 Have QVectorData::grow, take size of header w/ padding
This includes padding necessary to align the data array, but excludes the first
element as was done before. Size of header is the interesting piece of
information, anyway.

This simplifies calculations in a couple of places, harmonizes code with the
QRawVector fork and paves the way for further changes in QVector, namely the
memory layout.

When Q_ALIGNOF is not available, default to pointer-size alignment. This
should be honoured by malloc and won't trigger use of more expensive
aligned allocation.

Change-Id: I504022ac7595f69089cafd96e47a91b874d5771e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-20 17:52:27 +01:00
João Abecasis
ec5eb45cd3 Add header to .pri
Commit 7d16ea40 introduced QArrayDataPointer and respective header file, but
missed making it known to qmake.

Change-Id: I48c1831730cc4d27c6600c090a719861bb71a301
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-18 11:02:58 +01:00
João Abecasis
fd96115ae8 QVector: always grow exponentially
For non-movable types (QTypeInfo<T>::isStatic), QVector would grow the
array linearly, and defer to qAllocMore otherwise. That property,
however, gives no indication as to how the vector will grow.

By forcing additional allocations for growing containers of such types,
this penalized exactly those objects which are more expensive to move.

We now let qAllocMore reign in growth decisions.

Change-Id: I843a89dcdc21d09868c6b62a846a7e1e4548e399
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-02-17 21:23:20 +01:00
João Abecasis
fb8be9905d qAllocMore: Always grow exponentially
qAllocMore is used by growing containers to allocate additional memory
for future growth. The previous algorithm would grow linearly in
increments of 8 up to 64 and then progress exponentially in powers of
two.

The new (constant time) algorithm does away with the linear segment and
always progresses exponentially. It also has the nice benefit of cleanly
avoiding undefined behaviour that the old implementation tried hard to
circumvent.

Besides always progressing exponentially, the next-power-of-two
algorithm was tweaked to always include space for growth. Previously
queries at boundary values (powers of two) would return the same value.

The test was updated to verify sanity of results. As the algorithm is
well behaved, testing of bogus data was dropped. Whatever happens in
those cases is irrelevant, anyway: the bug lives elsewhere.

Change-Id: I4def473cce4b438734887084e3c3bd8da0ff466b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-02-17 21:23:06 +01:00
João Abecasis
5d593da3d3 Remove constructors taking implicit string sizes
Constructors taking explicit sizes got a default -1 size argument that
triggers length calculation from nul-terminated strings.

This imposes a slight change in behavior: negative size arguments would
previously be ignored and generate an empty string whereas with this
patch we expect to see a nul-terminated string.

On the other hand, keeping the previous behavior could effectively hide
errors in user code and I can't find a good reason to support it.

Documentation for the constructors was updated and made more consistent
between the classes.

Change-Id: I738ac3298cffe3221c8a56e85ba2102623e7b67d
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-02-14 15:25:37 +01:00
João Abecasis
75286739de Fix and simplify QString::mid
'position' was being used to initialize 'n' before being fully
validated. To compensate for this, the code attempted to fix 'n' once
'position' was found to be invalid (negative). This would, however, also
attempt to "fix" a perfectly valid value of 'n'.

By fully validating 'position' beforehand we avoid this trap and can
safely use it to validate and reset 'n', as needed.

Arithmetic for boundary conditions of 'n' was rearranged to avoid
triggering integer overflow.

Removed explicit check for shared_null, as the same behaviour can be
supported without it.

Change-Id: Ie9bff7b8137a74f55c7dcfe629bd569045e28f3c
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2012-02-14 12:50:14 +01:00
João Abecasis
f9872d12a6 Add support for rvalue-references in QArrayDataPointer
I love how this magically makes SimpleVector move-aware :-)

Change-Id: I5cb75954d70cf256863c33e684ebc4551ac94f87
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2012-02-13 10:40:21 +01:00
João Abecasis
113e921684 Don't expect null d-pointer in destructors
The feature was introduced in commit 83497587b2 (2004, private history),
to allow static containers to remain uninitialized until needed.

This finishes reverting said commit. The feature had been silently
removed from QByteArray and QString in commit a5a0985476 (2004, private
history); removed from QList in aef03d80f7.

Change-Id: I9947be7758d5730d2d6e6eb2a8a308db6e9bef39
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-02-13 10:40:03 +01:00
João Abecasis
a2abc11b51 Make QStringBuilder use memcpy for QByteArrayLiteral
There is no need to do a bytewise copy looking for the terminating
nul-character when the size of the data is statically declared and known
ahead of time.

Change-Id: I787745a58955d1a366624f9ea92e9e701de8c981
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-07 01:20:46 +01:00
João Abecasis
a78bcea586 Remove use of QT_MODULE from QArrayData stack
The macro was made empty in 4ecf82795d,
and is no longer necessary or used.

Change-Id: If000ff51729e41bdcd1b0409961cf94d50e5f172
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-06 17:34:31 +01:00
João Abecasis
475280d5fd Update license headers
- Updated copyright year, per 1fdfc2abfe
- Updated contact information, 629d6eda5c
- Drop "All rights reserved", 5635823e17

(Empty line added to maintain license header line count)

Change-Id: Ie401e2b6e40a4b79f4191377dd50dc60be801e1f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-06 17:34:29 +01:00
João Abecasis
b5148f5991 QConstStringData -> QStaticStringData
The class was renamed in fed603fde5.

Change-Id: I859f318e80a739f31c2666d0e3088c62b55c5f13
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-06 17:34:27 +01:00
João Abecasis
d065dfd454 Merge remote-tracking branch 'gerrit/master' into containers
Conflicts:
	src/corelib/tools/qstring.cpp

Change-Id: I23d214bf33c2badfae1876da3cc7d6d8f6e635fb
2012-02-05 21:26:33 +01:00
Friedemann Kleint
9f54846d95 qmake: Work around MSVC compiler bug.
Disable optimization for getProjectUUID() as it triggers
ASSERT: "&other != this" at qstring.h:720 with -O2.

Change-Id: I51b31d4318ba9be187c186623099171d8f48235b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-05 19:03:18 +01:00
Mark Brand
60f24ec608 reduce cost of checking cache for data() and headerData()
Assume requested row is usually not cached.

Change-Id: I7727b431cc3841528aa6390400b93b1218773e65
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
2012-02-05 17:50:44 +01:00
Mark Brand
e5c8927fe8 QSqlTableModel::setData(): comment historical idiosyncracies
Change-Id: I5c4782e18dc7a471dc294a4146db04f1efd3ed2e
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
2012-02-05 17:50:39 +01:00
Mark Brand
f6e3f24683 refactor QSqlTableModel::setData()
-move logic out of switch statement
-clear cache more clearly for OnFieldChange
-call setValue() in one place instead of two
-eliminate extra return path

Existing idiosyncracies have been kept for the time
being.

Change-Id: Ia4c5a5fd3e374b53e3c4d870f2ee9d37b5090917
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
2012-02-05 17:50:35 +01:00
Mark Brand
11bd543d90 refactor QSqlTableModel::setRecord()
-Do not use setData()
We're using ModifiedRow now so it makes sense to buffer the changes
and submit the row at once. This improves readability and
encourages further haromonization of the editing strategies.

-No longer need temporary change to OnRowChange
Previously, the strategy was temporarily changed from OnFieldChange
to OnRowChange in order to obtain the desired behavior from setData().
Now, since we don't use setData(), we can program the desired behavior
here and don't need this trick.

-Comment historical idiosyncracies/bugs

Change-Id: I6d9e2a69e1571a74c630ad1392e15b60fc0ad3f2
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
2012-02-05 17:50:30 +01:00
Mark Brand
ccaa6734f1 merge private and public QSqlTableModel::setRecord()
Change-Id: I409bd32f85224db64363688d63fc372d1beaa0d3
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
2012-02-05 17:50:26 +01:00
Mark Brand
48c68b0546 ModifiedRow: use for all edit strategies
Previously ModifiedRow was used only for OnManualSubmit and
a seperate buffer and utility methods were used for OnFieldChange
and OnRowChange.

Also, initialization of the edit buffer is done by ModifiedRow
instead of a helper function.

Change-Id: I3316498e5bb10c416138ca14c3a7f8b143c8e544
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
2012-02-05 17:50:21 +01:00
John Layt
23457bd6d9 SIC: QLocale: Make QSystemLocale a private class
As discussed on list and approved by Lars and Thiago.

Make QSystemLocale private to give us time and space to change it to a
better implementation.

Change-Id: Ifd806972f3996c43a876f544f78c6557ad71cd75
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-02-05 17:50:04 +01:00
John Layt
29c4a27a94 SIC: QLocale: Remove base argument from conversion to number api
As discussed on list and approved by Lars and Thiago.

Remove the option to use QLocale to convert strings to non-decimal
numbers as they are not localised and the api is available in QString.

Change-Id: Ib810505ba86fb08ad23571b39f1520e86fde6787
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-05 17:49:56 +01:00
John Layt
1e3833bed8 QString: Make convert to number methods only use C locale
Ensure consistent conversions by not using the system default locale.

Change-Id: I60db9fc4f465c0254f3213419e57d7879aaddd65
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-02-05 17:49:42 +01:00
Lars Knoll
96501b0a18 Move QtConcurrent into its own module
Task-number: QTBUG-20892

Change-Id: I614500aafb6428915509983608bbb0ade4e4f016
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-05 17:49:16 +01:00
Samuli Piippo
c8156cab81 Exclude helloconcurrent when QtConcurrent is not configured
Task-number: QTBUG-23874
Change-Id: I374a08ce947e804ebb1da08c413e340e4719d9d0
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-02-05 17:49:10 +01:00
Jędrzej Nowacki
92b1124752 Add movability tests for QByteArray.
QByteArray is declared as movable but it was not tested before.

Change-Id: I4fb636f8705c3fd792a768872206203ee5fd4ddb
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2012-02-05 13:07:56 +01:00
Jędrzej Nowacki
c9319f17f4 Do not crash trying to load or save QModelIndex.
QModelIndex doesn't have data stream operators loading or saving this
type should gracefully fail.

Change-Id: I6a1a3bab3f83ff4921369a07fdb54ac462eff554
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-02-05 13:06:02 +01:00
Jędrzej Nowacki
d97fd99270 Reimplement QMetaType::destroy.
New implementation is using QMetaTypeSwitcher, which should reduce
maintenance costs.

Change-Id: Ibb7bb4b9de0e19c081c087d9eebf0c709118d3b4
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2012-02-05 12:33:30 +01:00
Nick Ratelle
72c0731122 Fixes QIconvCodec::convertToUnicode()
We need to hang onto the internal state of the utf16 converter
object whenever converting a long string to unicode. This was
failing with the text stream class -- the first read was okay,
but subsequent reads could not be correctly converted to unicode.

Change-Id: I9e2d445d51c9009591bfa7a1765ea2d09ae634a2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-02-05 10:07:48 +01:00
John Layt
fc24979e43 QDateTime: Remove Julian Calendar
Convert QDate to only use Gregorian calendar and not Julian calendar
before 1582.  In future the Julian can be used via proper calendar
classes.

Change-Id: I547a3550332057a0ab1be616706630b6afaceffc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-05 00:26:07 +01:00
John Layt
8327fa7c11 QDateTime: Store Julian Day as qint64
Store the QDate Julian Day number as an qint64 instead of uint32 to
enable support for dates before 2 January 4713 BCE.  This changes the
possible date range to be approx 2.5 Quadrillion BC to 2.5 Quadrillion
AD. A qint32 was not used as it only covers 5 million BCE to 5 million
CE which does include Geological or Astronomical time.

The effective supported date range is currently 4800 BCE to 1.4 million
CE due to restrictions in existing conversion formulas.  The effective
range will be extended later with new formulas.

Change-Id: Ib4345369455b31d4edae8c933b7721e76414e914
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-05 00:26:07 +01:00
Bradley T. Hughes
31b4c5aa05 Use $CFG_ARCH even if src/corelib/arch/$CFG_ARCH does not exist
Recent commits in src/corelib/arch have removed empty directories,
which cause configure to assume that the architecture is not supported.
This assumption is wrong, due to changes in
src/corelib/thread/qbasicatomic.h to include the correct QAtomic*
implementation based on compiler pre-defined macros instead of the
architecture found by configure.

Change-Id: I026958fb9af8af62e295e68a4643c37ac9395dc6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-02-04 22:40:06 +01:00
Friedemann Kleint
3f75fb8d8f MinGW: Fix warnings.
- Special #define to access HB seems no longer necessary
  (it was causing about mismatching DLL import attributes).

Change-Id: I57cc7d57b12a67c1d549b053db81e1f198f87786
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
2012-02-04 08:43:38 +01:00
Simon Hausmann
19f4b47b45 Improve sysroot handling with regards to configure tests.
Some configure tests try to link programs, which when compiling against
a sysroot _does_ require the --sysroot= argument in order to find crt0.o.

This patch uses the existing pattern of using the export SYSROOT_FLAG
in the missing linking tests.

Change-Id: I063849c814f393d5f88de1b486ce9035b9f7bf65
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-02-03 18:59:09 +01:00
Kent Hansen
b184dd0a01 Bring qmetaobjectbuilder in sync with moc
qmetaobjectbuilder should generate meta-objects of the same version
as moc; in the future, when the moc version is bumped, QMOB has to
be adapted at the same time.

QMOB was generating version 4 meta-objects. This patch makes it
generate version 6 (the current version). This also fixes a bug with
using qt_static_metacall with QMOB (setStaticMetacallFunction()); it
was already using the version 6 qt_static_metacall signature, which
isn't compatible with version 4.

Also add tests that ensure that the QMOB-generated meta-object works
with real objects; in particular we want to test the codepaths in Qt
that check for version >= 4.

Change-Id: I64a151ea5c947a6f8b7a00e85a39866446c735e9
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2012-02-03 15:09:03 +01:00
Kent Hansen
8bbb00e44e Adapt QtDBus to QVariant property type change
Commit 00c8984b4e changed other parts
of Qt to use QMetaType::QVariant, not 0xff, as the type for QVariant
properties. QtDBus should check for that type, and also use it for
QDBusVariant properties.

Change-Id: I21d81b59754ae44889766877a4c5066466b46d86
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Kent Hansen
4ec2b37542 Bring QtDBus meta-object generator in sync with moc
QtDBus's meta-object generator should generate objects of the same
version as moc; in the future, when the moc version is bumped,
QtDBus's meta-object generator has to be adapted at the same time.

Since QMetaObjectPrivate and related flags reside in qmetaobject_p.h,
QtDBus can just include the header instead of duplicating code.
qmetaobject_p.h also defines the meta-object revision QtDBus should
be targeting.

QtDBus was generating version 3 meta-objects. This patch makes it
generate version 6 (the current version). Since a new field was
added to QMetaObjectPrivate in revision 4 (signalCount), the
generator had to be adapted. In particular, the signal definitions
need to come before other methods (as they do with moc), since
there are functions in QObject that rely on that (e.g.
computeOffsets()).

Change-Id: I37f102d8c1be372ef6cfaf013baa87f9abb0fd5e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Friedemann Kleint
5117f55063 Fix compilation on MinGW.
- Add missing constant.
- Make FontKey a pair instead of a function-local type which
  cannot be used as template parameter for gcc.
- Fix warnings about redefinition of NOMINMAX and enumeration.

Change-Id: Ie3eb6e5b8dd9cd81210d6e10270ada0158aaf809
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
2012-02-03 15:09:03 +01:00
Andy Shaw
5bab4744ba Handle the 'real' datatype correctly in the SQLite driver
The 'real' datatype should be seen as a QVariant::Double type and not as
a QVariant::String type otherwise it does not get presented correctly
when using a non Qt application to access it.

Test is included for QSqlQuery.

Task-number: QTBUG-16373

Change-Id: Ie323ce49eb95e4d6bb4c3814ba9a957a63f4b259
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
(cherry picked from commit b23631015c23a49e3b4d296ea0a6266bfce3d4f1)
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
2012-02-03 15:09:03 +01:00
Jędrzej Nowacki
1175ec444f Fix a typo TypeDefiniton -> TypeDefinition.
If you repeat a typo often enough, it becomes the right spelling.
But 49 times is definitely not enough :-)

Change-Id: I7c0bb29e68e4bff5c67277f9874df8b3ab8b2b54
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
4916510b01 Include qatomic_cxx11.h for C++11 compilers
qatomic_cxx0x.h doesn't exist.

Change-Id: Iac654ecf09a1b890d25fa23625c8c43f2f7f1ecf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
96809e36b2 Remove empty src/corelib/arch subdirectories
The bfin, integrity, s390, and sh4a directories included an empty
arch.pri, which is not necessary. Remove these directories and arch.pri
files.

Change-Id: I016dcef63e4b9fb4c14cc1fa7b9b91cba2080dbb
Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
12e43d7efa Remove src/corelib/arch/nacl/* and qatomic_nacl.h
This implementation uses the GCC __sync_* intrinsics, which we do not
need to duplicate after commit 2bbd2262b3
(which added qatomic_gcc.h).

Change-Id: I59b6e4a03e83f58f4145a5ab2bfd635fe9ab686f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
7142e689e0 Remove src/corelib/arch/ia64/*
The out-of-line q_atomic_test_and_set_(int|ptr) functions are no longer
declared after commit 1955353149. They
appear to have never been used either. Remove them.

Change-Id: Ia8dfa1f585f2370091b4fd93aaf98cb10241bf31
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
0797676329 Remove src/corelib/arch/i386/* and src/corelib/arch/x86_64/*
We do not want to support out-of-line QAtomic* implementations. Remove
these from the i386 and x86_64 implementations.

Change-Id: Ib6a9614b7b11bf6bccc9054b177357afd83e33e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
67729d05d0 Remove src/corelib/arch/avr32/* and qatomic_avr32.h
This implementation uses the GCC __sync_* intrinsics, which we do not
need to duplicate after commit 2bbd2262b3
(which added qatomic_gcc.h).

Change-Id: I2cab86deacad1c37f17f0c5836d9faf2ad366495
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
7b82034600 Remove src/corelib/arch/mips/*
Commit 99fb1bea49 removed the use of the
old, out-of-line q_atomic_* implementation. Remove these functions from
the library.

Change-Id: I0b239bf779e0545cb5558862e3a40f6e95fdcbd9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
c116206ccd Remove src/corelib/arch/arm/*
After commit dc5388e79b, which removed
support for non-EABI, qt_atomic_yield() and q_atomic_lock are no
longer used. Remove them.

Change-Id: I0f405ae63d7903c222fc2b829887207885be0a03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00
Bradley T. Hughes
214894da16 Remove #include "qatomic_macosx.h"
This file was removed in commit 68e5fd9ebc

Change-Id: I76671f79432204c28ffa7488871d0eef07cc8dca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-02-03 15:09:03 +01:00