Commit Graph

7378 Commits

Author SHA1 Message Date
Thiago Macieira
62013d7772 Mark to remove const from function parameters in QtCore public headers
Some compilers are known to complain about this with a warning. GCC
complains about const on return values on -Wignored-qualifiers (enabled
at -Wextra), so it's not too much of a jump to assume that others do
too. Besides, this is not Qt Library API policy. As maintainer for
QtCore, I'm exercising my prerrogative in specifying certain unspecified
parts of the coding style, like I've done for constructor initializer
lists.

Since all the classes involved are exported (including QVector, through
derived classes), we can't remove the qualifier until Qt 6, since there
are compilers known to encode the qualifier in the mangled name
(suncc). I'm not introducing #ifdef to silence unknown compilers unless
we get an actual complaint.

Change-Id: I33850dcdb2ce4a47878efffd14a876edef843c46
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 21:08:14 +00:00
Giuseppe D'Angelo
88a8feeacb QCryptographicHash: make SHA3 calculate SHA3, not Keccak
The SHA3 family is a modified version of Keccak. We were
incorrectly calculating Keccak (and even *testing* Keccak!),
but claiming it was SHA3.

To actually calculate SHA3, we need invoke Keccak on the original
message followed by the two bits sequence 0b01, cf. §6.1 [1].

[1] http://dx.doi.org/10.6028/NIST.FIPS.202

[ChangeLog][QtCore][QCryptographicHash] QCryptographicHash now
properly calculates SHA3 message digests. Before, when asked
to calculate a SHA3 digest, it calculated a Keccak digest instead.

Task-number: QTBUG-59770
Change-Id: Iae694d1a1668aa676922e3e00a292cddc30d3e0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 07:58:35 +00:00
Giuseppe D'Angelo
cd9e850f9e QCryptographicHash: fix documentation of the supported algorithms
Change-Id: Idfa7843ef8a8e3410ae0a8cf5311b8b598299730
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 07:57:55 +00:00
Marc Mutz
df43ef7b6d QStringBuilder: simplify QConcatenable<char[N]>
... by delegating to QConcatenable<const char[N]>.

The only thing that varied was the nested type alias 'type', which
therefore got retained.

Change-Id: I202f899034e1ddd23c6d1978a31be5eb7c195697
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 07:11:13 +00:00
Anton Kudryavtsev
5ec57560c0 Prefer rvalue versions of toLatin() and toUtf8()
... to re-use existing buffers.

Change-Id: I7c42529b8cd4400520a59e658ab76f4f8e965cd4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-30 20:31:59 +00:00
Anton Kudryavtsev
f901afaf49 Use QStringBuilder more
Change-Id: If5283e364e921d99ffa7a8fa1abb07356a4a2682
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-30 04:28:09 +00:00
Anton Kudryavtsev
ff259bffe6 Use case-insensitive compare more
... to avoid allocations.

Change-Id: I5993633d1509495ff6ce3a11274a53504aac7c5e
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-29 03:54:57 +00:00
Kai Koehne
3c66df6400 Core: Replace LGPL21 with LGPL license header
Also use canonical contact url.

Change-Id: I43f8c6a2c4949ee0e054045bccc17d82575b072c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2017-03-28 12:47:55 +00:00
Anton Kudryavtsev
18d6c82299 Prefer rvalue versions of toLower() and toUpper()
... to re-use existing buffers.

Change-Id: Ib2bc938f1cf0451c1dbc012b3db022b878e987cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-28 07:18:26 +00:00
Anton Kudryavtsev
ed96363d56 QMimeGlobPattern: init all members only once
... by initializer list.

Change-Id: I39d2f933dac171273f500963eb47ffa9165978de
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-28 04:01:41 +00:00
Tor Arne Vestbø
e0e717d06a Fix crash when QUrl::from{NS/CF}URL() was passed a nullptr
Change-Id: Ib193447c4a91dd3d08746e97727f7d4764f33d80
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-27 17:39:58 +00:00
Liang Qi
d5df0e9949 Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9 2017-03-27 09:21:47 +00:00
Liang Qi
7702fe8602 Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: Icdd71e9713725bda9c305e338f5c8b41a92ed8e8
2017-03-27 10:42:08 +02:00
Shawn Rutledge
1e7795ef60 Add documentation for TabletTrackingChange enum value
Amends 6aaf853222

Change-Id: I2c264db235ea552ce6b4eb003d7daeeb2cecde6f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2017-03-27 08:32:56 +00:00
Kimmo Ollila
1dd54b5647 Increase the maximum recursive template depth on INTEGRITY
Set the limit to 128 instead of the default 64 by adding
QMAKE_CXXFLAGS += --pending_instantiations=128. This is
needed by QMetaType::typeName array implementation.

Change-Id: I3fd13967f862f492210572cfe7ee9ffc5e7c9745
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-25 15:45:58 +00:00
Marius Kittler
38550c562d json encoder: Harmonize number serialization with ES6
Ensures that numbers representable as 64-bit integer
are not printed using exponent notation.

Some JSON implementations such as the one of the Go
standard library expect this in the default
conversion to int.

Change-Id: Ic3ac718b7fd36462b4fcabbfb100a528a87798c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-25 14:26:30 +00:00
Marc Mutz
d8e2db0173 QDir: replace QLVA<QChar> with QVLA<ushort>
... as used in qstring.cpp, too. QChar is only marked as movable, not
primitive, as it should have been and ushort is, and there's some hope
that the template instantiations can be shared across TUs.

Saves a rather disappointing 148B in text size on optimized GCC 7
Linux AMD64 builds.

Change-Id: Ic9558a4d83611a6461cd5540c9090cbd4c4f2f4e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-25 08:03:10 +00:00
Marc Mutz
5ca7d56aca QVarLengthArray: fix compilation with GCC 7
This fixes a warning-turned-Werror in qdistancefield.cpp:

  In member function ‘void QVarLengthArray<T, Prealloc>::realloc(int, int) [with T = bool; int Prealloc = 256]’,
      inlined from ‘void makeDistanceField(QDistanceFieldData*, const QPainterPath&, int, int)’ at ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:275:10:
  ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:390:19: error: ‘void* memcpy(void*, const void*, size_t)’: specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
               memcpy(ptr, oldPtr, copySize * sizeof(T));
               ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Apparently GCC cannot rule out that copySize may be negative in the
call to memcpy. Put GCC on the right track by adding a Q_ASSUME.

Change-Id: I63e3801e52ebe2a7f77e3a97ef03ec3869319c8c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-03-25 08:02:31 +00:00
Thiago Macieira
e19fda916a Fix some warnings found by QNX's compiler
-Werror is now disabled for that compiler, but it doesn't hurt to fix.

io/qstandardpaths_unix.cpp:149:32: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
qtestcase.cpp:2330:31: error: narrowing conversion of '(ms / 1000)' from 'int' to '_Timet {aka unsigned int}' inside { } [-Werror=narrowing]

Change-Id: Id92f4a61915b49ddaee6fffd14aea2c1e686e8f2
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2017-03-25 04:51:01 +00:00
Edward Welbourne
e5c0371d18 Fix propagation of locale from widget to its children
Fix the condition in QWidgetPrivate::resolveLocale() to decide whether
to propagate locale: make it match setLocale_helper()'s condition when
deciding whether to propagate to descendants.  This lead to a
QDateTimeEdit's calendar popup not getting told what locale to use
correctly, unless we setLocale() on it overtly, which then blocked
propagation of locale changes to it unless QDateTimeEdit manually
propagated the changes.

Fix the documentation of WA_WindowPropagation to mention locale as
also being propagated (which it was in several places, only neglecting
this one in resolveLocale).

[ChangeLog][QWidget][Qt::WA_WindowPropagation] Propagate locale
consistently, along with font and palette, within the widget
hierarchy.  Previously, locale was propagated on ancestral
setLocale(), but not on creation of the descendant.

Task-number: QTBUG-59106
Change-Id: I92270f7789c8eda66a458274a658c84c7b0df754
Reviewed-by: David Faure <david.faure@kdab.com>
2017-03-24 13:57:22 +00:00
Thiago Macieira
9021a748af QStorageInfo: Fix warning about unused variable
Happens on non-Linux, non-macOS Unix systems (got it on FreeBSD).

Change-Id: Ie67d35dff21147e99ad9fffd14acc7308b5ff17e
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-03-23 22:15:27 +00:00
Liang Qi
65faf45655 Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/plugins/platforms/eglfs/eglfs-plugin.pro

Change-Id: Id76cdbb41b7758572a3b8ea4dcb40d49bac968db
2017-03-21 19:07:53 +01:00
Thiago Macieira
99fc96fd37 QMetaType & QVariant: "load" and "save" std::nullptr_t
We don't load and save pointers usually because the pointer value cannot
be guaranteed to remain across program invocations. However, nullptr is
an exception: a null pointer is always a null pointer.

We don't actually have to read or write anything: there's only one value
possible for a std::nullptr_t and it is nullptr.

[ChangeLog][Important Behavior Changes] A QVariant containing a
std::nullptr_t is now streamable to/from QDataStream.

Task-number: QTBUG-59391
Change-Id: Iae839f6a131a4f0784bffffd14aa374f6475d283
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-20 21:53:32 +00:00
Thiago Macieira
202d6ad730 QHash: unexport the hash seed variable
The only allowed way to access the variable is now via the public
qGlobalQHashSeed and qSetGlobalQHashSeed functions. The variable was
private API, so we're allowed to remove it.

Task-number: QTBUG-47566
Change-Id: I4a7dc1fe14154695b968fffd14abd331e5810482
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-03-20 20:07:59 +00:00
David Faure
035e0eafa6 QUrl::fromUserInput: fix handling of files with a ':' in the name
QUrl::isRelative(str) would be false for such files, so first check for
file existence before doing any URL parsing.

Change-Id: I51b6229251ad94877ac408b2f8018456d3e10a36
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-20 12:55:36 +00:00
Anton Kudryavtsev
4a97e3b98a QMap, QHash: make key_iterator satisfy the DefaultConstructible concept
Change-Id: Ifc3f481ddb902b26c217516412c93a4a39a32b1c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-20 04:36:42 +00:00
Anton Kudryavtsev
949bce97d0 QString: de-deplicate code of leftRef, rightRef, midRef
Re-use methods of QStringRef.

Change-Id: I5ff719c08c54246e9cafd4f9aa0823ff6df8433b
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-18 06:51:24 +00:00
Marc Mutz
5c724a6087 QChar: fix ambiguous comparisons with 0, '\0', ... for good
Commit e0ea0f6178 optimized QChar <->
QString(Ref) comparisons by adding more overloads to avoid creating
QStrings from QChars just to compare them.

But these new overloads made existing comparisons to QChar ambiguous.
This was known at the time for QChar/int comparisons.

It has since turned out that also comparing to '\0' is ambiguous,
ie. not comparing to int or char per se is ambiguous, but comparing to
nullptr constants is, because QString(const char*) is just as good a
candidate as QChar(char)/QChar(int).

Since we allow QString/QChar comparisons, it seems logical to solve
the problem by adding QChar<->nullptr overloads.

[ChangeLog][QtCore][QChar] Disambiguated comparisons with nullptr
constants such as '\0', which 5.8.0 broke. As a consequence,
QChar<->int comparisons are no longer deprecated, as this was a failed
attempt at fixing the ambiguity.

Change-Id: I680dd509c2286e96894e13078899dbe3b2dd83bc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-17 20:28:32 +00:00
Thiago Macieira
4ee7425794 Work around Linux libc overflow in mmap64
The mmap64 functions in all Linux libc fail to properly check that the
value fits in the system call parameter. I guess the developers just
said "16 PB are enough for everyone"...

Change-Id: Ic39b2c4fd9c84522a8fafffd14ac91567ce09c09
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-03-17 20:24:57 +00:00
Thiago Macieira
cdaea16964 Protect better against timer ID replacement
Timer IDs have been reused since Qt 4.5 or thereabouts, so just checking
if the timer ID is in the timer dictionary is an incorrect check: our
timer may have been deleted and replaced by another with the same ID.

Instead of deleting the WinTimerInfo object, let's just mark it as
unregistered by setting timerId to -1 and cooperate in deleting at the
appropriate places. Since unregisterTimer skips deleting if inTimerEvent
is true, the appropriate places are everywhere that set inTimerEvent to
true.

Change-Id: I057e93314e41372ae7a5ff93c467767c8a6d92ea
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-03-17 20:24:04 +00:00
Jesus Fernandez
346cd79192 Make QFile::open fail when using an invalid file name
Fixes the bug in QFile which allowed opening a file with reserved
characters in its name.  If the name is a long file path, CreateFile
opens a file with a truncated name instead of failing, so we have
to catch reserved characters ourselves.

[ChangeLog][Windows] Fixed a bug that caused QFile to create
files with truncated names if the file name was invalid. Now,
QFile::open correctly fails to create such files.

Task-number: QTBUG-57023
Change-Id: I01d5a7132054cecdfa839d0b8de06460039248a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-17 11:06:43 +00:00
Marc Mutz
e364384d9f QChar: fix docs of (uchar) ctor
The constructor is not only disabled under QT_NO_CAST_FROM_ASCII,
but also under QT_RESTRICTED_CAST_FROM_ASCII.

Change-Id: I7bbaf2891913d5256dff7f80c49075ea3326155a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-16 07:53:25 +00:00
Marc Mutz
e83247a2b9 Do not assume QStringRef(const QString*) to be implicit
It won't be for very much longer.

Change-Id: I30e3e0cd8c8ecf0833f759557382a3ded7bdea34
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-14 05:42:08 +00:00
Liang Qi
77e71dac16 Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9 2017-03-13 19:45:20 +00:00
Liang Qi
d51c3ecf8e Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	examples/network/network.pro
	mkspecs/features/mac/default_post.prf
	src/corelib/io/qfilesystemengine_win.cpp
	src/corelib/io/qprocess.cpp
	src/corelib/io/qprocess.h
	src/corelib/io/qprocess_p.h
	src/corelib/io/qprocess_unix.cpp
	src/corelib/io/qprocess_win.cpp
	src/corelib/thread/qmutex.cpp
	src/platformsupport/fontdatabases/windows/windows.pri
	src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
	tests/auto/corelib/io/io.pro

Change-Id: I8a27e0e141454818bba9c433200a4e84a88d147e
2017-03-13 15:55:44 +01:00
Olivier Goffart
16d1ddfc42 moc: Support signals that return movable-only type
By adding std::move where it makes sense.
This is not only good for move-only types, but for any type which
can be moved as it saves copies of the return value in any case.

[ChangeLog][moc] Move-only types are now supported as return types
of signals and slots.

Change-Id: Idc9453af993e7574a6bddd4a87210eddd3da48a9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-13 11:03:47 +00:00
Ulf Hermann
2f10a6f04e Suppress -Wfloat-equal when defining float16 equality operators
Change-Id: Ie30fa13eb5f8eb44f0c9c21e9483c8aba40cec02
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-13 11:00:27 +00:00
Sze Howe Koh
d8a123841c Doc: Add links to the signal-slot syntaxes page
Change-Id: I5443a09d18ada6de16a5cec503523b7cc284b0dc
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-03-13 09:34:58 +00:00
Marc Mutz
75f5e2bef2 Deprecate QString::null
It's a Qt 3 compatibility vehicle, and as such inherits the now-alien
property to distinguish empty and null strings. Particularly worrisome
is the following asymmetry:

   QString("") == QString::null          // false
   QString("") == QString(QString::null) // true

Instead of fixing this behavior, recognize that people might use it as
a weird way to call isNull(), albeit one that once was idiomatic, and
simply deprecate everything that deals with QString::null.

[ChangeLog][QtCore][QString] QString::null is now deprecated. When
used to construct a QString, use QString() instead. When used to
compare to a QString, replace with QString::isNull().

Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2017-03-12 17:41:16 +00:00
Jake Petroules
c0da37a806 Fix QStandardPaths values on Apple Platforms containing URL encoding
This corrects an issue where the file system paths returned for some
QStandardPaths values on Apple Platforms would be URL encoded, for
example having %20 instead of an actual space character.

Task-number: QTBUG-59389
Change-Id: I771a44eb20b756842c324ac6fc9bdc475ce84826
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
2017-03-11 02:10:10 +00:00
Olivier Goffart
b52b509ae4 QLockFile: Don't deadlock if the lock file has a mtime in the future
Stale Lock files in the future can happen in some situations. For exemple
two computers with different clocks access the same file system. It could
be that one of the timestamp is totaly off (several years into the future).

[ChangeLog][QtCore][QLockFile] Fixed a deadlock occurring if a corrupted
lock file's modification time is in the future.

Change-Id: I8dac98a0e898c76bcef67f8c195e126c996b6add
Reviewed-by: David Faure <david.faure@kdab.com>
2017-03-10 17:09:24 +00:00
Marc Mutz
5cc0de2e08 QAtomic: pass explicit failure memory order to std::atomic::compare_exchange_strong
GCC 4.8 seems to get the failure memory order wrong when using the
overload that only accepts one memory order and produces errors such
as:

  bits/atomic_base.h:577:70: error: failure memory model cannot be stronger than success memory model for '__atomic_compare_exchange'
  return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, __m1, __m2);
                                                                      ^
(as seen on Android).

Fix by explicitly passing the failure orders corresponding to the
success orders, as specified by the standard:

 relaxed → relaxed
 release → relaxed
 acquire → acquire
 acq_rel → acquire

(cf. http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange).

Task-number: QTBUG-59399
Change-Id: If046e735888cf331d2d6506d8d5ca9aa7402f9ad
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-03-10 08:24:41 +00:00
Edward Welbourne
9ed389bf15 Bugfix in QDateTimeParser's findTextEntry()
If a later month-or-day were to have a name that's a prefix of an
earlier one's name, the code would have selected the longer name as
best match when the text matched is the shorter name, simply because
it found that one first.  (Found, on Turkish Cuma(rtesi)? in Thiago's
recent new test, by reversing the loop that iterated the list.)

Make an exact match win and a match of a full name beat any prefix
match of the same length.

Change-Id: I8d954b83ccc25e4f47af2e558036d714685cef5e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-09 19:27:13 +00:00
Edward Welbourne
326f1fdb7d Simplify QDateTimeParser's shiny new findTextEntry()
Decouple from the callers' offset into a larger list; just search for
an entry in a list, let the caller deal with the offset.  Also, defer
a .tolower() to save the need to allocate a copy of each list entry.

Change-Id: I748d5214c2cc6dc592fe2bd41e3f8150f71c335b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-09 19:27:06 +00:00
Thiago Macieira
ef26467eb2 Reintroduce a directed QMetaType::typeName array
Commit fb376e0fcc removed an array that
facilitated returning the names of built-in types, to avoid the jump tables
from the switch statement. This commit brings it back but makes the array a
compile-time constant string offset table.

The array is created by way of a set of C++11 constexpr functions, so we
require that compiler feature. I've tested that MSVC 2015 does support
it as well as the ICC 17 when masquerading as MSVC 2015, so I've enabled
for that too. The only compiler left out is MSVC 2013.

If we didn't need to support MSVC 2015, this could have been written
more simply with C++14 relaxed constexpr.

This also adds unit tests to confirm that QMetaType::typeName() does
return null when we said it would. We're testing QMetaType::User-1
(which we'll likely never use) and QMetaType::LastWidgetsType-1 to
select something inside the range of the built-in types.

Task-number: QTBUG-58851
Change-Id: I4139d5f93dcb4b429ae9fffd14a33982891e2ac1
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-09 14:56:35 +00:00
Thiago Macieira
7fd483f3de QDateTimeParser: Merge the code to parse names of months and weekdays
Simplifies everything and avoids bugfixes in one not propagating to the
other.

Change-Id: I95c9e502ccc74af3bcf0fffd14a69f0cde60cc8c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-08 16:44:54 +00:00
Kai Koehne
8d11df83d4 Document QT_DEPRECATED_WARNINGS
Task-number: QTBUG-58468
Change-Id: I0f822c2dd14878d70b74ddd2db89b11ba54f687b
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-03-08 09:45:09 +00:00
Thiago Macieira
e7295c959b Add -Wfloat-equal to Qt's header clean check
Task-number: QTBUG-57649
Change-Id: I15b62e0f9cec482fbb40fffd1490d802c54bf0fe
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-07 10:51:54 +00:00
Stephan Binner
00e6863552 Add feature.pushbutton
Change-Id: I654d91635e60b177df16f6dfe00acc940132f66a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-06 20:35:07 +00:00
Olivier Goffart
6797570a59 Fix UB in QFutureInterface: invalid casts from ResultStoreBase to ResultStore<>
ResultStore never actually exists, only ResutStoreBase does. So casting to
ResultStore<T> and calling its  member functions is UB. Put the type dependent
function as template member functions within ResultStoreBase and so we don't
need QtPrivate::ResultStore anymore.
Same goes for the iterator.

Change-Id: I739b9d234ba2238977863df77fde3a4471a9abd2
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-06 18:32:28 +00:00
Ulf Hermann
d6330a19b2 Use QT_CONFIG(library) instead of QT_NO_LIBRARY
For the windows file system engine, we add an extra macro to use
library loading if configured to do so, but avoid it on WinRT, as
none of the symbols would be found.

We also QT_REQUIRE_CONFIG(library) in the library headers and
exclude the sources from the build if library loading is disabled.
This, in turn, makes it necessary to clean up some header inclusions.

Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-03-06 11:27:20 +00:00
Edward Welbourne
a1c27748d2 Make QLocale consistent about special handling of the C locale
QLocale::matchingLocales() simply created each locale using the basic
data, without (unless the matching conditions stipulated Language C)
applying number-options hacks that it applies everywhere else, when
creating the C locale.  Thus the C locale in its returned list (if it
wasn't the only entry) ended up with the default number options,
without omiting separators in numbers.  Thus QLocale::c() didn't
actually appear as an entry in the list.  Discovered while
investigating QTBUG-58947.

Added a dumb autotest that checks various ways of getting the C locale
do actually give us equal locale objects.  Fixed matchingLocales() to
apply the same hack as is used elsewhere for the C locale.

Change-Id: I263f31da623052b63171f5b5a83c65802383df21
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-06 09:51:49 +00:00
Thiago Macieira
3a2f4bde14 QStaticByteArrayMatcher: enforce alignment
The data is 256 bytes, so might as well align it on a 16-byte boundary
to facilitate copying (if that happens). We should consider similar for
QByteArrayMatcher in 6.0.

Change-Id: I74966ed02f674a7295f8fffd14a8c64526d734bb
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-06 09:42:45 +00:00
Thiago Macieira
03b3f7a3af Make new QtCore code conform to the coding style
Change-Id: I74966ed02f674a7295f8fffd14a8c6389da538c1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-06 09:42:23 +00:00
Kai Koehne
4460b9c843 Replace outdated BSD license text
For examples and documentation, use new BSD license text that
includes the commercial licenses.

Change-Id: I1cd74bd8e9c8f2746d8702df00780ee100cbebac
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2017-03-03 07:26:11 +00:00
Stig Bjørlykke
62e6aa6195 QVector: Avoid implicit conversion warnings
This fixes compiling an application using QVector and -Wshorten-64-to-32
on a 64-bit system without getting this warning:

 ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:695:18:
 warning: implicit conversion loses integer precision: 'typename
 iterator_traits<QString *>::difference_type' (aka 'long') to 'int'
 [-Wshorten-64-to-32]
    int offset = std::distance(d->begin(), before);
        ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:731:35:
 warning: implicit conversion loses integer precision: 'long' to
 'const int' [-Wshorten-64-to-32]
    const int itemsToErase = aend - abegin;
              ~~~~~~~~~~~~   ~~~~~^~~~~~~~

 ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:740:39:
 warning: implicit conversion loses integer precision: 'long' to
 'const int' [-Wshorten-64-to-32]
    const int itemsUntouched = abegin - d->begin();
              ~~~~~~~~~~~~~~   ~~~~~~~^~~~~~~~~~~~

Change-Id: I52d85908f4aac20c7e9ac8063ac760ce52f85541
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-02 20:03:03 +00:00
Giuseppe D'Angelo
8cd99d24a8 QRegularExpression: build fix
Latest PCRE2 versions require a macro to be defined before
including pcre2.h, so do it.

Task-number: QTBUG-59226
Change-Id: I472ff557e29d1212fdcd99454778551323be4d4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-02 16:25:17 +00:00
Olivier Goffart
b41492d53e Doc: Remove references to pre-C++11 recommendations
Compiler support for lambda functions and variadic templates is
required since Qt 5.7, so no need to mention in the documentation
what happens if the compiler doesn't support it.

Change-Id: I5caeaa0bd7f0edce81e22e22964e0b7dd042c719
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-01 19:30:10 +00:00
Kai Koehne
a62d8ab993 Doc: Use canonical contact URL in license header
Change-Id: I34821150f66255df30d12572b27779e0e729ebc8
Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch>
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-28 15:33:49 +00:00
Allan Sandfeld Jensen
6dc7e468df Do not include qfloat16 tables in arm64 builds
The FP16 extension in IEEE mode is mandatory for Aarch64, so there is
no aarch64 configuration where the tables will be needed for conversion.

Change-Id: I9804e55c193cc9b5adcaedb720d8b980624139cc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Glen Mabey <Glen.Mabey@swri.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-28 12:01:18 +00:00
Thiago Macieira
04b8db3d57 Fix parsing of day-of-week names that start with another name
Task-number: QTBUG-59159
Change-Id: I95c9e502ccc74af3bcf0fffd14a69e0cd27ce96b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-28 10:40:40 +00:00
Stig Bjørlykke
2ae8292d03 QList: Avoid implicit conversion warning
This fixes compiling an application using QList and -Wshorten-64-to-32
on a 64-bit system without getting this warning:

 ... 5.8/clang_64/lib/QtCore.framework/Headers/qlist.h:897:26:
 warning: implicit conversion loses integer precision: 'long' to 'int'
 [-Wshorten-64-to-32]
           int removedCount = e - n;
               ~~~~~~~~~~~~   ~~^~~

Change-Id: I688ed086805c431821c2ee6078fa5aeb631e7a07
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-28 09:57:03 +00:00
Stig Bjørlykke
17d780ad45 QTimer: Avoid implicit conversion warnings
This fixes compiling an application using QTimer and -Wshorten-64-to-32
on a 64-bit system without getting this warning:

 ... 5.8/clang_64/lib/QtCore.framework/Headers/qtimer.h:171:21:
 warning: implicit conversion loses integer precision: 'rep'
 (aka 'long long') to 'int' [-Wshorten-64-to-32]
         setInterval(value.count());
         ~~~~~~~~~~~ ^~~~~~~~~~~~~

Change-Id: I3e0407a7193c841308f7271c41a8dd5a2eb2a534
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-28 09:56:13 +00:00
Nico Vertriest
657bea873b Doc: added info about return type for function QMutex::try_lock()
qmutex.cpp:266: warning: Undocumented return value

Change-Id: Ib93a5a2505f663f266871dbe5582fb5856096889
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2017-02-28 09:34:05 +00:00
Ulf Hermann
44af54419e Properly use the "process" feature
Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in
qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess
headers, exclude the sources from compilation when switched off, guard
header inclusions in places where compilation without QProcess seems
supported, drop some unused includes, and fix some tests that were
apparently designed to work with QT_NO_PROCESS but failed to.

Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-02-27 15:44:46 +00:00
Giuseppe D'Angelo
9d82b1586d QEasingCurve: mark as shared
Requires no further changes.

Change-Id: Ib280fa69a752aefa1c29fc5f0eb292e99b96270a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-27 15:35:59 +00:00
Oswald Buddenhagen
85b30fda7c fix detection of static icu under unix
the library has a dependency on libdl.

Task-number: QTBUG-58301
Change-Id: I36567ded32980b241ff2f01cfdec044510405a75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-02-27 12:20:50 +00:00
Oswald Buddenhagen
0d7ed8f5f3 streamline libdl detection and linking
instead of having a library and a test, use a library with two sources,
the first being empty (i.e., just libc). this allows us doing away with
the "libdl" feature, and using just the "dlopen" one.

subsequently, replace all LIBS+=$$QMAKE_LIBS_DYNLOAD with
QMAKE_USE+=libdl.
the definitions of QMAKE_LIBS_DYNLOAD remain in the qmakespecs for
backwards compat only. n.b.: the only specs where it is not empty or
"-ldl" (i.e., what we support now) are the hpux ones, where the library
is called 'dld'.

technically, the "library" feature should depend on '!unix || dlopen', but
that's for a later patch.

Change-Id: Ib8546affc4b7bc757f1a76729573ddd00e152176
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2017-02-27 12:20:44 +00:00
Marc Mutz
1d31f23ce9 QVarLengthArray: add rvalue overload of append/push_back
Improves performance when appending temporaries, esp. since
the aliasing fix in the lvalue overload in 0f730ef made that
overload correct, but a bit slower across reallocs.

The unit tests already also pass rvalues, so the function is
covered in the existing tests.

[ChangeLog][QtCore][QVarLengthArray] Added rvalue overloads
of append() and push_back().

Change-Id: If3a6970f03a160cba5b42d33d32d3d18948f6ce3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-25 21:04:01 +00:00
Christian Gagneraud
e3bcab935c Fix documentation typos
This patch fixes 2 simple typos in QGraphicsItem and QPainter
documentation and a copy/paste error between QAbstractItemModel's
beginRemoveColumns and beginRemoveRows documentation.

Change-Id: I32bdc4dc69154a40fe30a5b8c08d0c3a001853f8
Reviewed-by: Harri Porten <porten@froglogic.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-25 00:16:28 +00:00
Liang Qi
de49839df8 Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	mkspecs/features/moc.prf

Change-Id: Ia71c8e3b3185f7c999bf226d0675051b10b8740b
2017-02-24 20:01:42 +01:00
Thiago Macieira
07fffa6010 QDateTime: Fix clearing the ShortData flag in setMSecsSinceEpoch
Unlike setTimeSpec, this forgot to clear the bit when detaching. So it's
possible that some further use of the flags could incorrectly conclude
that the data was short and then proceed to corrupt the pointer.

The example from QTBUG-59061 caused this because toUTC() -> toTimeSpec()
calls setMSecsSinceEpoch which left the bit set; then addDays() calls
setDateTime(), which calls checkValidDateTime() and that corrupted the
pointer. This problem was more visible on 32-bit systems because no
QDateTime was short (except for default constructed ones), but it
can happen on 64-bit with sufficiently large dates.

Task-number: QTBUG-59061
Change-Id: Ibc5c715fda334a75bd2efffd14a562a375a4e69b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-24 16:17:03 +00:00
Marc Mutz
f4495d29e5 Clean up QByteArrayLiteral definition
Remove the dead QByteArray(data, size) fall-back. We've been
requiring lambdas since Qt 5.7.

Change-Id: I4d9023ab4583f2ee80a74a828fba0d95c2fdb0df
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-24 08:03:32 +00:00
Aaron Linville
c4f122927a Doc: Fix minor typos in QRectF
Fix a couple incorrect references to the integer precision classes.

Update snippet to use floating point precision classes.

Task-number: QTBUG-51630
Change-Id: I9b08cfb68937a8e1179ee414d7981956ef7bc106
Reviewed-by: Martin Koller <kollix@aon.at>
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-02-23 20:55:10 +00:00
David Faure
9ffc9e306f QUrl::fromUserInput(with cwd) fix handling of files with trailing spaces
The call to trimmed() makes sense for URLs typed in a browser's location bar,
but its use in every code path made it impossible to open a file with a trailing
space in command-line tools that uses fromUserInput(cwd) to handle command-line
arguments, as recommended. For instance kde-open5 "file.txt " would fail.

Change-Id: Ie61182684521d91f077d3e76f95b7240965ab405
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 18:12:35 +00:00
Marc Mutz
62e15093ff Unexport QTimeZonePrivate
It's only used in the autotests, and it private API, so
downgrade from Q_CORE_EXPORT to Q_AUTOTEST_EXPORT.

Fix a use of QTimeZonePrivate functions unprotected by
QT_BUILD_INTERNAL in tst_qtimezone.cpp.

Change-Id: I70eaea06f8fcf2983aeafb6894c3a5d2a4b272a7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 10:42:51 +00:00
Shawn Rutledge
6aaf853222 make TabletMove hover events conditional on QWidget::tabletTracking
This adds the tabletTracking property in the same way that mouseTracking already
existed: there is a WA_TabletTracking attribute, and a TabletTrackingChange event
to notify when it changes.  So for widget applications it's an opt-in feature.
QtQuick applications don't yet make use of tablet events, but when they do
in the future, we don't yet have a mechanism to turn the move events off;
it remains to be seen whether that will be necessary.

[ChangeLog][QtWidget] QWidget now has a tabletTracking property, analogous
to mouseTracking, which will enable TabletMove events while the stylus is
hovering, even if no button is pressed.  This allows applications to show
feedback based on the other tablet event properties such as rotation and tilt.

Task-number: QTBUG-26116
Change-Id: Ie96e8acad882b167e967796cdd17f1ad747a2771
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2017-02-23 10:42:42 +00:00
Edward Welbourne
2c13070162 Do not delete someone else's QSystemLocale when constructing another
The QSystemLocale constructor remembers the most-recently-constructed
instance - a dodgy enough proposition at the best of times - and
shares it with much of the rest of QLocale.  There is a global static
instance, actually of a derived singleton class, to which it is
usually set on program start-up.  However, the constructor deleted the
remembered instance before remembering any new instances; there was no
way this could not lead to bad consequences.  So let's not do that.

Change-Id: Ie8f3d655c9d4f75f6ec00a5861d98d6020ecc633
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 09:39:23 +00:00
Marc Mutz
4d92712a2c QTimeZonePrivate: make clone() const, use covariant return types
There's nothing wrong with cloning a const QTimeZonePrivate, so make
clone() const.

Also, if you're cloning a QTzTimeZonePrivate, you already know that
you get a QTzTimeZonePrivate back. C++ supports covariant return types
for this reason, so use them.

Change-Id: I60e19e89b1b7bad080c552f1baca314ab0a6295e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 05:45:53 +00:00
Marc Mutz
4cd002402f Simplify QTzTimeZonePrivate implementation
- Don't init m_icu with 0. It's a QSharedDataPointer, which inits to
  nullptr anyway.
- The copy ctor didn't do anything out of the ordinary, so = default it.
  It's also only used in the implementation of clone(), so make it private.

Removes three #if QT_CONFIG blocks.

We can't use ctor delegation here, because systemTimeZoneId() is a
virtual function.

Change-Id: I2cd06c3349686b6f21c897acb5c12185a36d5b9f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 05:45:49 +00:00
Marc Mutz
2cda991ab1 QStaticByteArrayMatcher: fix MSVC warning
MSVC 2013 complained:

  src/corelib/tools/qbytearraymatcher.h(143) : warning C4351: new behavior: elements of array 'QStaticByteArrayMatcher<6>::m_pattern' will be default initialized

Fix the same way as 9a07ab9234: by suppressing
the warning.

Change-Id: Ic41f7eabe7e39709d76e6062f5891cdcfaa6e1ed
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-02-23 05:44:58 +00:00
Marc Mutz
3ac8b8c696 QTypeInfo: record whether it was specialized
This is one of the pillars of my static container checking toolbox,
one of the main checks being that every type put into a Qt container
has been marked up with Q_DECLARE_TYPEINFO.

Obviously, we cannot upstream such a checker and inflict it upon the
world, but we can put some foundations in. This is the most central
one.

Change-Id: I9185facb2f37ba9fcc12c9aae5675eed454d755c
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 05:44:47 +00:00
Pavol Markovic
dd4465f57c Wrap RunLoopModeTracker into Objective-C namespace
RunLoopModeTracker as one of Qt Cocoa classes was not wrapped
in namespace which limited its use in Objective-C single symbol space.

Change-Id: Ida2c62c6f543a3bf5107f28c78d27435bcb3470d
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2017-02-22 20:16:59 +00:00
Ulf Hermann
4e9f7807fb Move qJsonFromRawLibraryMetaData into qfactoryloader_p.h
This is still not a great place for it, but this way we can
Q_REQUIRE_CONFIG(library) in qlibrary_p.h and qfactoryloader_p.h is the
only private header that doesn't require library support in plugin.pri.

Change-Id: Ia6c1ac8799822eca1e0cbeca98d1c1b8de74beae
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-02-22 17:36:32 +00:00
Marc Mutz
494ee2aa8d QThreadPool: supersede cancel() with tryTake()
The cancel() function added in 5b11e43e for Qt 5.5 suffers from a
number of problems:

First, if runnable->autoDelete() is true, then the function suffers
from the ABA problem (see documentation written for trytake()).

Second, if runnable->autoDelete() is false, due to cancel() throwing
away crucial information instead of returning it, the caller cannot
know whether the runnable was canceled (and thus has to be deleted),
wasn't found or is currently executing (and thus mustn't be deleted),
or has finished executing (and can be used to extract the result).

Deprecate this dangerous API and replace it with the much more useful
Private::stealRunnable(), promoted to public API and renamed to
tryTake() for consistency with the rest of Qt.

Described the various caveats in the function's documentation.

[ChangeLog][QtCore][QThreadPool] The cancel() function suffers from
several subtle issues and has been replaced with a new tryTake()
function.

Change-Id: I93125935614087efa24b3e3969dd6718aeabaa4f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-22 16:37:07 +00:00
Marc Mutz
7c647edae9 QTypeInfo: don't treat enums and (extended) integral types as complex
We fully specialize QTypeInfo for most C++ built-in types,
but enums and extended integral types (like GCC's int128_t)
were not covered.

Now that we depend on <type_traits>, we can stop pessimizing
enums and extended integral types in QVector and QVLA by
defaulting QTypeInfo::isComplex to true for such types.

Fix a test that checked that enums were complex types. This should
have been a XFAIL test. Enums are not complex types.

Change-Id: Ibb0fb38cc83e980a428b5573d1db5666593418ae
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-22 09:21:57 +00:00
Marc Mutz
19085350fb Do not use QTypeInfo::isStatic anymore
... except in QList.

When dafa3618 introduced isRelocatable and QTypeInfoQuery, the
intention was to decouple the memory layout of QList from the
reallocation optimizations in QVector. This never happened, as
QVector (and QVarLengthArray) continue to use isStatic to this
day.

Fix by porting both QVector and QVLA to QTypeInfoQuery and
isRelocatable.

Change-Id: I6951f2cf21f0cbb24e2dbd38f80f1bd82007d394
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-22 08:04:12 +00:00
Marc Mutz
4df229ce50 QArrayDataOps: don't use value-initialization
... but default-initialization instead.

This bug may have rendered the diverse Qt::Uninitialized ctors
we have in Qt containers ineffective.

Change-Id: I5a369fa8527f19b6f8cc1a9f36512f6a0058839a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-22 08:03:46 +00:00
Marc Mutz
adca47cbc1 QTzTimeZonePrivate: introduce PosixZone class
... as a replacement for QPair<QString, int>, and move some
repsonsibilities into it.

This avoids the repeated use of the magic number INT_MIN to indicate
absence of an offset and does away with the confusing .first and
.second, replacing them instead with proper names, .name and .offset.

Change-Id: I0f6906467b8efa16bed2bf5677f2bbbd534da1ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-22 07:58:19 +00:00
Stephan Reiter
1d44b6bedb QProcess::startDetached(): Support privilege elevation for non-.exe files
Pass classname 'exefile' to ShellExecuteEx() for UAC prompt.
This allows running executable files that do not have a .exe extension.

Task-number: QTBUG-59008
Change-Id: I88d669481e893db50edccd7b30259e5366477556
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-02-22 07:47:18 +00:00
Oswald Buddenhagen
7509ccc0f7 add configure -list-features
also actually deletes qfeatures.txt, which was already claimed by
a668c6a6, but not actually done.

Task-number: QTBUG-58411
Change-Id: I686760632fee7c10b01bd2e83f2481b01bc2b774
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-22 07:46:05 +00:00
Olivier Goffart
5426e689f9 Fix a race condition between QObject::connect and qRegisterMetaType
QObject::connect will extract the QArgumentType for first the signal,
then the slot. The QArgumentType with a string constructor will query
the metatype system to get the meta type id. But it might happen that
between the extraction of the signal's argument and the slot's argument,
qRegisterMetaType was called in another thread. For this reason, it's
possible that one QArgumentType has a type id while the other does not.
For this reason, we should fall back to compare the string if any of
the argument's type is 0.

Task-number: QTBUG-50901
Change-Id: I260ca662ff00a773ae519f78bb633e05fde0ea81
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-22 07:37:51 +00:00
Marc Mutz
e0a9a0e217 QArrayDataOps: do not use QTypeInfo::isStatic anymore
These days, QTypeInfoQuery and isRelocatable should be used.

Change-Id: Ieac2d7fcef6b1d5466b14bbd1066901d6e751a55
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-22 07:12:13 +00:00
Marc Mutz
809cef1732 QTimeZone: do not access static functions through this->
The this pointer cannot be null, so we can't do d->staticFunction while
d is a null pointer. This was caught by Clang 3.8's ubsan.

Change-Id: I3c0d39b88cca83d827a69ed1544a4412b18ac907
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-22 07:00:43 +00:00
Marc Mutz
567abeaa04 QLoggingRegistry: fix potential data race
The 'rules' vector is made up of all the individual {env,config,...}Rules
vectors under mutex protection whenever init() is called (only from the
QCoreApplication ctor) or, at any time, by a call to QLoggingCategory::
setFilterRules().

Yet, the writes to the individual *Rules vectors were never protected by
registryMutex, racing against the reads of the same vectors in the
updateRules() function.

Fix by protecting all access of all member variables with registryMutex.
Add some strategic comments to make analysis easier for the next guy.

Change-Id: If68d15a553ec7038693574a34f10a39f4cd480e8
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-20 07:23:59 +00:00
David Faure
6c9b558153 QMimeDatabase: fix matching of filenames with different length when lowercase
AİİA.pdf takes 8 QChars, but after lowercasing it takes 10, so the code cannot
assume the length to be the same.

Task-number: QTBUG-58822
Change-Id: Id6fbb99f6afd08ee420099cd66372732d7598d9e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-17 18:52:50 +00:00
Olivier Goffart
8d6d68d3d3 QReadWriteLocker: Fix race in unlock
An Acquire barrier in QReadWriteLocker::unlock was missing to synchronize
with the testAndSetOrdered on d_ptr in the lock functions.

The race is between the write of d->writerCount in tryLockForWrite,
and the read in unlock. The acquire on d->mutex is not enough because
it is not on the same object. While that race could be fixed by taking
the newly-allocate()ed d's mutex before publishing it with testAndSet,
there's another race, on 'recursive', between a newly-minted Private*
with recursive == false in tryLockForWrite(), and the read of 'recursive'
in unlock().

Task-number: QTBUG-58917
Change-Id: I10ba36573c0e57468d11e9b77d85045711feaea1
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-17 16:21:20 +00:00
Paul Olav Tvete
d995f0fe09 Build fix for new feature -qt-no-processenvironment
Change-Id: I6d1c5d122761d239d96b943a9abf7af12195a3eb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-02-17 14:41:34 +00:00
Paul Olav Tvete
983ffeb9ff Build fix for -no-feature-datestring
Change-Id: I09c7bc360956aef44f4137a093b6329a08a099ee
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-17 14:41:19 +00:00
Liang Qi
e5c3700a61 Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9 2017-02-17 10:36:32 +00:00
Olivier Goffart
dd7f62059c Fix a race in QFreeList
The _next variable need the acquire and release fence in next()
to synchronize with the equivalent operations in release() (which
already have the them)
The ordering on the _v[block] is not enough as this does not
synchronize the same object.

Task-number: QTBUG-58917
Change-Id: I17cc39e6791433348b6227363dbea92bcf03700d
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-17 09:28:44 +00:00
Marc Mutz
0e3d6fe4f6 QVarLengthArray: fix appending an already-contained item
Like the lvalue QVector::append() overload, when we reallocate,
we need to take a copy of the function's argument because the
reference will get stale upon reallocation.

Add a test.

[ChangeLog][QtCore][QVarLengthArray] Fixed a bug involving
appending an item already in the container to the container
again.

Change-Id: I06eeed6cb383dd5924e47a302bb3d1666d04c8e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-17 07:35:31 +00:00
Thiago Macieira
d9a2dd8d3b QDir::mkpath: don't try to mkdir in automount filesystems
Automount filesystems like /home on many operating systems (QNX and
OpenIndiana, at least) don't like if you try to mkdir in them, even if
the file path already exists. OpenIndiana even gives you an ENOSYS
error.

So instead, let's try to mkdir our target, if we fail because of ENOENT,
we try to create the parent, then try again.

Task-number: QTBUG-58390
Change-Id: Ibe5b1b60c6ea47e19612fffd149cce81589b0acd
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-16 21:08:32 +00:00
Liang Qi
c577f6edaf Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/corelib/plugin/qlibrary_unix.cpp
	src/plugins/platforms/xcb/qxcbconnection.cpp
	tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp

Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
2017-02-16 21:51:11 +01:00
Marc Mutz
cad9c7cbc9 Use static initialization for QBasicAtomics
A default-constructed static QBasicAtomicInt at function scope
will be dynamically initialized. It will still be zero-initialized,
but at least GCC adds guard variables for such objects.

When using aggregate initialization, the guard disappears.

Amends 04d6495bf7.

Change-Id: Id9335cffdd43094cafb231fdde2523d013abe1d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-16 19:26:46 +00:00
Ulf Hermann
1aaf45e106 Eliminate QT_NO_DYNAMIC_LIBRARY
The library feature already covers this. As library depends on the
dlopen compile check, we can assume dlopen to be available, also on
vxworks.

Change-Id: Idcdb07ab4688c6158651d9a5ad5e2ba126bd7d9e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-02-16 15:06:26 +00:00
Marc Mutz
0f730ef7b6 QReadWriteLock: make field 'recursive' const
It is never written after initialization, and accessed concurrently
outside mutex protection, so make sure that it never changes by
marking it as const.

Change-Id: Ib28b2e8b3067d596a95d1699165a6ebfb15fe674
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-16 14:34:22 +00:00
Marc Mutz
f05d2764b0 QJNIHelpers: unbreak runnables counter
Adding 0 each time will obviously not produce a new identifier each
time...

Also use static initialization for QBasicAtomicInt.

A default-constructed static QBasicAtomicInt at function scope
will be dynamically initialized. It will still be zero-initialized,
but at least GCC adds guard variables for such objects.

When using aggregate initialization, the guard disappears.

Amends 265db5ad9b.

Change-Id: Ia71290cf26c486dcbcc74381f12cd0c4712d6019
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-16 14:30:27 +00:00
Allan Sandfeld Jensen
925a3c6529 Use native support for fp16 where available
Use F16C or ARM FP16 if available at compile time.

Configure check added because older clang compilers have F16C defines
and flags but not all the intrinsics.

Change-Id: I71f358b8fd003e70ab8fcf35097414591e485112
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-16 12:03:45 +00:00
Marc Mutz
5486882b52 Android: De-duplicate vtables of exported private classes
By making the destructor (usually the first non-inline, non-pure,
virtual function, and therefore the trigger for most compilers to emit
the vtable and type_info structures for the class in that TU)
out-of-line, vtables and, more importantly, type_info structures for
the class are pinned to a single TU. This prevents false-negative
dynamic_cast and catch evaluation.

Since the classes are already exported, users of these classes are
unaffected by the change, and since it's private API, we don't need to
avoid adding code to the out-of-line destructor until Qt 6.

While at it, de-inline also the empty default implementations of
virtual (non-dtor) functions.

Task-number: QTBUG-45582
Change-Id: I3e6f37eab1dee0db445f6c13638a43ca3bf6ac62
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-16 05:02:34 +00:00
Marc Mutz
bf2160e72c Clean up QStringLiteral definition
We require lambda support in the compiler since Qt 5.7, so drop
the guard macro.

Apart from MSVC 2013, all our supported compiler also support
char16_t:

- VxWorks uses GCC 4.8, which supports char16_t since 4.5.
- ICC supports char16_t since v12.1; we require v14+.
- ONX uses a GCC which supports char16_t in the compiler,
  but is equipped with a stdlib that does not sport char16_t
  support, which is why we revoke its Q_C_UNICODE_STRINGS in
  qcompilerdetection.h. But we don't need stdlib support, we
  only need the core language feature.
  This is the only platform where this patch actually changes
  something. It removes the, rather unfair, pessimization of
  the platform which could have supported the static-storage-
  duration implementation of QStringLiteral instead of the
  fallback, which uses dynamic memory (QString::fromUtf8()).
- GCC and Clang support char16_t since 4.5 and 3.0, resp.,
  which is far below our minimum compiler requirements in
  effect since Qt 5.7.
- On Windows, MSVC supports char16_t since 2015 only, and we
  still support 2013, but on Windows, wchar_t is the same size
  as char16_t, so instead of u"str" we can fall back to L"str".

So simplify the implementation of QStringLiteral by assuming
that all these feature are present, adding noexcept to the
lambda to make noexcept() queries return true.

This allows us to guarantee:

[ChangeLog][QtCore] QStringLiteral is now guaranteed to be
evaluated at compile-time. The last platform (QNX) to use the
QString::fromUtf8() fallback has been ported to allocate the
string data statically, too.

Change-Id: I7920d7a77001e5c5550e7c7d57ceb7c51c9eb443
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-15 20:14:56 +00:00
Marc Mutz
04d6495bf7 Make some atomic counters zero-based
A variable of static storage duration that is not zero-initialized
takes up space in the DATA segment of the executable. By making the
counters start at zero and adding the initial value afterwards, we
move them over to the BSS segment, which does not take up space in
the executable.

Wrap atomics used across function boundaries into small functions,
to avoid code duplication and to increase readability.

Change-Id: Ida6ed316ecb8fe20da62a9577161349e14de5aed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-15 20:14:27 +00:00
Marc Mutz
a5febadac5 QString(Ref): make toLatin1()/toLocal8Bit() null handling consistent
Systematic testing in tst_QStringApiSymmetry revealed a bug in
QStringRef::toLatin1(): a null input did not result in a null output,
but an empty one. This is fixed, for consistency with
QString::toLatin1(), and QString(Ref)::toUtf8(), which behaved
correctly already.

The same bug was found in QString(Ref)::toLocal8Bit(), which is
particularly hideous, as it's documented to fall back to toLatin1(),
which preserves null inputs. Fixed, too.

[ChangeLog][QtCore][QString] toLocal8Bit() now preserves nullness of
the input QString (outputs null QByteArray).

[ChangeLog][QtCore][QStringRef] toLocal8Bit() and toLatin1() now
preserve nullness of the input QStringRef (output null QByteArrays).

Change-Id: I7026211922c287e03d07e89edbad2987aa646e51
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-15 20:12:36 +00:00
Thiago Macieira
798819bb87 Correct \since for QStorageInfo::subvolume()
3e9db01a2e4be5034d10d6eeafd65d0a8609615b entered dev after the 5.8
branch.

Change-Id: I4139d5f93dcb4b429ae9fffd14a349e85e62a298
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-02-15 16:33:20 +00:00
Thiago Macieira
fb376e0fcc Remove the name cache from QMetaType::typeName
It was unnecessary, since we only cached the static types, which are all
generated by the macro anyway. The way it was implemented, this produced
data races that are strictly-speaking UB, even if all the threads were
writing the same values to the same data locations.

This commit changes a little the code to simplify, since we're changing
those lines anyway.

Task-number: QTBUG-58851
Change-Id: Idc5061f7145940f987dffffd14a30047846e3113
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-15 16:25:38 +00:00
Frederik Schwarzer
1e7143cff8 Fix minor typos in apidoc
Change-Id: I5ce9599a60ea336b469807df075e491f0e6df680
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-02-15 15:01:45 +00:00
Samuel Gaist
280225495d Doc: fixed explanation in Qt::Tool documentation
Clarify the the macOS implication of the flag.

Change-Id: Ic68e1ac668cfa68abf868ba6bdd46241dfa9b9a7
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
2017-02-15 14:45:18 +00:00
Kimmo Ollila
a0a9e8b2d7 Fix is_iec559 assert on GHS compiler
GHS compiler is not fully compliant with iec559.
Therefore we need to replace is_iec559 assertion
with separate checks to build quint16.

Change-Id: I88c57e394b8d4e7899ee7d4a13cbfbac9436b2fc
Reviewed-by: Rolland Dudemaine <rolland@ghs.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-15 13:52:26 +00:00
Marc Mutz
03903ec783 QJNIHelpers: make mutexes static
Amends 265db5ad9b.

Change-Id: I707bb88285531ee9f82efec46901871d53413eb3
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2017-02-15 13:06:12 +00:00
Frederik Schwarzer
9e888e633b Fix indentation of source code example in docs
Change-Id: Icf94c9adc55d16acd26831cce331054a8c49652d
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-02-15 11:58:12 +00:00
Marc Mutz
af8771867c Fix UB (data race) in QtAndroidPrivate::requestPermissionsSync()
If the QSemaphore::tryAcquire() call times out, we mustn't
touch *res, because there was no happens-before relation
established between *res = result in the lambda and our
returning *res;

Fix by returning a default-constructed hash in that case.

Add a strategic std::move().

The same problem exists in runOnAndroidThreadSync(), but
I have no idea how to solve it, because there the shared
object is the runnable itself.

Change-Id: I9a2c431144c169fbd545763555d96153143a11bf
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2017-02-15 11:24:18 +00:00
Marc Mutz
39820cf8c3 QJNIHelper: fix a potential race in sendRequestPermissionsResult()
The code obtained an iterator into a QHash under mutex protection,
then dropped the lock, dereferenced the iterator several times and
only retook the lock to erase the element from the QHash.

This is very smelly. QHash provides no official iterator validity
guarantees, and the container isn't const, either (which would imply
thread-safety). In particular, the dereference into the container
outside the critical section is cause for concerns.

Simplify the code, removing any doubts about its race-freedom, by
taking the payload item out of the hash before dropping the lock, and
using only the local strong reference in the remainder of the
function.

The only other references to g_pendingPermissionRequests are
insertions with unique-by-construction keys in QtAndroidPrivate's
requestPermissions(), so there was no reason to keep the item in the
hash for the whole duration of the sendRequestPermissionsResult()
call.

Change-Id: I39fe0803b13b3046d1f0fd9c8e96c531406d57da
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2017-02-15 11:23:28 +00:00
Heikki Haveri
aebf66d242 Enable QtAndroid::runOnAndroidThread in a Service
Change-Id: I214f5dc70c52011a5e1712ea70f97f8b564fb664
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2017-02-15 10:04:17 +00:00
Thiago Macieira
b58af67d7b Turn QThreadData::threadId into a QAtomicPointer
Solves a data race found by TSan.

Since thread and threadId are QAtomicPointer, I've removed the explicit
initialization in the QThreadData constructor

Task-number: QTBUG-58855
Change-Id: I4139d5f93dcb4b429ae9fffd14a34082f2683f76
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-15 08:08:58 +00:00
Friedemann Kleint
0b30a6e6aa QElfParser: Fix plural form in error message
Amends change dcec1420ea.

Change-Id: I54c7db012d87a55c310141debac19118e7cb284a
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-15 07:18:55 +00:00
Marc Mutz
265db5ad9b QJNIHelper: clean up atomic int and mutex handling
1. Do not use Q_GLOBAL_STATIC to hold QAtomicInt or QMutex, use
   file-static QBasicAtomicInt and QBasicMutex instead. They are
   zero-initialized PODs.
2. Use only QMutexLocker to lock mutexes.

Also wrap the atomic counter into a next...() function, as done
elsewhere.

Change-Id: I4b14ac0de9d4cb6780b1f1372c2b5fc88e918e4c
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-14 21:11:03 +00:00
Marc Mutz
c4a5307a3e QMutex/Linux: remove unused QBasicAtomic
$ git grep -we futexFlagSupport
  src/corelib/thread/qmutex_linux.cpp:static QBasicAtomicInt futexFlagSupport = Q_BASIC_ATOMIC_INITIALIZER(-1);

The last user of this variable was removed in 9ef59b5.

Change-Id: I818a13a481ad25baa5ff7d389a737b8801adcfcc
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-14 13:30:05 +00:00
Liang Qi
27432d40f2 Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: I2bd2e61bae1eab4fc74fa6accd741ed9ae1f0669
2017-02-14 11:33:02 +01:00
Oswald Buddenhagen
e3e2bc2109 announce 'temporaryfile' feature in bootstrap library
qmldevtools refers to it.

Task-number: QTBUG-58819
Change-Id: Id88265bb17e4d2e9c61f77409c4163eacc4a13f3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-13 09:20:07 +00:00
Marc Mutz
0d2791c5f6 QCollatorSortKey: add some std::move
All implementations of QCollator::sortKey() can benefit from
moving their CollatorKeyType into the QCollatorSortKeyPrivate
on construction.

So make the QCollatorSortKeyPrivate ctor a perfect forwarder
for its m_key member, and add std::move() calls where they
were missing (in all but one case, lvalues were passed).

Make the ctor explicit, as it should have been from the
beginning.

Change-Id: I2a1cdda5fd23990ace019b963df895c621a1fa85
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-13 08:42:46 +00:00
Marc Mutz
a85b4d79db QThreadPool: replace a QSet with a QList
QThreadPool maintains three containers of QThreadPoolThread*:

- allThreads, a QSet
- waitingThreads, a QQueue
- expiredThreads, also a QQueue

None of the operations on allThreads make use of QSets fast lookup.
The only functions called on it are isEmpty(), count(), insert(),
and swap().

Since therefore QSet adds nothing but overhead, causes indeterminism
(e.g. when deleting threads in Private::reset()) and code bloat, use
the same container for allThreads that underlies QQueue: QList.

Port insert() to append(). Add an assert to verify that we're not
running into an ABA problem here (but this should never fire, since
we're never deleting threads except in Private::reset(), where we
do remove them from allThreads), just in case.

Saves ~0.5KiB in text size on optimized Linux AMD64 GCC 7.0 builds.

Change-Id: I53a4d5ef2c204420f7c8852f1e72ab3d6ea43d08
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-13 08:42:41 +00:00
Filipe Azevedo
9db8c171e7 Fix QLibrary::isLibrary on Apple platforms
Add proper support for 'so' and 'bundle' suffixes.  Qt wrongly assumes
.so libraries are not versioned on Apple platforms, which is
wrong. Also, the shared library .bundle which is what Apple recommends
instead of .so, are also versioned (not to be confound with the
different Core Foundation bundles, which are directory hierarchy).

For more info, see http://docstore.mik.ua/orelly/unix3/mac/ch05_03.htm.
Especially the part that reads:

"Loadable modules, called bundles in Mac OS X, have the file type
MH_BUNDLE. Most Unix-based software ports usually produce bundles with a
.so extension, for the sake of consistency across platforms. Although
Apple recommends giving bundles a .bundle extension, it isn't
mandatory."

Task-number: QTBUG-50446
Change-Id: Iacd5136397a12d65d83821434f332eb602550b4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-12 18:25:42 +00:00
Thiago Macieira
418184c2a0 Update the __xxx__ macros due to MSVC and ICC not defining them all
And if __AES__ or __PCLMUL__ is defined, then we expect wmmintrin.h to
exist.

Change-Id: I445bb15619f6401494e8fffd149db77dc513e071
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2017-02-12 08:16:05 +00:00
Thiago Macieira
68b21690e2 Use QBasicMutex in qthread_win.cpp
It's QtCore, so we're fine.

Change-Id: Ifaee7464122d402991b6fffd14a0d7ad9c09e2f2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-11 05:06:33 +00:00
Thiago Macieira
8a410f60ae Don't include qfloat.h in the QtCore master include
We have observed that MSVC 2013 gets lost with the overloads that this
header adds, causing compilation bugs. This is believed to be a compiler
bug, but it's not something we can work around.

Task-number: QTBUG-58555
Change-Id: I536c32a88bff44dab37afffd14a1bad1d31dc16d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Glen Mabey <Glen.Mabey@swri.org>
2017-02-09 21:23:31 +00:00
Alex Trotsenko
6e8fcab7e0 Improve QIODevice::peek() performance on buffered devices
Since 5.7, QIODevice::peek() implementation is based on transaction
mechanism. While technically it's correct, seeking backward on a
buffered random-access device clears the internal buffer that affects
the performance of reading.

To solve the problem, this patch implements peek mode directly inside
the reading procedure.

Task-number: QTBUG-56032
Change-Id: Ic5269f76e44c491a0309e13aba87fa7cf7b9259f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-09 18:46:24 +00:00
Alex Trotsenko
60563855e5 Refactor QIODevice::read()
Move device-dependent part of the code into the private function for
further reusing by peek() procedure.

Task-number: QTBUG-56032
Change-Id: Iedceafe4b0bab109ca5c64ad274d779efe87c27b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-09 18:46:15 +00:00
Thiago Macieira
7314c53d31 Add QDataStream streaming operator for QFlags
We're already using it, for example in qpaintengine_pic.cpp:502:
         d->s << p << ti.text() << fnt << ti.renderFlags() << [...]
                                             ^

[ChangeLog][QtCore][QFlags] Added operator<< and operator>> for
streaming QFlags into and out of QDataStreams.

Change-Id: I33dc971f005a4848bb8ffffd1478e79d6102d1bc
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-09 17:46:11 +00:00
Oswald Buddenhagen
b052d0cffd rename qvector.cpp => qvector.qdoc
the file contains no code.

this avoids complaints from ar/ranlib in static/bootstrapped builds.

Change-Id: Iee22ffc61a5f9ea8c25f5455b7e8e017ac521624
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-09 14:56:01 +00:00
Thiago Macieira
136c5b9338 Merge several Q_GLOBAL_STATICs in qresource.cpp into one
Since they are all used in a typical application, this reduces the
number of memory allocations (thus, the overhead) as well as the
state-keeping in the libc atexit() functions.

Change-Id: Ifaee7464122d402991b6fffd14a0e59457ad9cb7
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-09 01:22:54 +00:00
Thiago Macieira
4f3ea30922 Avoid unnecessary creation of some Q_GLOBAL_STATIC
If these lists weren't created in the first place, then they are empty.
We don't need to create it in order to conclude that. Unlike most
Q_GLOBAL_STATICS, these are almost never used and yet they were
always created due to where they were checked.

Since we're calling exists() before, there are two consequences: first,
since the list already exists, we're not allocating memory so it cannot
throw std::bad_alloc when being accessed. Second, since we've just
checked it exists, we can use QGlobalStatic's operator*(), which is
slightly faster than operator()(). The weird &(*list) syntax is only to
avoid changing the rest of the code that used a pointer

Change-Id: Ifaee7464122d402991b6fffd14a0e44f533dc3d9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-09 01:22:12 +00:00
Liang Qi
dd756011da Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	configure.json
	mkspecs/win32-icc/qmake.conf

Change-Id: Ibf40546b024d644c7d9ed490bee15b82597f4d3f
2017-02-08 15:49:18 +01:00
Thiago Macieira
8798d03e7e Remove unused qt_application_thread_id variable
Seems to be a write-only variable and QThread::currentThreadId has no
side-effects.

Change-Id: Ifaee7464122d402991b6fffd14a0c8666968dfe4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-08 00:02:44 +00:00
Marc Mutz
0c50edbe84 QCollator: don't pipe bcp47Name() through QString
Give QCollator access to QLocalePrivate::bcp47Name(), to avoid
both the latin-1 -> UTF-16 conversion in QLocale::bcp47Name(),
as well all as

- the replace('-', '_').toLatin1() call in ICU
- the toLocal8Bit() call in macOS
- the toUtf8() call in Windows

implementations of QCollatorPrivate::init().

This is safe, since, according to https://tools.ietf.org/html/bcp47,
a BCP47 name only contains US-ASCII (ALPHA used, which is defined by
https://tools.ietf.org/html/rfc5234 to be [a-zA-Z] only).

Change-Id: Id56befb1b5a7983494d848cdabf7ebeda377cf9f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-07 19:40:10 +00:00
Marc Mutz
9e5e30fa13 QStringMatcher: fix setCaseSensitivity() on a non-QString-backed matcher
When a non-QString-backed mode (via the (QChar*, int) ctor) was added
for Qt 4.5, the author forgot to adjust the setCaseSensitivity()
function.  It still uses q_pattern instead of (p.uc, p.len) as the
pattern for which to create the skip-table. Since there is no
setPattern() overload for this mode, the correctness of the matcher is
not harmed by this, but its performance degrades to that of a linear
scan: the skip-table, being filled from an empty pattern, will be
all-zeros, sending bm_find() into the 'possible match' case at every
character.

Since matching is still correct, but slow, it's not possible to write
a test for this. I did, however, leave my attempts in the auto-test,
for when we add QStringView overloads of setPattern() which will then
be able to expose the bug.

Change-Id: I7b803e8624b0352a0a974900affbbfc0c260d93b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-07 16:31:00 +00:00
Marc Mutz
18e6e81059 QCollator/ICU: fix a rather hair-raising performance bug in compare(QChar*, int, QChar*, int)
The intention when using an overload that takes (const QChar*, int)
instead of a QString is probably to avoid creating a QString in the
first place. If the implementation stabbs the user in the back by
internally creating a QString just so it can call QString::compare()
on it, then that is rather unacceptable.

QCollator is already a friend of QString, so, absent QStringView,
resolve to calling compare_helper().

Change-Id: Ia7de1a095e3e310bd1b9957ed67291cc9cc95b32
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-07 12:01:08 +00:00
Marc Mutz
9aaaa8427d QCollatorSortKey: use QExplicitlySharedDataPointer as pImpl
The key is immutable except for assignment and swap,
so don't run the risk of auto-detaching and use the
explicit-detach version of QSharedDataPointer.

Change-Id: Ib2cfe5981e6dfe375d6208289ff58247ef9d4870
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-07 09:50:16 +00:00
Marc Mutz
1401225330 QLoggingRegistry: optimize updateRules()
... by not creating three temporary QVectors just to concatenate them.

There's no QVectorBuilder, so what works well with QStrings doesn't
work well at all with QVectors. The chaining of op+ causes three
temporary QVectors to be created and thrown away.

Instead, use clear() (which preserves the vector's capacity these days),
followed by four op+=.

Change-Id: I300bd35544ea41037d28db0f48f210c33c826b85
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
2017-02-07 09:50:00 +00:00
Friedemann Kleint
4bf0ddb3f1 Fix some qdoc warnings for 5.9
Fix warnings:
src/network/access/qhstspolicy.cpp:158: warning: Undocumented parameter 'expiry' in QHstsPolicy::setExpiry()
src/network/access/qhstspolicy.cpp:178: warning: Undocumented parameter 'include' in QHstsPolicy::setIncludesSubDomains()
src/network/access/qhstspolicy.cpp:178: warning: Can't link to 'includeSubdomains()'
src/widgets/kernel/qsizepolicy.cpp:402: warning: Cannot find 'transposed(...)' in '\fn' QSizePolicy QSizePolicy::transposed()
src/widgets/kernel/qsizepolicy.h:165: warning: No documentation for 'QSizePolicy::transposed()'
src/widgets/util/qundostack.cpp:164: warning: Undocumented parameter 'obsolete' in QUndoCommand::setObsolete()

Fix the signature of the QStaticByteArrayMatcher member functions. The warnings
src/corelib/tools/qbytearraymatcher.cpp:372: warning: Cannot find 'indexIn(...)' in '\fn' QStaticByteArrayMatcher::indexIn(const char *haystack, int hlen, int from)
src/corelib/tools/qbytearraymatcher.cpp:382: warning: Cannot find 'indexIn(...)' in '\fn' QStaticByteArrayMatcher::indexIn(const QByteArray &haystack, int from)
remain, though since apparently qdoc is thrown off by the constructor.

Change-Id: I157359a881ff3fbc80d2eeb52dd5c27249d009c4
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-02-06 16:58:04 +00:00
Marc Mutz
47a275c0ba Un-export QCollator{SortKey,}Private
This is private API, and used nowhere else except in qcollator*,
so don't export these classes.

Change-Id: I217fde97c60ab0a3e19774ed5a6eed8b156fff1d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-06 09:42:35 +00:00