Commit Graph

6956 Commits

Author SHA1 Message Date
Anton Kudryavtsev
6aa935cd92 Use QString::fromLatin1() less to avoid string allocations
QString::fromLatin1 always allocates memory, but there are
cases where we can avoid/reduce allocations or/and reduce
text size, e.g.:

QStringBuilder expressions
Fix: replace QString::fromLatin1 with QL1S

QString::fromLatin1().arg(String) pattern
Fix: replace with QStringBuilder

Overloaded functions with QL1S arg
Fix: replace QString::fromLatin1 with QL1S

In rare cases if there is no overloaded function
with QL1S and we have deal with string literal,
replace QString::fromLatin1 with QStringLiteral.

Change-Id: Iabe1a3cc0830f40ef78a0548afa4368583c31def
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-09-15 15:55:57 +00:00
Anton Kudryavtsev
6b2071c697 Use QStringBuilder more to optimize memory allocations
Change-Id: I2939ffa10496fdc59e0402a9cb54458565ccd657
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-15 09:08:45 +00:00
Lars Knoll
a668c6a6b6 Convert the old feature system
... to the new qmake based configuration system.

This removes the old qfeatures.txt (distributed over configure.json
files) and qfeatures.h (distributed over qconfig-<module>.h files).

qfeatures.prf is gone without replacement, as attempts to use it would
lead to followup errors anyway.

Change-Id: I1598de19db937082283a905b9592d3849d2199d0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-09-15 08:24:10 +00:00
Oswald Buddenhagen
b754b2815d rename description => label in configure.json
"description" suggests something slightly longer.

this may seem like a gratuitous change, but the upcoming replacement of
the old feature system clarifies makes it seem much less so.

Change-Id: Ibe702e01cb146b59127bf1f990b4acaef1c61d55
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-09-15 08:24:00 +00:00
Lars Knoll
2d3c73fcfe Modularize configure.json/.pri
Move the different parts of configure.json/.pri into the libraries where
they belong.

Gui is not yet fully modularized, and contains many things related to
the different QPA plugins.

Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Change-Id: I6659bb29354ed1f36b95b8c69e7fce58f642053f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-09-15 08:23:53 +00:00
Maurice Kalinowski
13d20e4787 winrt: Report system languages for QLocale::uiLanguages
dc3e7e45eb introduced locales from a
packaging perspective, providing the information available from the
package manifest. However, developers are rather interested in the
available and preferred system languages to update user interfaces.

Task-number: QTBUG-55672
Change-Id: I740d4f9c9ca21a8cbd437d3b232470897c569d34
Reviewed-by: Jens Bache-Wiig <jensbw@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2016-09-11 17:15:14 +00:00
Marc Mutz
6549bd383d Optimize Q_FOREACH for rvalues
Add an rvalue overload of the QForeachContainer ctor to allow moving
rvalues into the internal container copy.

This does not change the semantics of Q_FOREACH. It is just an
optimization.

Port to NSDMI to minimize code duplication.

Costs ~1.3KiB across all libraries and plugins in a QtBase Linux
build (optimized GCC 6.1 AMD64).

Change-Id: I180e35ecab68aa1d37773b3546787481bb5515a2
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-09-09 17:19:27 +00:00
Liang Qi
d892e6f721 Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
	mkspecs/features/qt_common.prf
	src/plugins/platforms/windows/qwindowsdialoghelpers.cpp

Change-Id: I03b92b6b89ecc5a8db7c95f04ebb92ed198098a8
2016-09-05 18:47:27 +02:00
Liang Qi
657c2bfbec Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	tests/auto/testlib/selftests/generate_expected_output.py

Change-Id: If856162abf9a24ae2c9946d336a7d1da03520fa7
2016-09-05 13:57:12 +02:00
Thiago Macieira
cec8cdba4d QTextStream: log the defect that op<< uses Latin 1
The rest of Qt, including the QString constructor, uses UTF-8 to
interpret narrow character literals. The fact that QTextStream uses
Latin 1 should be considered a defect.

We can't fix this in Qt 5, so log it for consideration in Qt 6.

Change-Id: I9e96ecd4f6aa4ff0ae08fffd14710fa61673db57
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-09-04 09:21:30 +00:00
Marc Mutz
2a6bea7a55 qcompilerdetection.h: retract Q_COMPILER_DEFAULT_MEMBERS for MSVC < 2015
Earlier versions of the compiler cannot default
move special member functions, even though we
also define Q_COMPILER_RVALUE_REFS for them.

Fix by retracting the less-often-used of the
two compiler feature defines.

Q_COMPILER_DEFAULT_MEMBERS is not used outside
QtBase in neither 5.6 nor 5.7 (5.8 is not
released at this time, so wasn't considered).
The same is true of the dependent macros
Q_COMPILER_DEFAULT_DELETE_MEMBERS and
Q_DECL_EQ_DEFAULT.

In QtBase, the three uses are:
1. in QAtomic*, where the user also requires
   Q_COMPILER_CONSTEXPR, which is not defined
   for any MSVC at this time,
2. for QEnableSharedFromThis, which is a class
   template with an alternative {} implementa-
   tion of the default constructor, and uncon-
   ditional user-defined copy special member
   functions.
3. The test of the corresponding functionality
   in tst_compiler, which this commit amends.

That means that neither of these two only uses
of the macro in Qt libraries are affected by
the change.

The reason we do this change, then, is that in
the future, we want to be able to more easily
restore move special member functions for
classes for which they are suppressed due to
user-defined dtors or copy special member
functions.

Change-Id: I6f88cad66d6b87a758231f16355c3bddae697b86
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-03 05:11:40 +00:00
Marc Mutz
312d08b290 qstrncpy: don't call strncpy_s with invalid parameters
According to https://msdn.microsoft.com/en-us/library/5dae5d43.aspx,
strncpy_s' second argument must not be 0:

> If strDest or strSource is NULL, *or numberOfElements is 0*, the
> invalid parameter handler is invoked.

Move the existing check for len > 0 up to protect the strncpy_s
call, too.

Change-Id: I70d339ea60d4b76f3038b2e4e4756f6590a9bd31
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-03 05:07:54 +00:00
Thiago Macieira
84830fc07d QLockFile::tryLock: prevent over-sleeping in certain cases
The sleep time increases exponentially, but we never checked whether the
time to sleep was less than the remaining time. For example, if timeout
was 4000 ms on entry, we'd progressively sleep 100 ms, 200, 400, 800,
1600 ms. At this point, the accummulated sleep time would be 3100 ms and
the next sleep should be no more than 900 ms.

Prior to this change, the tryLock() would then proceed to sleep 3200 ms,
for a total wait time of 6300 ms, or 57.5% above the timeout provided by
the user.

Change-Id: Ifc295639c8cf4ddcaa69fffd146f7586a7ee95e4
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-30 21:52:04 +00:00
Thiago Macieira
eebdb16c63 QLockFile: Use QDeadlineTimer in tryLock
This simplifies the code a bit.

Change-Id: Ifc295639c8cf4ddcaa69fffd146f7535d646cb15
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-30 21:51:55 +00:00
Thiago Macieira
1a09c599b3 QDeadlineTimer: inline the isForever function
The constructor that sets it is inline already, so there's no point in
hiding this.

Change-Id: I66707fdfe8eb460a9c72fffd146d8dbc35b13056
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-30 18:41:29 +00:00
Gabriel de Dietrich
bc1b45ff9f QSettings: Remove calls to deprecated API on macOS
CFURLCreateDataAndPropertiesFromResource and
CFURLWriteDataAndPropertiestoResource have been
deprecated since 10.9. We replace them with simple
QFile access.

Code cleaning and included.

Change-Id: I19c7ceac41c8c511962f1128bd8e210e3adb434c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-08-30 01:52:53 +00:00
Liang Qi
1cc571593a Merge remote-tracking branch 'origin/5.7' into 5.8
cf53aa21bf and 3aaa5d6b32
were reverted because of reconstruction in 5.7.

defineTest(qtConfTest_checkCompiler) in configure.pri is smart
enough to cover the case in a9474d1260.

DirectWrite: Fix advances being scaled to 0

Since 131eee5cd, the stretch of a font can be 0, meaning
"whatever the font provides". In combination with ec7fee96,
this would cause advances in the DirectWrite engine to be scaled to
0, causing the QRawFont test to fail.

Conflicts:
	configure
	mkspecs/features/uikit/device_destinations.sh
	mkspecs/features/uikit/xcodebuild.mk
	src/corelib/global/qglobal.cpp
	src/corelib/global/qnamespace.qdoc
	src/plugins/platforms/cocoa/qcocoamenuitem.h
	src/plugins/platforms/windows/qwindowsservices.cpp
	src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
	src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
	src/widgets/kernel/qapplication.cpp
	tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
	tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp

Change-Id: I4656d8133da7ee9fcc84ad3f1c7950f924432d1e
2016-08-29 15:30:17 +02:00
Nico Vertriest
6cbd982836 Revert "Doc: removed reference to non-existing method"
This reverts commit 53f0b43a4b.
{QAbstractAnimation::}{updateCurrentValue()} had been modified to
{QVariantAnimation::}{updateCurrentValue()} in a previous patch.

Change-Id: Ibaccf51de816966f16b8f3109e0c20626d5102a8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-26 11:40:11 +00:00
Marc Mutz
d875a04174 QtJson: simplify/add missing relational operators involving Latin1String
As noted by Mat Sutcliffe <oktal3700@gmail.com>, there were
no relational operators for Latin1String/QLatin1String and
String/QLatin1String mixed comparisons, leading to implicit
conversions from QL1S to QString in Entry::op==(QL1S).

This patch fixes half of the issue, by providing the operators
for Latin1String/QLatin1String. In doing so, it cleans up their
definition (non-members, non-friends, delegating to existing
QL1S operators where possible, passing both {Q,}Latin1String by
value, as they're both Trivially Copyable and small).

A follow-up patch will deal with String/QLatin1String
comparisons. It will be not quite as straight-forward as
this patch, since we don't, yet, have QStringView, the
UTF-16 equivalent of QL1S, available.

Amends a5159cc50a.

Change-Id: I596358eb3ccf847b7680f171f9992f3fad80132c
Reviewed-by: Mat Sutcliffe <oktal3700@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-26 08:25:31 +00:00
Nick Shaforostoff
8adad2fe09 fix build with various QT_NO_* defines
Done-with: Andriy Gerasika <andriy.gerasika@gmail.com>
Change-Id: I90883a491dbddb005c3d756c339e42285d50e437
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-26 07:39:53 +00:00
Liang Qi
13680ceb9a Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7 2016-08-25 16:08:09 +00:00
Liang Qi
c7cdf3aac7 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/corelib/mimetypes/qmimeprovider.cpp
	src/corelib/mimetypes/qmimetype.cpp

Change-Id: Ib483ddb6bfc380e7c8f195feca535703814c3872
2016-08-25 16:12:11 +02:00
Ulf Hermann
de7f281d7a QLocale: Fix wrong assert
The endptr from reading the exponent of a 'g' form snprintf result
should not be past the end of the string we're reading from. It has
nothing to do with the 'e' sign.

Task-number: QTBUG-54482
Change-Id: I8bdee917b8d21fdc94c255548ad7e008431a07fa
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-25 12:45:50 +00:00
Marc Mutz
e83f6aaaa6 QMimeProvider: fix quadratic loop
Calling QMutableListIterator::remove() in a loop constitutes quadratic
behavior (O(N) function called O(N) times).

Fix by splitting the loop, simplifying it by sharing conditions, and
using std::remove_if(), which is linear.

Removes one more use of mutable Java iterators.

Change-Id: I88bde414777b50996e546bc8cb238619ea4fb645
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-25 04:14:24 +00:00
David Faure
3e453abc7d QMimeType: use default locale rather than system locale
This makes it possible for the application to control which language
is used by QMimeType::comment()

[ChangeLog][QtCore][QMimeType] QMimeType::comment() now uses the default locale
rather than system locale, so that applications can control which language
is being used.

Task-number: QTBUG-50776
Change-Id: I82623b7c488035a4164fadaf37ebcc79a9fd6173
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-24 20:30:13 +00:00
Raphael Kubo da Costa
680ec54a76 QMutex: Make freelist() return a real global static
Since Qt 5.6.0, some applications such as Kate (built with clang, libc++
and libcxxrt) on FreeBSD occasionally crash with the following error
message on exit:

    QMutex::lock(): sem_wait failure: Invalid argument
    [or pthread_cond_wait in the 5.6 branch]

Investigation by Gleb Popov, Thiago Macieira and Olivier Goffart has
shown that this is caused by the fact that QDBusConnectionManager is a
Q_GLOBAL_STATIC (so it will be destroyed with all the other
Q_GLOBAL_STATICs in the reverse order of construction). In the
Q_COMPILER_THREADSAFE_STATICS case, freelist() also returns a
function-level static that is constructed on first use, so it may be
destroyed earlier than the QDBusConnectionManager object, making it
impossible to lock a contended mutex.

We now make freelist() return a global static, so that it is always
destroyed after QDBusConnectionManager and other function-static
variables.

Change-Id: I210fa7c18dbdf2345863da49141b9a85cffdef52
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-23 15:37:00 +00:00
Christian Strømme
5e3f770ad5 Fix problem with exception reporting in QFuture::waitForResult()
This fixes a problem that occurs when a task, that is run synchronously,
throws an exception. If that happened, then the exception would not be
re-thrown, because of an early return.

Task-number: QTBUG-54831
Change-Id: Ic70c5b810ec6adce6e62bfd6832ba9f170b13a7f
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-08-23 14:55:49 +00:00
Orgad Shaneh
449390c3a5 Revert "QLocale: Actually get the language script for the system locale"
The text direction should *not* be set by the default script, but by the
UI direction.

For example, if the default script is Hebrew, but the UI is in English,
it doesn't make sense to default all the controls to RTL. This should be
done only if the UI is RTL.

This reverts commit a90869861c.

Task-number: QTBUG-53110
Change-Id: I5a6951ac30f24eec86bc0ae2a9fcfe14eb3a8e28
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-23 14:52:31 +00:00
Venugopal Shivashankar
ca979a2f69 Doc: Remove references to Windows CE in Qt Core
The platform is not supported since Qt 5.7

Task-number: QTBUG-55331
Change-Id: I98b90d574d9a76c4281852d93818620b5f489117
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-23 11:06:30 +00:00
Alexander Volkov
4f6f0cd4c9 Bypass a bug in gcc 4.7 for QAtomicTraits::isLockFree()
It's not possible to build Qt with gcc 4.7 since
aca0e367be because of the bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53473 that doesn't
allow to specialize static members declared both as constexpr
and noexcept. That commit was made after 5.7.0 and it introduced
QAtomicTraits::isLockFree() with these specifiers.

Remove the noexcept specifier to fix building.

Change-Id: Ifc2462c90de1180f1e015fdc0646f246d33e68b0
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-23 10:10:38 +00:00
Venugopal Shivashankar
c3bd28de8d Doc: Remove references to Windows CE in Qt SQL and Qt Namespace
The platform is not supported since Qt 5.7.

- Removed Windows CE-specific \notes in SQL drivers' documentation
- Marked a couple of Windows CE-specific enum values using
  \omitvalue

Task-number: QTBUG-55331
Change-Id: I35b44f9d31fde6f10013c043260db1b852c171e2
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2016-08-23 08:28:23 +00:00
Nico Vertriest
53f0b43a4b Doc: removed reference to non-existing method
QAbstractAnimation::updateCurrentValue


Change-Id: I1610591ec43d019ca136df5a01350dc6ca7392ff
Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
2016-08-22 14:20:15 +00:00
Oswald Buddenhagen
d314819fc0 Merge dev into 5.8
Change-Id: I41ee7b50534b01cf042bed8bb8824ba2e5026a29
2016-08-22 11:30:01 +02:00
Marc Mutz
519b8d1a28 QtJson: mark String/Latin1String ctors explicit
An implicit conversion from const char* would be quite unfortunate.
Luckily, the code compiles as-is.

Change-Id: I445f983a27cc25bfaf4285c1a6c5811bd5d201b3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-22 07:43:20 +00:00
Jake Petroules
57378a108c Add support for Apple watchOS
Change-Id: I3f9e00569458a463af2eaa5a3a16a6afd1e9c1ea
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2016-08-19 21:05:55 +00:00
Allan Sandfeld Jensen
9f888d2fde Support C++17 fallthrough attribute
Replaces our mix of comments for annotating intended absence of break
in switches with the C++17 attribute [[fallthrough]], or its earlier
a clang extension counterpart.

Change-Id: I4b2d0b9b5e4425819c7f1bf01608093c536b6d14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-19 18:38:53 +00:00
BogDan Vatra
691dc71a01 Say hello to Q_NAMESPACE
Q_NAMESPACE is useful to add Q_ENUM_NS/Q_ENUMS, Q_FLAG_NS/Q_FLAGS and
Q_CLASSINFO to a namespace.

[ChangeLog] Added Q_NAMESPACE which can be used to add Q_ENUM_NS/
Q_ENUMS, Q_FLAG_NS/Q_FLAGS and Q_CLASSINFO to a namespace

Task-number: QTBUG-54981
Change-Id: Ic61b972794063e77134681fb347d6c4acddcdb44
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-19 15:41:27 +00:00
Lars Knoll
e33a382c33 Add a qeventtransition feature
This replaces the QT_NO_STATEMACHINE_EVENTFILTER define, and
gives it a proper name.

Change-Id: I2b9386458224ff2bd30003daac548daa61961085
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:28:26 +00:00
Lars Knoll
0a070d1e95 Don't use QT_NO_MIMETYPE in mimetypes.pri
Instead define a proper feature for it and use qtConfig().

Change-Id: I64b1d26b2419a24d3239e9935341b7d535990dfb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:28:21 +00:00
Lars Knoll
cf166e5839 iconv-related cleanup in codecs.pri
The configuration system already takes care of setting QT_NO_ICONV.

Also move the platform conditions for using iconv from the pri file
to the .json.

Change-Id: I91b08bcee6799deddabcbb4a91d0a3f9ed7f0f28
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:28:15 +00:00
Lars Knoll
60985aa42b Use qtConfig throughout in qtbase
Use the new qtConfig macro in all pro/pri files.

This required adding some feature entries, and adding
{private,public}Feature to every referenced already existing entry.

Change-Id: I164214dad1154df6ad84e86d99ed14994ef97cf4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:28:05 +00:00
Lars Knoll
606924132f Add support for safe feature checking at compile time
Added a qtConfig(feature) function to qmake, and a QT_CONFIG(feature)
macro. These can safely check whether a certain compile time feature of
Qt is enabled or not.

For this to work the feature has to have a publicFeature or
privateFeature output in the configure.json file.

In pro files, please use the qtConfig(feature) test function
instead of checking contains(QT_CONFIG, feature), as the latter
will be unreliable with the upcoming modularization (it requires a
load(qt_module_config) before doing any such checks). Note that
feature names are now lowercase, and identical (except for hyphens
versus underscores currently) in the pro and c++ files.

This makes the logic easier to follow, as we avoid all double negations,
and most importantly, QT_CONFIG and qtConfig are implemented in a
way that you'll get a build error for a mistyped or non-existent
feature. This will also prevent accidental use of a widget feature
in gui in the future.

This gives us complete symmetry between the handling in pro and
c++ files.

Change-Id: I60404f97953724e639ffb6386cce2e8b1e4b735a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:27:17 +00:00
Lars Knoll
48b4e0bf6f Improve library version handling
Output the version as a define into the private config header as
a define using a hex number. Like that we can easily do version checks
on libraries using the QT_LIBRARY_VERSION(lib) and QT_VERSION_CHECK()
macros.

Change-Id: I6dc4ac6550886ca95c5542b6e75cd933ed079d76
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:27:06 +00:00
Oswald Buddenhagen
de1da50557 make bootstrapped build work entirely without generated headers
instead, the only relevant defines from qconfig.h (QT_VERSION*) are
passed on the command line, like we already did for qmake and
configure.exe.
this enables us to remove the early forwarding header generation from
qtbase.pro, and rely wholly on the regular mechanism from syncqt +
qt_module_headers.prf.
another advantage is that we can be sure that the bootstrapped namespace
is not polluted by the target feature configuration.

Change-Id: If29285cfc697ae56b591e2ff1a2114686d18fb30
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-19 04:26:59 +00:00
Oswald Buddenhagen
4b288e30ef employ QMAKE_USE: LIBS += -lfoo
this switches all instances of LIBS[_PRIVATE] += -lfoo where a config
tests exists for foo.
this removes some code duplication between tests and project files (in
case of conditionals), and ensures that the projects always actually use
the libraries configure has found.

Change-Id: Ia7e80c8db5f329290c7f1a4e03a8bf78882a687e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-19 04:26:43 +00:00
Oswald Buddenhagen
d5dc46d319 employ QMAKE_USE: LIBS += $$QMAKE_LIBS_FOO
this migrates the cases where the build system already made (some) use
of variables (possibly) set by configure.

Change-Id: I43a08caed481d5f887a3a40821e71a4797760e7e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-19 04:26:36 +00:00
Liang Qi
0ca4fcbc36 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/plugins/platforms/xcb/qxcbintegration.cpp

Change-Id: I2d71d06a55f730df19ace0dd3304238584a0497f
2016-08-18 11:07:51 +02:00
Anton Kudryavtsev
1075f6c764 Use QStringRef to optimize memory allocation
Replace substring functions that return QString
with corresponding functions that return QStringRef.

Change-Id: I3c485f89352a1ee66076fba74fd486da9349c354
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-08-18 07:29:37 +00:00
Dyami Caliri
ecb73a7bb3 QJsonValue: use Q_NULLPTR instead of 0 in ctor
Use Q_NULLPTR in all public headers

Task-number: QTBUG-45291
Change-Id: Ib294deb3c210a9a186448cbf9656af7a09fea2c1
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-17 19:54:40 +00:00
Friedemann Kleint
e4bb9395c2 Standardize some "We mean it" comments
Fix the occurrences where the wrong classes are mentioned.

Change-Id: Ia291af77f0f454a39cab93e7376a110c19a07771
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-17 19:51:40 +00:00
Anton Kudryavtsev
b0dba5b874 QMimeData: use QStringBuilder more
Change-Id: I5a6937545561c51add0d48a618b1921cf9201c4b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-17 19:44:02 +00:00
Marc Mutz
253d2e5135 QLinkedList: restore move special member functions for iterators
They were masked by the pointless user-defined copy special member
functions, which we cannot remove because it would change the way
the iterators are passed by value into functions, on some platforms.

Add a reminder for Qt 6 to fix the issue for good.

Change-Id: I039093894db4a4e5e4bbf94fb346fd90311316c0
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-17 08:59:06 +00:00
Anton Kudryavtsev
8617ce5c88 Use QStringRef() more, exploiting its new ::chop()
Change-Id: Id2201639be604b9a32b2dc5d21e675a961bee477
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-16 20:08:31 +00:00
Friedemann Kleint
ff00b2efbd Add " We mean it" comment to qdeadlinetimer_p.h
Fix warning:
QtCore: WARNING: qtbase/src/corelib/kernel/qdeadlinetimer_p.h does not have the "We mean it." warning

Amends change 12eacc3bab

Change-Id: Ibb8fd25cee0249380996ae271200055e131d359b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-16 15:46:20 +00:00
Friedemann Kleint
ff68be114e Fix documentation of the Windows parts of QSettings::setPath()
Explain in terms of CSIDL_ values and update the sample locations.

Task-number: QTBUG-55065
Change-Id: I15ddf32555d43cffae66d98c6ac12d62a98d5e6d
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-16 13:51:16 +00:00
Marc Mutz
6d95497931 QLinkedList: compile with -Wzero-as-null-pointer-constant
The existing header check unfortunately doesn't detect uses of
'0' as nullptr in template code.

Task-number: QTBUG-45291
Change-Id: Ibe701402d95deca98c5286e2cee5f7118fd7f606
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-16 13:36:15 +00:00
Giuseppe D'Angelo
8dc45d5b7c Deprecate Q(Persistent)ModelIndex::child
Due to how invalid model indices are handled in Qt, child() is unsuitable
for general purpose usage. In particular you can never get a top level
item in the model because the root model index by definition hasn't got
a pointer to the model it belongs.

That makes child() useless for anything but tree models (and even there
you'd need to special case your code anyhow).

[ChangeLog][QtCore][QModelIndex] QModelIndex::child has
been deprecated due to its lack of generality.
Use model->index(row, column, index) instead.

[ChangeLog][QtCore][QPersistentModelIndex] QPersistentModelIndex::child has
been deprecated due to its lack of generality.
Use model->index(row, column, index) instead.

Change-Id: Ice73c17133aaf71355fa2af1eacfe64da01bd456
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-16 11:07:03 +00:00
Liang Qi
17198e03ab Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	qmake/doc/src/qmake-manual.qdoc
	src/corelib/global/qglobal.cpp
	src/corelib/tools/qstring.cpp
	src/network/socket/qabstractsocket.cpp
	src/network/socket/qnativesocketengine_unix.cpp
	src/plugins/platforms/eglfs/api/qeglfsglobal.h

Change-Id: Id5dfdbd30fa996f9b4b66a0b030b7d3b8c0ef288
2016-08-16 07:58:32 +02:00
Marc Mutz
6e2af81daf QMetaType: clean up #ifdefs
We require Q_COMPILER_VARIADIC_TEMPLATES since Qt 5.7,
so remove the non-variadic version which anyway has
zero test coverage.

Change-Id: I24dd22a798e11d797238f9209312802d1d84a672
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-15 16:56:01 +00:00
Marc Mutz
7b5d14c699 QFactoryLoader: clean up #ifdefs
We require Q_COMPILER_RVALUE_REFS (implicitly used, but not explicitly
checked for) and Q_COMPILER_VARIADIC_TEMPLATES since Qt 5.7, so remove
the non-variadic version which anyway has zero test coverage.

Change-Id: Ie3658ff6ae71a66df9d35100c3d6df41f2326c80
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-15 16:55:58 +00:00
Marc Mutz
2889ebc903 QSharedPointer: clean up #ifdefs
We require Q_COMPILER_RVALUE_REFS and _VARIADIC_TEMPLATES since Qt 5.7,
so remove the non-variadic version which anyway has zero test coverage.

Also drop #include <utility>, as that is included from qglobal.h already,
and drop QSKIP from test.

Change-Id: I1fc7f7068eac80ad6fd85e1d8f6d33c5c7bb67db
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-15 16:55:45 +00:00
Thiago Macieira
12eacc3bab Long live QDeadlineTimer
It's like QElapsedTimer, but marks a time in the future instead.

[ChangeLog][QtCore] Added QDeadlineTimer, a counterpart to
QElapsedTimer, used to mark a time point in the future (a deadline) and
determine whether such a deadline has passed.

Change-Id: Ifea6e497f11a461db432ffff144921f7fbc1d1d3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-15 03:07:16 +00:00
J-P Nurmi
906fc0f5e3 Add Q_DECLARE_OPERATORS_FOR_FLAGS(QStandardPaths::LocateOptions)
QStandardPaths::LocateOptions was declared with Q_DECLARE_FLAGS(),
but missing Q_DECLARE_OPERATORS_FOR_FLAGS().

Change-Id: Id4ab1b1c86cdc9e79fb324d9b9d4d8deb659f718
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-14 18:43:48 +00:00
J-P Nurmi
af87bf4b14 Register QStandardPaths enums & flags
This allows QML StandardPaths to use the same enums without having to
duplicate them.

Change-Id: Ibfc63a97a8ba31e5c4dc11e3e8fee9d753087c54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-14 12:41:49 +00:00
Marc Mutz
9c016cefe9 QFuture(Interface): remove unneeded special member functions
The compiler-generated ones are just fine.

This is BC because the class is not exported and
QFutureInterfaceBase (needlessly) contains virtual
functions (the dtor), so this class will never be
trivially copyable. It's also not movable, until I
figure out how to add move special member functions
to QFutureInterfaceBase.

Also made the QFutureInterface(State) constructor
explicit, because a State is not a faithful
representation of a QFutureInterface.

Change-Id: Ifa44f87b41c4ee3c5167c282512ec4860075671d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-13 05:34:51 +00:00
Liang Qi
6b8f422c5e Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/corelib/global/qglobal.cpp
	src/corelib/io/qsettings.cpp
	src/corelib/itemmodels/qstringlistmodel.cpp
	tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp

Change-Id: I1c6c306ef42c3c0234b19907914b19da706b4a03
2016-08-13 01:05:02 +02:00
Frederik Schwarzer
b6fb349ad5 Fix typo (word repetition) in documentation
Change-Id: I1c8785e39f28f94846126fc45b875e6425a4ce12
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-12 10:41:53 +00:00
Topi Reinio
a2ae631c04 Doc: Change instances of '(Mac) OS X' to 'macOS'
As of version 10.12 (Sierra), the name of Apple's desktop operating
system will be macOS. Change the occurrences where the Mac platform
is discussed to use a macro \macos, which expands to 'macOS'. This
helps with adapting to future renaming.

Update the instructions on mac-specific Q_OS_* macro usage.

Add a \target for the old 'Qt for OS X' topic to keep links working
for other documentation modules that try to link with the old name.

Change-Id: Id33fb0cd985df702a4ae4efb4c5fd428e77d9b85
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2016-08-12 08:30:29 +00:00
Marc Mutz
b57f743c46 QStringListModel: fix dataChanged's roles parameter
In QStringListModel, the display and the edit roles are synonyms,
so when one is changed, the other changes with it. However, in
setData() we only emitted a vector with just the role that was
passed in by the user.

Fix by always passing both roles, regardless of which one was used
to set the data.

Change-Id: I498e7cb33796fae266901817b01ad85d861d4bb4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-12 08:27:53 +00:00
David Faure
4e24ff2e68 QCommandLineParser: call qCoreApp post routines before ::exit()
This gives a chance for some cleanups at least.

Change-Id: I3a628e32c6fc8c7fa00943769210c517005f2a0a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-12 08:26:59 +00:00
Kai Koehne
7c5ccdd83b Add list of 3rd party code attributions to Qt Core, Qt GUI, Qt SQL
Also document the current license the modules are available from,
since this is not consistent anymore across Qt.

Task-number: QTBUG-55139
Change-Id: I117fdb0cda7bd7ff92aa825e29c28f22a8a2f96d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-12 06:55:08 +00:00
Morten Johan Sørvig
b0abe20d4b Darwin: Add QImage::toCGImage() conversion function
(Move QT_FORWARD_DECLARE_CG to qglobal.h)

This function converts to CGImage for supported formats. This
is done by creating a CGImageRef that reuses the QImage data.

The CGImage and QImage ref counting systems are bridged, implemented
by using CGDataProvider that holds a copy of the QImage.

Unlike the previous internal implementation this public version
does not implicitly convert unsupported formats to ARGB32_Premultiplied.

See included documentation for the complete description.

Change-Id: Ie3984a7a8331e02a6f1c42943caaf76854e93538
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
2016-08-11 21:21:05 +00:00
Anton Kudryavtsev
5d1c35e21d QTranslator: use const to avoid detach()'ing
Change-Id: Idbab696affed9486e9077d72ba14ce409b98174c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-11 18:20:25 +00:00
Edward Welbourne
6c473b7e08 QDateTimeParser::getAmPmText() use QLocale instead of tr()
I am not convinced toUpper/toLower is a generally sound solution here;
however, QLocale doesn't make the upper/lower case distinction this
parser does and a bug report shows tr() isn't doing an adequate job.

Task-number: QTBUG-47815
Change-Id: Iaf654d1d76d4c38d74fc647e168d50debb924a8f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-11 08:12:04 +00:00
Liang Qi
8ba384a564 Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I1a63523de158757964b6fb5ea026cf69a6c5ddcf
2016-08-10 17:43:13 +02:00
Thiago Macieira
c35fef9d3b Fix qnumeric_p.h with ICC's supplied math.h
ICC supplies a math.h header that defines things like:
 #define isnan( __x__ )      __IMFC99MACRO1ARG_ALL( __x__, isnan,      __, f, __,  , __, l)

So use the already-existing workaround for it.

Since Qt 5.7 requires C++11, we can remove the check for that.

Change-Id: I149e0540c00745fe8119fffd1463cc5caf341337
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-10 06:42:43 +00:00
Liang Qi
22e96c4d34 Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: I36e6b890b65d12bf6931757540bcc9c553b5eb8f
2016-08-09 17:59:51 +02:00
Thiago Macieira
e24f89f266 Fix build with clang-cl and the Intel compiler on Windows
Neither clang-cl nor the Intel compiler are able to parse the MSVC code
in a constexpr environment. For Clang, we can just use the __builtin
functions, which it does make available on Windows. For the Intel
compiler, there's no alternative, so we just don't use the _BitScanXxx
functions. It will produce slower code, though.

qalgorithms.h(587,19) :  error: variables defined in a constexpr function must be initialized
qalgorithms.h(635,12) :  note: non-constexpr function '__popcnt' cannot be used in a constant expression

etc.

Change-Id: I149e0540c00745fe8119fffd14627ded43807000
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-09 02:41:19 +00:00
Giuseppe D'Angelo
874852d625 QMap: remove statement about STL support during Qt's own configuration
Since STL support is mandatory in Qt 5, the sentence is a tautology
and can be removed.

Change-Id: I8676368cc917aa00a85b1113ed2a47694427b2ce
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-07 07:43:29 +00:00
Marc Mutz
009f1f2812 QString: fix regression comparing null QString with null const char *
Commit 4a40c717f3 optimized
QString::compare_helper(QChar*, int, char*, int), but got
the case wrong where the rhs is null, but the lhs is empty,
not null (which is the case even with a null QString, as
QString().constData() != nullptr). The correct result in
this case is 0, since in Qt empty and null strings compare
equal.

Fix by checking the length of lhs, not its pointer.

Task-number: QTBUG-55154
Change-Id: I3ec2cd25d9bdca90cf3f5568a875b1e52c779979
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-05 18:52:16 +00:00
Christian Kandeler
4b63ab9a93 QJsonValue::toVariant(): Differentiate between null and invalid
Both were mapped to QVariant() before. Instead, use a null pointer
QVariant for a null JSON value.

[ChangeLog][QtCore][QJsonValue] QJsonValue(Null).toVariant() now returns
a QVariant of type QMetaType::Nullptr instead of an invalid QVariant.

Task-number: QTBUG-43077
Change-Id: Ife611f418583dbff542210bc8c5cd65201212a6e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-08-05 14:53:33 +00:00
Simon Hausmann
131b7c8f64 Fix permissions on lock files on Unix
We should create the files with 0666 and let the umask take care of adjusting
to the final permissions in the file system.

[ChangeLog][QtCore][QLockFile] Fixed permissions on lock files on Unix to
allow for adjustments via umask.

Change-Id: Iee6a6ac3920d0ffd4465f54ac6e955f7fe087173
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-05 14:27:04 +00:00
Liang Qi
69ef0481fc Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp

Change-Id: I6f3878b204464313aa2f9d988d3b35121d4d9867
2016-08-05 08:58:48 +02:00
David Faure
91a2c8630b QUrl::resolved: keep treating file:name.txt as relative for now
8a33077 made QUrl::resolved() follow its documentation ("If relative
is not a relative URL, this function will return relative directly.",
where relative means scheme is empty).
However there is much code out there (e.g. qtdeclarative) which relies
on QUrl::fromLocalFile("fileName.txt") to be treated as relative, so
for now, we still allow this (in Qt 5.6.x). For Qt 5.8, this commit will
be reverted.

[ChangeLog][QtCore][QUrl] [EDITORIAL: replaces 8a33077] QUrl::resolved()
no longer treats a URL with a scheme as a relative URL if it matches
this URL's scheme. For now it still treats "file:name.txt" as relative
for compatibility, but be warned that in Qt 5.8 it will no longer
consider those to be relative. Both isRelative() and RFC 3986 say that
such URLs are not relative, so starting from Qt 5.8, resolved() will
return them as is.

Change-Id: Iff01e5b470319f6c46526086d765187e2259bdf5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-04 19:55:30 +00:00
Anton Kudryavtsev
9c8a8e90a6 QString: fix append(const QStringRef &str)
Use QStringRef::isNull instead of QStringRef::string()
for validation. Non-NULL str.string() may yet leave us
with a useless str.unicode(), which is the actual problem here;
whereas !str.isNull() does really confirm that str.unicode()
is sensible.

Such test prevents situation like:

const QString a;
QString b;
b.append(a); // b.isNull() == true
b.append(QStringRef(&a)); // b.isNull() == false

Auto test updated: create QStringRef from QString directly, without
any condition.

Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-04 19:55:04 +00:00
Anton Kudryavtsev
955b2bdfc0 QString: de-duplicate code of variants of lastIndexOf()
Re-use methods of QStringRef.

Change-Id: I0f79ee6767653c694ac6a342263c046a5f5f3baa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-04 15:46:12 +00:00
Marc Mutz
4a40c717f3 Optimize QString::compare_helper(QChar*, int, char*, int, cs)
... by using the recently-added QUtf8::convertToUnicode()
and a QVarLengthArray instead of QString::fromUtf8().

Like elsewhere in QString, use a QVarLengthArray<ushort>
instead of the more natural <QChar> to avoid instantiating
another QVLA.

Assume that length2 is usually set to a non-negative value.
Not because that's necessarily the frequent case, but
because a negative length2 leads to an expensive strlen,
that usually dwarfs the additional branch cost.

Check for data2 == nullptr early to avoid having to check
it later twice.

Change-Id: I04bda44ed857451efdf04c3283b5726480dd8c0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-04 09:28:41 +00:00
Jędrzej Nowacki
31520c4fc0 Add missing include in qeventloop_p.h
The code depends on qApp to be visible in the scope

Change-Id: Ibeb54c90f5a65f441e9eb90b848952b955c71f0d
Reviewed-by: Jesus Fernandez <jesus.fernandez@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-04 08:47:52 +00:00
Marc Mutz
ed38f516bf QStringListModel: begin/endResetModel() are no signals
... so don't use emit on them.

Just confuses readers.

Change-Id: I24365fc533b5b35f8942d6014dbc68387aa23e22
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-08-03 12:10:00 +00:00
Jędrzej Nowacki
d7132c6c6d Add std::nullptr_t as builtin type in QMetaType
Change-Id: If6c484bc89a2610c6a9e3e7bd54ef85ef40a783f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-08-03 11:49:28 +00:00
Alex Blasche
958bc5793f Add QtAndroidPrivate::context()
This simplifies the retrieval of the correct Context object.

Task-number: QTBUG-55102
Change-Id: I303bc5393a7900ceb4bde36e711938f3f49075c1
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2016-08-03 11:49:27 +00:00
Clemens Sielaff
2a24c3c268 Fixed Bug in QVariant comparison when containing QStringLists
As it were, QStringLists were not handled explicitly when comparing
QVariants. If both QStringLists contained only a single entry, they
were treated as QStrings - if both QStringLists were empty, there were
equal (correctly so) - but if one of the QStringLists had more than
one entry, the compare function fell through to returning always 1.
As discussed here:  https://stackoverflow.com/a/38492467/3444217

Added rich comparison tests for all non-numerical, non-recursive
QVariants that support them (except QModelIndex and
QPersistentModelIndex)

Task-number: QTBUG-54893
Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-08-03 11:16:35 +00:00
Giuseppe D'Angelo
c0637c0298 QObject::connect: allow to disable narrowing of the connection arguments
One of the good features of the new connection style is that
implicit conversion is performed for the connection arguments.

However, this is also a bad feature when it comes to the old
C remnants in the C++ language: for instance, doubles implicitly
convert to ints, possibly losing precision (and GCC/Clang do not
even warn about those under -Wall, only MSVC does) or even
triggering undefined behavior.

For this reason, when using braced initialization, C++11
disables narrowing conversions or floating/integral conversions.
Use this feature when checking the arguments of a PMF-style
signal/slot connection. Technically this makes the program
ill-formed, however GCC still accepts it (but at least
warns under -Wall).

Hence, add a way to disable these implicit conversions.
This is a opt-in and guarded by a macro, as it's a source
incompatible change.

[ChangeLog][QtCore][QObject] The
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT macro has been added.
When using the new connection syntax (PMF-based) this macro
makes it illegal to narrow the arguments carried by the signal,
and/or to perform floating point to integral implicit
conversions on them. When the macro is defined,
depending on your compiler a QObject::connect() statement
triggering such conversions will now fail to compile.

Change-Id: Ie17eb3e66ce0cd780138e60d8bb7da815a4ada83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-02 23:03:15 +00:00
Edward Welbourne
879fd5bb5c QTzTimeZonePrivate: skip redundant check, tidy up
Various transition functions checked on m_tranTimes.size() > 0 inside
a block which was conditioned on this already; simplify the code by
knowing this is true already.  Tidied up an initializer at the same
time.

Change-Id: I3e933a69e1b71b94bfd4451e4d761844da669d33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-02 08:57:21 +00:00
Edward Welbourne
f6fc34294f Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	configure
5.7 now supports clang on android; but dev re-worked configure

	src/gui/kernel/qevent.h
One side renamed a parameter of a constructor; the other added an
alternate constructor on the next line.  Applied the rename to both
for consistency.

	tests/auto/tools/moc/tst_moc.cpp
Each side added a new test at the end.

	.qmake.conf
Ignored 5.7's change to MODULE_VERSION.

	configure.json
No conflict noticed by git; but changes in 5.7 were needed for the
re-worked configure to accommodate 5.7's stricter handling of C++11.

Change-Id: I9cda53836a32d7bf83828212c7ea00b1de3e09d2
2016-08-01 18:20:00 +02:00
Olivier Goffart
49c8923282 QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signal
We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might
be filtering extra items.

The documentation of QAbstractItemModel::LayoutChangeHint states:

    Note that VerticalSortHint and HorizontalSortHint carry the meaning that
    items are being moved within the same parent, not moved to a different
    parent in the model, and not filtered out or in.

And some of the views rely on this assumption (QQmlDelegateModel for example)

What happens in the test is the following:
- 'model' emit the dataChanged signal when its data is changed.
- 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward
  the dataChanged signal imediatly, it will instead first re-sort the model and
  call layoutAboutToBeChanged / layouChanged with the VerticalSortHint
- 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in
  QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping
  which will cause the changed data to be filtered.
So proxy2 can't forward the VerticalSortHint as it removed rows in the process.

Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-01 14:08:15 +00:00
Liang Qi
3cb7302480 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/widgets/itemviews/qabstractitemview.cpp
	src/widgets/itemviews/qabstractitemview_p.h

Change-Id: I54589b1365103cb1749186af92aab03a49c94b64
2016-08-01 10:03:21 +02:00
David Faure
f2995ee078 QWaitCondition: add notify_one/notify_all, i.e. STL naming
This makes the API more consistent with the STL, which helps discovering
the API. Much like QVector has push_back etc.

Change-Id: I75f6b77ab94233c15e17f66605f4bf13aa03e61c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 12:10:29 +00:00
Konstantin Shegunov
f0685992a3 Docs changed to reflect that valueName is required with value parsing
When the option expects a value the valueName parameter of the
constructor isn't optional; it must be set. This requirement is made
explicit in the documentation.

Task-number: QTBUG-54855
Change-Id: I190884aff2fa8e96bc5c5e82cdfed85be761d6e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-07-29 21:18:07 +00:00
David Faure
8a33077853 QUrl: fix resolved() for data URLs
They look relative because the path doesn't start with a '/' but they
have a scheme so they shouldn't be combined as if it was one absolute
and one relative URL.

[ChangeLog][QtCore][QUrl] QUrl::resolved() no longer treats a URL with
a scheme as a relative URL if it matches this URL's scheme. This special
casing was incompatible with RFC 3986 and broke resolving data: URLs,
for instance.

Change-Id: I3758d3a2141cea7c6d13514243eb8dee5d510dd0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-29 17:51:51 +00:00
Denis Kormalev
f24cc53cc2 Fix for race condition in signal activation
There was a race condition between QObject::disconnect() and
QMetaObject::activate() which can occur if there are multiple
BlockingQueued connections to one signal from different threads and
they connect/disconnect their connections often.

What can happen in this case is:
T1 is in activate() method and T2 is in disconnect() method

T1                          T2
locks sender mutex
selects next connection
unlocks sender mutex
                            locks sender mutex
                            sets isSlotObject to false
creates QMetaCallEvent      derefs connection
posts event

Two things can happen here:
1. Connection can still be valid, but it will have isSlotObject==false
and callFunction will be used instead of slotObj
2. Connection can already be invalid

To fix it mutex unlock should be moved after QMetaCallEvent creation.

Also there is another case, when we don't disconnect but delete the
receiver object. In this case it can already be invalid during
postEvent, so we need to move mutex unlock after postEvent.

Change-Id: I8103798324140ee11de5b4e10906562ba878ff8b
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-29 06:09:22 +00:00
David Faure
4790ccfa7a Fix gcc -Wsuggest-override warning on Q_OBJECT
Same reasoning as commit 3092bd5 (which was for Clang), but for gcc >= 5.1.

Change-Id: I123b17670c1a64876b01fd39fb11648fa4e8b1fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-28 23:43:16 +00:00
David Faure
f5af4428c3 QVector: fix crash on reserve(0)
It crashed when d was equal to Data::unsharableEmpty().

Task-number: QTBUG-51758
Change-Id: If9f2a7d11892507135f4dc0aeef909f59b7478fc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-07-28 13:50:38 +00:00
David Faure
c9354429dd QSocketNotifier: improve warning to show thread names and pointers.
Much like the QObject::setParent() warning, which helps a bit when debugging.

Change-Id: I2abf277a12aa1ce04bd8b5759f46f8bfdcb25383
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-28 12:03:47 +00:00
Alex Trotsenko
75a9bd2a4f Introduce SCTP sockets support
Add protocol-specific code and the QSctpServer, QSctpSocket classes.

Change-Id: Ie9a1d87bd1fda866a2405043d1c15c12ded5a96e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-27 06:37:24 +00:00
Olivier Goffart
c5a4b093d0 Add QMetaEnum::isScoped to be able to destinguish C++11 enum class
Change-Id: I67b1dbd069fa57bd60e50690abb5d876edc0d1d2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-26 22:49:31 +00:00
Mitch Curtis
d9831a03ca Fix grammar error in QFlags documentation
Change-Id: I1c5d2be402f7e194eaa2e6f646aa5edad1bfd9d9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-26 11:50:47 +00:00
Edward Welbourne
6c5de416c9 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/corelib/io/qtemporarydir.cpp
One side encapsulated a repeated piece of #if-ery in a local define;
the other added to the #if-ery.  Made its addition to the other's.

	src/corelib/kernel/qeventdispatcher_unix_p.h
One side moved some members into a struct; this collided with a #undef
check that neither side now has.  Discarded the #undef part.

	src/gui/opengl/qopengltexturehelper_p.h
5.7 deleted a bunch of methods; not clear why merge got confused.

	src/tools/moc/moc.cpp
One added a name to the copyright header; another changed its URL.

Change-Id: I9e9032b819f030d67f1915445acf2793e98713fa
2016-07-26 10:43:29 +02:00
Giuseppe D'Angelo
25d6f312ac qFatal: unify the code path for aborting via std::abort
[ChangeLog][QtCore][Important behavior changes] qFatal will now
use std::abort to terminate the application on all operating
systems. Previously, ::abort() or ::exit(1) were called, depending
on the operating system.

Change-Id: I43da912cce1db3c2229568da25000ea80060eed9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-25 22:18:49 +00:00
Giuseppe D'Angelo
a594f85d54 Q(Basic)Mutex: add try_lock{,_for,_until} for STL compatibility
Now QBasicMutex is Lockable and QMutex is TimedLockable, which means they can
be used in std::lock_guard, std::unique_lock, std::lock, etc.

[ChangeLog][QtCore][QMutex] QMutex now fully models the TimedLockable
concept by providing the try_lock, try_lock_for and try_lock_until
functions, therefore making it usable in Standard Library lock
management classes and functions.

Change-Id: I7c691481a5781a696701e1ab78186b5cefbd6a87
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-25 13:10:07 +00:00
Thiago Macieira
726c8ca0de Work around ICC bug about shadowing declarations that aren't shadowing
Known ICC bug, still present in version 17 beta.

qdatetime.h(126): error #3280: declaration hides member "QDate::jd" (declared at line 136)

Obviously a parameter to static function or to a function in a nested
class can't shadow an NSDM.

Intel issue IDs: 0000698329 / DPD200245740
Change-Id: I149e0540c00745fe8119fffd1463c679a3a9c8c3
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-24 05:27:53 +00:00
Alex Trotsenko
3c6a7a96ef QRingBuffer: add packet mode
As a special case, setting the value of chunk size to zero forces
QRingBuffer to produce a separate QByteArray on each call which
appends the data. So, this enables a packet mode where portions of
data are stored independently from each other.

Change-Id: I2d0b331211901a289da7d4533e974f06830b5590
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-23 09:05:13 +00:00
Alex Trotsenko
3605fc653b QRingBuffer: allow to change the chunk size of the buffer dynamically
Change-Id: I0ac55713c7bb8c48d2c9c774376543caef781980
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-23 09:05:04 +00:00
Oswald Buddenhagen
dd59118b87 move c++11 test into qcompilerdetection.h and make it stricter
it positively makes no sense to have a configure test which will be
never reached due to the configure/qmake bootstrap failing with a
slew of totally unhelpful error messages.

pre-standardization partial c++11 implementations are now rejected,
except for VS2013, which is still sufficient despite not announcing full
compatibility.

Change-Id: I58af10e03960af06b80cedac105cf8433f7a1745
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-22 10:21:36 +00:00
Edward Welbourne
601019e3f4 Merge "Merge remote-tracking branch 'origin/5.7' into dev" into refs/staging/dev 2016-07-22 10:15:48 +00:00
Thiago Macieira
b5153d5bfa Windows: Disable unsupported C++11 features with Clang-cl and ICC
Whenever someone installs Clang or the Intel compiler on Windows, it's
very likely that the compiler will be much newer than the MS headers
that came with the installed Visual Studio version. So let's make sure
we disable the C++11 features that the MS headers don't support
properly.

For example, MS's <limits> header supplied with VS 2013 doesn't mark the
max() function as constexpr, resulting compiler errors in uses of that
function in Qt code declared with Q_DECL_CONSTEXPR:

qdeadlinetimer.h(62,13) :  note: non-constexpr function 'max' cannot be used in a constant expression
        : s(std::numeric_limits<qint64>::max()), ns(0), type(type_) {}
            ^

Change-Id: I149e0540c00745fe8119fffd146286ffe480d216
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-22 01:01:48 +00:00
Friedemann Kleint
0696566b1e Windows: Fix truncation in QFSFileEnginePrivate::nativeWrite()
The number of bytes to write was converted to a 32bit unsigned value,
causing losses. Change the type to qint64 and adapt the code determining
the block size.

Task-number: QTBUG-54870
Change-Id: I294da5bfe97c7e60f67228399e1244a1aba4c89c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2016-07-21 08:50:01 +00:00
BogDan Vatra
e6034a4740 Make sure JNI_OnLoad is not called more than once
Since Android 5.0 Google introduce a nasty bug[1] which calls
JNI_OnLoad more than once.
Basically every time when a library is loaded JNI_OnLoad is
called if found, but it calls *again* JNI_OnLoad of its .so
dependencies! So, JNI_OnLoad of libQt5Core.so gets called may times,
this is not a problem as long as it's called from Qt's java delegate
class loader. The problem is that the application .so file *must* be
called from default class loader to allow the user to find his custom
Activity/Service stuff.


[1] Workaround https://code.google.com/p/android/issues/detail?id=215069

Change-Id: Ia71209658ef56056b560018597608acf7cb0f9ea
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2016-07-20 14:33:31 +00:00
Simon Hausmann
494ced1329 Improve precision of reported file times on Unix-style platforms
Instead of reporting the file times in the precision of seconds, our API allows
us to report it up to millisecond precision.

Change-Id: I8bcc6a1fb4116e8c5421d650a68f6fb00482e551
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-20 12:35:30 +00:00
Friedemann Kleint
c14c149b51 Fix QTemporaryDir to handle Unicode characters on Windows
For platforms not providing mkdtemp(), QTemporaryDir relied on an implementation
of q_mkdtemp() operating on char *, converting back and forth using
QFile::encodeName()/decodeName() when passing the name to QFileSystemEngine.
This caused failures on Windows (which uses "System"/Latin1 encoding)
for names containing characters outside the Latin1 space.

Reimplement q_mkdtemp() to operate on QString, which avoids the conversions
altogether and also enables the use of larger character spaces for the
pattern.

Add tests.

Task-number: QTBUG-54810
Change-Id: Ie4323ad73b5beb8a1b8ab81425f73d03c626d58a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-20 07:31:18 +00:00
BogDan Vatra
cc119dee73 Workaround clang explicit specializations function templates export bug
Should be reverted when https://github.com/android-ndk/ndk/issues/34 is fixed

Change-Id: Ic7fe394412afc25082a9689da59d36cba8b3dade
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2016-07-20 07:06:37 +00:00
Alex Trotsenko
902a5e7aaa QDataStream: adjust containers' deserialization in transaction mode
If an error occurs during the transaction, we should prevent the
containers from being successfully read. So, check the status of the
stream before reading the container, because the deserialization
procedure temporarily resets it on entry.

Task-number: QTBUG-54022
Change-Id: Ie955c2fa3e449374f0f8403f00e487efa2bfdaf3
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-20 06:52:43 +00:00
Thiago Macieira
ea582cdcbf Work around Apple defining "check"
The header says they'll stop doing that in the next release. It's been
like that since at least the OS X 10.8 SDK...

Change-Id: Ib57b52598e2f452985e9fffd14585d4838dc8b09
Reviewed-by: Richard J. Moore <rich@kde.org>
2016-07-20 06:49:53 +00:00
Thiago Macieira
da04322b4c Make moc obey the preprocessor environment variable for include paths
C preprocessors augment their standard list of include paths from the
environment: Unix preprocessors use $C_INCLUDE_PATH (for C) and
$CPLUS_INCLUDE_PATH (for C++), plus CPATH for both, whereas MSVC uses
the an environment variable simply called "INCLUDE". Handling this for
MSVC is particularly important because the VCVARSALL.BAT script sets the
necessary #include paths in the environment for important things.
Without that being parsed, moc won't find some #defines, like
WINAPI_DESKTOP_FAMILY.

[ChangeLog][moc] qmake and moc now cooperate to use the Visual Studio
environment variables (set by the VCVARSALL.BAT script) to find system
include files. A possible consequence is that moc parses application
headers slightly differently, depending on #if conditions that depended
on macros that previous versions had not seen #define'd. Implementers of
other buildsystems are advised to pass the --compiler-flavor=msvc option
to moc.

Change-Id: I7e06274214d1939b0124e5b4bf169cceaef9ca46
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-20 02:54:09 +00:00
Thiago Macieira
9467bdc909 Update QLibrary's debug output when loading failed
We were printing 'loaded library "xxx"' even when ret == false, which
was misleading. So instead print the error string.

Change-Id: Ib57b52598e2f452985e9fffd1459ea860ed2dfcf
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-07-20 00:41:29 +00:00
Jake Petroules
23bf3da5a0 Extend PLATFORM_SDK_EQUAL_OR_ABOVE and DEPLOYMENT_TARGET_BELOW macros
There is now a DARWIN version for all four Apple platforms at once,
a MACOS_IOS version for macOS and iOS (since many of the checks we need
are prior to tvOS or watchOS's existence), and MAC and OSX have been
relegated to synonyms for MACOS_IOS and MACOS, respectively.

Change-Id: I54f587e26c6b46bf4b469c5d3039086c65566651
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
2016-07-19 20:54:07 +00:00
Edward Welbourne
782ebeada1 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	qmake/library/qmakebuiltins.cpp
	qmake/library/qmakeevaluator.cpp
	qmake/library/qmakeevaluator.h
	qmake/project.h
QMakeEvaluator:
* evaluateConditional(): one side changed return type, the other
  changed a parameter type.
* split_value_list(): one side changed a parameter adjacent to where ...
* expandVariableReferences(): ... the other killed one overload and
  changed the survivor

	src/corelib/io/qlockfile_unix.cpp
One side changed a #if condition, the other moved NETBSD's part of
what it controlled.

	src/corelib/tools/qdatetime.cpp
One side fixed a reachable Q_UNREACHABLE in toMSecsSinceEpoch(), the
other moved it from the private class to the public one, in the midst
of the "short date-time" optimization, which confused diff entirely.
One side changed a QStringLiteral to QLatin1String, the other rewrote
adjoining code.

	src/network/kernel/qauthenticator.cpp
Both rewrote a line, equivalently; kept the dev version.

	src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
	src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
One side changed #if-ery that the other removed.

	tools/configure/configureapp.cpp
One side added a check to -target parsing; the other killed -target.

	tests/auto/testlib/selftests/expected_cmptest.lightxml
	tests/auto/testlib/selftests/expected_cmptest.teamcity
	tests/auto/testlib/selftests/expected_cmptest.txt
	tests/auto/testlib/selftests/expected_cmptest.xml
	tests/auto/testlib/selftests/expected_cmptest.xunitxml
Regenerated using generate_expected_output.py
I note that quite a few other expected_* come out changed, now.

There was no git-conflict in
	src/widgets/kernel/qformlayout.cpp
but it didn't compile; one side removed some unused methods; the other
found uses for one of them.  Put FixedColumnMatrix<>::removeRow(int)
back for its new user.

Change-Id: I8cc2a71add48c0a848e13cfc47b5a7754e8ca584
2016-07-19 20:14:40 +02:00
Giuseppe D'Angelo
c8277b6e53 QThread: make it fatal to destroy a running QThread
Align ourselves to what std::thread does (and what's sensible to do anyhow,
since we even document that "Deleting a running QThread [...] will probably
result in a program crash").

[ChangeLog][QtCore][QThread] Destroying a QThread which is still running will
now result in immediate and abnormal program termination.

Change-Id: Ib481287915be01a1381df14abf6e0fb68c36b5b5
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-19 11:28:55 +00:00
Friedemann Kleint
62cbb43457 Fix typo in doc snippets of qOverload and related
Task-number: QTBUG-54808
Change-Id: Ic565710e4d3a95abf98d4696ae7c0001a9171697
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-19 10:49:06 +00:00
Edward Welbourne
b3f260236a Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7 2016-07-19 10:46:15 +00:00
Edward Welbourne
975d21a8c9 QTzTimeZonePrivate: missing spaces for readability.
Change-Id: If19669750fab89fbe0ac24d98b89fa1ea597fbb9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-18 16:05:17 +00:00
Edward Welbourne
92ccb76550 QUtcTimeZonePrivate::data - skip spurious invalid start state.
Most fields were over-written after setting invalid.  The two that
weren't (not used by QUtcTimeZonePrivate) should be (if only for
uniformity with other QTimeZonePrivate variants), so set them to
sensible values.

Change-Id: I824ca0108d5b6bc322f76a0d1683342f789523b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-18 16:04:33 +00:00
Kai Koehne
13c198cedb Doc: Fix snippet to use initializer list
We can expect C++11 now, and using an initializer list
is much shorter.

Change-Id: I6424d24ce7660b342a629e836b94d62c8868a44d
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-07-18 11:12:46 +00:00
Luca Bellonda
d4302ec693 QtCore: Fix QXmlStreamReader for invalid characters in XML 1.0
The XML parser uses fastScanLiteralContent() to read a block of
text. The routine was not checking the range of valid characters as
defined in the XML standard:
https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Char
A check has been added to stop reading the bad character.
Note that the characters are legal in XML 1.1, but QXmlStreamReader
is a well-formed XML 1.0 parser

[ChangeLog][QtCore][QXmlStreamReader]
Fixed a bug in the XML parser that prevented to load XML that
contained invalid characters for XML 1.0.

Change-Id: I10aaf84fbf95ccdaf9f6d683ea7c31925efff36d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-17 14:54:36 +00:00
Edward Welbourne
82ea53ad24 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	qmake/library/qmakeevaluator.cpp

One side changed the iterator to use ranged-for, the other changed its
body; they only conflicted because the latter had to add braces around
the body, intruding on the for-line.  Trivial resolution.

Change-Id: Ib487bc3bd6e3c5225db15f94b9a8f6caaa33456b
2016-07-15 20:47:57 +02:00
Lars Knoll
8ee2a659d6 Don't mention private classes in our docs.
Change-Id: I2cb7443ffa9afac8160b9510df95a304936a01c9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-07-15 08:58:53 +00:00
Anton Kudryavtsev
e46e112eb1 Optimize string usage
Use QStringBuilder more.
Use QL1S directly, without QString construction.

Change-Id: Iad844391367681fc1013b9725403d009e7c346e6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-15 08:23:04 +00:00
Olivier Goffart
120ba68882 QReadWriteLock fast path for tryLock without timeout
When one tries to lock without a timeout, there is no need to allocate
a QReadWriteLockPrivate as we will not wait on it.

Change-Id: I37c96a7fbc0c66fbdffe372f6089708cb2466fe3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-15 06:33:56 +00:00
Lars Knoll
8fc1cd085c Add qtwidgetsglobal.h and qtwidgetsglobal_p.h
The new modular configuration system requires one global
header per module, that is included by all other files in
this module.

That header will later on #include the configuration file
for Qt Widgets. For now it defines the Q_WIDGETS_EXPORT
macro for this library.

Change-Id: I6698989b952b9bac94d086d9f219e03c000f7d53
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-07-14 13:46:07 +00:00
Lars Knoll
64507c7165 Clean up qwindowdefs_win.h
The file lives in Qt Gui, but declares a few methods from
Qt Core and Widgets. All of those methods are actually mostly
unused, not documented and pretty trivial.

This patch removes the last few places the methods got used and
removes the declarations. The implementations should get removed
in a future release.

Change-Id: I2b609c29f403d2ed4824ff4346008be08b3fd067
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-14 13:46:03 +00:00
Martin Smith
4038c07e5f qdoc: Documentation for qFuzzyIsNull() is added
The two versions of this function are now documented on the
global variables page.

Change-Id: Iee95e251d616f6c8b1b42458d23cbf64a70a5315
Task-number: QTBUG-50654
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-14 13:41:54 +00:00
Marc Mutz
5d935dca0c Remove (private) QString::expand(), port to (new) QString::resize(int, QChar)
We cannot really remove the function, since it's called from
inline code (QCharRef::op=(QChar)), but we can schedule it for
removal in Qt 6, and inline it into existing in-tree callers.

Change-Id: I3499f101dcb5ae908726b3673bf3526a04408db6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-14 06:54:16 +00:00
Marc Mutz
c2f4705f23 Add qHash(QHash) and qHash(QMultiHash)
The hash function is carefully designed to give the same result
as the straight-forward implementation of qHash(unordered_map),
which we'll probably add at some point, namely: std::accumulate
over a container of std::pair.

This is one reason to use std:: and not QPair in the implemen-
tation of qHash(QHash). The other is that qHash(QPair) uses a
bad hash combiner, which may xor out the 'seed' from the result.

We can't fix that until Qt 6, but the qHash(std::pair) overload
uses the well-known boost::hash_combine algorithm (implemented
in Qt as QtPrivate::QHashCombine), so we can use that.

I also trust std::pair to work without problems with reference
template arguments, while QPair only very recently gained a very
basic auto-test for reference parameters.

[ChangeLog][QtCore] Added qHash() overloads for QHash, QMultiHash.

Change-Id: I90879d8a99cf1aadb6e84ecc0c3704f52f3691da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-14 06:53:48 +00:00
Thiago Macieira
aca0e367be Fix the Q_ATOMIC_xxx_IS_www_NATIVE macros with C++11
When I introduced this code in Qt 5.0, I made INT and POINTER be
SOMETIMES_NATIVE, but then later I made the specific sizes be
ALWAYS_NATIVE. That doesn't make sense.

Instead, use the macros from the C++11 <atomic> header.

Note that the member isXxxxNative() functions should not have been
constexpr. That's a defect I introduced in Qt 5.0.

Task-number: QTBUG-51315
Change-Id: I0c94a5c2846b48c8aea7ffff1436013e8686c153
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-07-13 21:15:30 +00:00
Simon Hausmann
31b6760e64 Add missing logical bitwise operators to the little-endian storage classes
These make the (future) usage in declarative even more convenient.

Change-Id: I12c0fec1ea843d8acd2ee3fdf2a2189939bebd95
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-07-13 18:17:32 +00:00
Allan Sandfeld Jensen
690d6be542 Handle QVariantHash in QJsonDocument::fromVariant
It absence is just an oversight. The patch also adds test for the valid
inputs of the method.

[ChangeLog][QtCore][QJsonDocument] fromVariant can now take a QVariantHash argument.

Task-number: QTBUG-39751
Change-Id: I7e051413f930023db3cbb81452e77c56a7ceffe8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-07-13 10:58:02 +00:00
Ralf Nolden
4397a1b26c FreeBSD: move order of includes for compiling
The previous patch works for FreeBSD 10 but however not for 9 and 11
due to the order of includes. Move <sys/user.h> down to fix those compile
issues due to unknown types when user.h is included first.

Change-Id: Ica3d3ddf335a543c4a473e8b80d1667cb81667cf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-13 06:50:05 +00:00
Marc Mutz
5c46d07a7c Optimize QString::insert()
When the insertion position is not beyond end(), call
resize() instead of expand(), which fills the new size
with spaces, which, however would just be overwritten
by the following memmove().

Add some Q_UNLIKELY to indicate that we strongly
expect the resize() case to be the more common.

Change-Id: Iaf3215dd53c2cbd18f2fd8a5f80af8f6844944da
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-13 06:33:07 +00:00
Ulf Hermann
972580accd Call disconnectNotify() when disconnecting a QMetaObject::Connection
In all other forms of disconnecting this is done. We also know the
signal index, so there is no reason not to do this.

Change-Id: Ic8b042cd8f45dbff74b42ee30c384a84bef78b20
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-12 16:53:05 +00:00
Edward Welbourne
e21bf5e6b3 QString::replace(): protect sought text and replacement
When replacing each copy of one text with a copy of another, we do so
in batches of 1024; if we get more than one batch, we need to keep a
copy of the sought text and replacement if they're part of the string
we're modifying, for use in later batches.

Also do the replacements in full batches of 1024, not 1023 (which left
the last entry in an array unused); marked some related tests as
(un)likely; and move some repeated code out into a pair of little
local functions to save duplcation.

Those new functions can also serve replace_helper(); and it can shed a
const_cast and some conditioning of free() by using them the same way
replace() now does.  (There was also one place it still used the raw
after, rather than the replacement copy; which could have produced
errors if memcpy were to exercise its right to assume no overlap in
arrays.  This error is what prompted me to notice all of the above.)

Added tests.  The last error proved untestable as my memcpy is in fact
as fussy as memmove.  The first two tests added were attempts to get a
failure out of it.  The third did get a failure, but also tripped over
the problem in replace() itself.  Added to an existing test function
and renamed it to generally cover extra tests for replace.

Change-Id: I9ba6928c84ece266dbbe52b91e333ea54ab6d95e
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-07-12 10:22:25 +00:00
Edward Welbourne
9a3bcd1c3d QString::replace(): Commentary clarifications.
Also skip doing a += 0 when we had to test whether the relevant rhs
was zero anyway (because we want to ++ there instead of +=ing).

Change-Id: Ibd5f21eb9aaf410b09c9db8450b2d61618e628fc
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2016-07-12 10:22:17 +00:00
Timur Pocheptsov
f8dc769655 QMacTimeZonePrivate - correctly initialize m_nstz data-member
The default ctor never initializes m_nstz but calls init with
[NSTimeZone systemTimeZone].name. Init (re)sets m_nstz _only_
if this ianaId is in [NSTimeZone knownTimeZoneName], which is not guaranteed
(a good example is "US/Pacific" that can be returned by systemTimeZoneId() -
the similar problem is described in [*]. Set m_nstz to nil in ctor,
so if 'init' fails we still have a valid (nil) pointer.

[*] http://stackoverflow.com/questions/19819268/convert-ios-localtimezone-to-a-knowntimezone.

Task-number: QTBUG-54330
Change-Id: I68917926350aad3158d44a06f06721f25b3fdb74
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-11 17:51:21 +00:00
Marc Mutz
8cee6864c6 QStringBuilderCommon: drop const from resolved() result type
The const qualification prevented toUpper() etc from
calling the rvalue overloads of the corresponding QString
functions. Since resolved() always returns a non-shared
object, the rvalue overloads can re-use the object's
capacity for storing their result, saving up to one memory
allocation per QStringBuilderCommon::to*() invocation.

Change-Id: Ica97fcd906cdd949ffe56055654578b93407e2d3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-11 13:57:51 +00:00
Thiago Macieira
a2ff5afffa Correct indentation in qsettings.cpp
Introduced in 9c49d8c411, despite my
pointing out.

Change-Id: Ie585843cfb684bc3b6e3fffd14600c99f7fde591
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru>
2016-07-11 06:33:26 +00:00
Anton Kudryavtsev
9c49d8c411 QSettings: optimize string usage
Use QStringBuilder and QString::asprintf more.
Use += operator to reserve extra capacity for
possible free following append/prepend/+= call.

Change-Id: Ia534bec28cb96b688a68a5051a855cda1eb5db4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-09 08:37:10 +00:00
Thiago Macieira
cba3378732 Make QDateTime's default constructor not allocate memory on 32-bit
Commit fb498a6519 introduced the short
datetime optimization, but it accidentally removed the optimization from
Qt 5.7 that made QDateTime's default constructor not allocate memory.
Instead of bringing back the Q_GLOBAL_STATIC that was used, let's use
the short date time optimization on 32-bit too.

The CanBeSmall constant remains false on 32-bit systems, but judicious
non-use of that constant in a few functions allows 32-bit systems to use
the optimization. We still say that any date/time value is "unsmall", as
there's no sense in calculating whether the date is between 1970-01-01
and July 14 of the same year.

Change-Id: I413d458307aa46469b80fffd145a9db0325c08cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-09 02:17:30 +00:00
Thiago Macieira
d16ba63f5c QTimer: add support for <chrono> functions
[ChangeLog][QtCore][QTimer] Added support for std::chrono duration
objects for QTimer methods, like QTimer::singleShot and
QTimer::setInterval.

Change-Id: I87e17314d8b24ae983b1fffd14536e24d5b12424
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-09 02:17:17 +00:00
Anton Kudryavtsev
6bafb9da71 QString: fix incomplete doc of chop()
Change-Id: I84de848681e793e68e0c290719a7f961aca48f4e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 06:43:06 +00:00
Anton Kudryavtsev
2788fccd29 Use QStringLiteral more judiciously
Replace it with QL1S in QStringBuilder expressions
and in overloaded functions.

Replace patterns 'QString::number() + QStringLiteral'
and 'QStringLiteral + QString::number()' with
QString::asprintf.

Saves some text size.

Change-Id: Ib39b2332264dfc3df04e77f2c101b47a1030cef4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 06:43:02 +00:00
Anton Kudryavtsev
e91c412391 QStringRef: add chop()
chop() was missing in the API.

Change-Id: I15af86c8f218cf159b8ce19bbeb2ffa6201f98cf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-07 15:12:27 +00:00
Maurice Kalinowski
753aed83c6 winrt: Fix launch as background task
In case a background task wants to use Qt, winmain is not invoked.
Neither can we create the same objects like winmain do (as in creating a
application view). Instead runOnXamlThread uses the thread pool enabling
the event loop to run successfully.

Task-number: QTBUG-54396
Change-Id: Ia3ba23ed0fd6cd7d2ed8d43675e88073b9aec8b5
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2016-07-06 07:20:16 +00:00
Kevin Funk
bec2fc19fd Windows/QProcess::startDetached(): Don't always create console
Make QProcess::startDetached() behave exactly like QProcess::start() when it
comes to the behavior of whether to create a new console window or not.

Before this patch, QProcess::startDetached() created a new console window
(CREATE_NEW_CONSOLE flag of CreateProcess()) unconditionally. Instead, use the
same rules for deducing whether to show an console window or not as
QProcess::start().

[ChangeLog][QtCore][Platform Specific Changes] QProcess::startDetached()
changed behavior on Windows: it no longer creates a new console window
unconditionally, instead it passes the same creation flags to CreateProcess
as QProcess::start().

Task-number: QTBUG-53833
Change-Id: I0e3d4b161fb5cb94cfbbd21fb4edb8417ab543fd
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2016-07-06 07:00:13 +00:00
Thiago Macieira
9e49778380 Fix/adapt the uses of {to,set,from}Time_t in the qtbase source code
Move those to the equivalent {to,set,from}SecsSinceEpoch(), except for
the cases that did QDateTime::currentDateTime{,Utc}().toTime_t. Those
are best implemented with QDateTime::currentSecsSinceEpoch().

Change-Id: Ib57b52598e2f452985e9fffd145a366c92cfda20
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-06 06:28:13 +00:00
Thiago Macieira
b6345a515b QStorageInfo: update the algorithm for ignored filesystems on Unix
Use the criterion that GNU coreutils' df uses: if the total size of the
filesystem is zero, then it's pseudo. After all, if it contains files in
a zero-sized volume, it has to be pseudo; if it contains nothing, then
it's not very useful anyway.

This would have caught most Linux pseudo-fs anyway, but the mount point
check beforehand allows us to skip quite a few statfs() syscalls.

The new algorithm also solves the following cases which had been
mistakenly interpreted:
 * fuse and ZFS (source devices don't usually start with /)
 * pseudo-fs that were mounted from a device starting with /
   (the source device is usually ignored by the OS)

This change is not testable automatically. Manual testing shows it still
reports the same entries it used to on Linux, plus now shows FUSE
(sshfs) mounts.

Task-number: QTBUG-54235
Change-Id: Ib57b52598e2f452985e9fffd1459f06dcefcc5c6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-06 03:59:50 +00:00
Timur Pocheptsov
6c935dc74f Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7 2016-07-05 20:51:40 +00:00
Kevin Funk
6583720aa4 Revert "CMake: Add imported target for qdoc."
This reverts commit dc0ae02ebc.
qdoc is a binary built inside the qttools repository, thus it should be added
to the respective ConfigExtras.cmake.in there instead.

Task-number: QTBUG-54446
Change-Id: I182e5889af164a89c68226a91abc4d9962a508ea
Reviewed-by: Volker Krause <volker.krause@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-07-05 14:40:29 +00:00
Edward Welbourne
b5695bd5be Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: Ibd81cd1df4a0650d93fcb556a57be90be2e1f569
2016-07-04 15:58:39 +02:00
Lars Knoll
8af681c107 Add qtnetworkglobal.h and qtnetworkglobal_p.h
The new modular configuration system requires one global
header per module, that is included by all other files in
this module.

That header will later on #include the configuration file
for Qt Network. For now it defines the Q_NETWORK_EXPORT
macro for this library.

Change-Id: I9c45d425baf881c431ed71fd457c7feb2c123855
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-07-03 07:56:17 +00:00
Lars Knoll
e8fe65205c Add qtguiglobal.h and qtguiglobal_p.h
The new modular configuration system requires one global
header per module, that is included by all other files in
this module.

A similar scheme and naming convention is already being used
for many other modules (e.g. printsupport, qml, quick).

That header will later on #include the configuration file
for Qt Gui. For now it defines the Q_GUI_EXPORT macro for
this library.

In addition, add a private global header, qtguiglobal_p.h,
that can later on include the private config header for
Qt Gui for things we don't want to export to the world.

Change-Id: Id9ce2a4f3d2962c3592c35e3d080574789195f24
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-07-03 07:55:57 +00:00
Giuseppe D'Angelo
daade9b90d QEventLoop: better describe the exception safety of Qt
1) In general it's unsafe to let exceptions propagate through Qt code,
so document that.

2) Add a note that overriding notify() makes sense only in Qt 5, in Qt 6
it's going away.

3) The advice applies also to applications not using QApplication, but
just QCoreApplication.

Change-Id: I4f6e74c53da757faf2eeaa9de226ceba55c52536
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
2016-07-02 19:36:10 +00:00
Thiago Macieira
946c1a578a Fix build: ftok(3) requires sys/ipc.h
Task-number: QTBUG-54069
Change-Id: Ib57b52598e2f452985e9fffd1457fa9c7ad3bac0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2016-07-02 16:37:03 +00:00
Thiago Macieira
4f3eb66173 QUrl: Test that we do correctly accept valid schemes
... and reject invalid ones. There was one error: we accepted schemes
starting with pluses, dashes and dots.

Change-Id: Ie585843cfb684bc3b6e3fffd145cfe12227ec4ad
Reviewed-by: David Faure <david.faure@kdab.com>
2016-07-02 16:36:50 +00:00
David Faure
1af4916e11 QTime: restore Qt3 compatibility in the QDataStream operators
A Qt5 program writing a null QTime() using setVersion(QDataStream::Qt_3_3),
and then a Qt3 program reading that, would lead to a weird QTime,
with isNull=false, isValid=false, hour=1193, minute=2, second=47, ms=295.

This commit restores interoperability, by writing out the expected value
(0) for a null QTime rather than the -1 value used by Qt4 and Qt5.

Change-Id: Icde468a8f6fc9434ef7018296725819b44d672af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-02 08:13:44 +00:00
Thiago Macieira
169f1beaf5 Move QElapsedTimer to src/corelib/kernel
It's really a kernel functionality, as it implements really low-level
functionality and it's used by the event dispatcher. It was in tools/
only because QTime is.

QDeadlineTimer is also coming to kernel/.

Change-Id: Ifea6e497f11a461db432ffff14491c6d9b839eb0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-07-02 07:51:45 +00:00
Thiago Macieira
840729a931 QDateTime: use the more efficient currentMSecsSinceEpoch()
... instead of creating a QDateTime object.

Change-Id: Ib57b52598e2f452985e9fffd145a36911de4fa9a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-02 07:51:11 +00:00
Anton Kudryavtsev
6662919ecd CoreLib: use QStringRef to optimize memory allocation
Replace substring functions that return QString with
corresponding functions that return QStringRef where
it's possible.

Create QString from QStringRef only where necessary.

Change-Id: Id9ea11b16947220cd27787c0b529de62d10b6c26
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-02 07:39:06 +00:00
Anton Kudryavtsev
2185b2f054 ItemModel: Extract Method isVariantLessThan()
As noted in comments, QSortFilterProxyModel and QStandardItemModel
duplicate code to compare QVariant; extract this into a separate method
they can share.

Since there is only one common suitable header for both files,
the method was placed in qabstractitemmodel.cpp

Change-Id: I82bb4a2d6084059b8a70a8d556c16f1a29f4f686
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-07-02 07:38:00 +00:00
Alex Trotsenko
3c93286f08 QDataStream: unify deserialization of containers
Serialization of the Qt container classes is accomplished by breaking
up the data into primitive units. On the receiver side, these units
should be read atomically to guarantee integrity of the container.

Deserialization procedures for QHash and QMap were already implemented
in accordance with this strategy and have the following behavior:

 - a previously latched error status is saved for the caller. This
   overrides possible different errors in the current read. This
   is consistent with the treatment of primitive types.
 - if an error occurs during the deserialization, the container is
   cleared.

To make the API consistent, this patch adjusts the behavior of QList,
QLinkedList, QVector, and QSet deserialization. On the implementation
side we accomplish this with a private StreamStateSaver RAII class that
consolidates the handling of the stream status for all containers.

[ChangeLog][Important Behavior Changes][QtCore][QDataStream] Incomplete
reads of Qt containers are now handled same way as for primitive types,
meaning that previous errors are latched.

Task-number: QTBUG-54022
Change-Id: I5c77257fe2a4637e8a7e6cf3cd43091c8469340e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-07-01 16:08:41 +00:00
Kai Koehne
9964b850ad Doc: Improve QJsonDocument::fromJson documentation
Be explicit on how to check whether parsing succeeds.

Change-Id: I44f408cb6e5a830826b84dfb3a8af331f03e58cc
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-07-01 14:55:29 +00:00
Liang Qi
200fdd96f0 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	configure
	configure.json

Change-Id: Iba032d9a29c273da2585632bc6e22bbafb961808
2016-07-01 13:21:29 +02:00
Alexander Volkov
c376e3fbf0 QDir: Remove redundant QString wrapping
Change-Id: I8368b137d15509cdec575a17f5dae3c0c343400f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-06-30 15:28:30 +00:00
Edward Welbourne
f3df265a38 QDateTime: early return to make a Q_UNREACHABLE actually true.
It could be reached when QT_BOOTSTRAPPED was defined.

Change-Id: I632d6f908a3bcbde81a6ebbadcaf2800dfe1449d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-30 12:27:00 +00:00
Maurice Kalinowski
ed32af3506 winrt: fix conditional
Seems the previous check was a leftover from debugging. Tests still pass
and loop checks properly now.

Change-Id: Ic12cd49881f6d146687e257794b3028f6c8e874c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-06-30 11:54:26 +00:00
Anton Kudryavtsev
5c9e393117 QString: add some missing overloaded operator+
to keep compatibility with and without
using QT_USE_QSTRINGBUILDER.

Change-Id: If8218fe0693cdb7ad1250beb272e0e7c356bbf4a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-29 14:58:25 +00:00
Liang Qi
f27d8b9f57 Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: If6ba05867e7c98159e1b94ff71923e8b36bdbccb
2016-06-29 10:10:22 +02:00
Friedemann Kleint
0dc5d8e6c9 Fix some qdoc-warnings for Qt 5.8.
qtbase/src/corelib/tools/qstring.cpp:8341: warning: Unknown command '\length'
qtbase/src/corelib/tools/qstring.cpp:8354: warning: Unknown command '\length'
qtbase/src/corelib/tools/qstring.cpp:8366: warning: Unknown command '\length'
qtbase/src/corelib/doc/src/animation.qdoc:38: warning: Can't link to 'QAbstractAnimation::updateCurrentValue()'
qtbase/src/corelib/io/qdatastream.cpp:529: warning: Undocumented enum item 'Qt_5_8' in QDataStream::Version
qtbase/src/corelib/tools/qdatetime.cpp:4377: warning: No documentation for 'QDateTime::currentSecsSinceEpoch()'
qtbase/src/corelib/tools/qcommandlineoption.cpp:435: warning: Undocumented parameter 'flags' in QCommandLineOption::setFlags()
qtbase/src/network/ssl/qsslconfiguration.cpp:857: warning: Undocumented parameter 'dhparams' in QSslConfiguration::setDiffieHellmanParameters()
qtbase/src/network/ssl/qsslconfiguration.cpp:830: warning: Undocumented parameter 'hint' in QSslConfiguration::setPreSharedKeyIdentityHint()
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:225: warning: No such enum item 'ErrorUnsafeParameters' in QSslDiffieHellmanParameters::Error
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:225: warning: No such enum item 'ErrorInvalidInputData' in QSslDiffieHellmanParameters::Error
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:225: warning: Undocumented enum item 'UnsafeParametersError' in QSslDiffieHellmanParameters::Error
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:225: warning: Undocumented enum item 'NoError' in QSslDiffieHellmanParameters::Error
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:225: warning: Undocumented enum item 'InvalidInputDataError' in QSslDiffieHellmanParameters::Error
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:105: warning: Undocumented parameter 'encoding' in QSslDiffieHellmanParameters::QSslDiffieHellmanParameters()
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:129: warning: Undocumented parameter 'encoding' in QSslDiffieHellmanParameters::QSslDiffieHellmanParameters()
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:208: warning: Can't link to 'clear()'
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:277: warning: Undocumented parameter 'dhparam' in operator<<()
qtbase/src/network/ssl/qssldiffiehellmanparameters.cpp:277: warning: No such parameter 'dhparm' in operator<<()
qtbase/src/widgets/kernel/qapplication.cpp:999: warning: Cannot find 'QApplication::autoMaximizeThreshold' specified with '\property' in any header file

Change-Id: I4ac00f0fc0dbc4d421cf7c0273635d9681962645
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-06-28 13:27:46 +00:00
Thiago Macieira
59c3670b63 Make sure all private headers in Qt Core include qglobal_p.h
The rule was:
 - if the header included qglobal.h, turn that into qglobal_p.h
 - otherwise, insert the #include after the "We mean it" warning

qglobal_p.h currently only includes qglobal.h.

Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-25 08:01:04 +00:00
Liang Qi
dd90af1221 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	mkspecs/common/mac.conf
	mkspecs/features/configure_base.prf
	mkspecs/features/configure.prf
	mkspecs/macx-clang-32/qmake.conf
	mkspecs/macx-clang/qmake.conf
	mkspecs/macx-ios-clang/qmake.conf
	src/network/ssl/qsslsocket_openssl_symbols_p.h

Change-Id: I768b592e8e589662b1fdb9b8cbd633fef26845b6
2016-06-23 14:24:55 +02:00
Liang Qi
5cfb80a28e Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/angle/src/libGLESv2/libGLESv2.pro
	src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp

Change-Id: If8da4cfe8f57fea9f78e7239f378a6302c01674e
2016-06-23 10:29:37 +02:00
Kai Koehne
3986e1cb22 Document limitations and good practice for logging category names
Task-number: QTBUG-54238
Change-Id: I2b6f54fb26d24e6da19c0e09782483eeb10206e1
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Michael Brasser <michael.brasser@live.com>
2016-06-23 07:11:34 +00:00
Jake Petroules
0c43ef5023 Update for the newest Darwin-family operating systems.
This also corrects for some code that was not included in the forward
merge from 5.6 (ea438b2508) due to code
restructuring.

Change-Id: I90a20fbcb60cfd6deb1cca3716a62754af27901f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-23 02:37:12 +00:00
Thiago Macieira
f4be16e1f7 Win: Get rid of unused variables un QDateTime::currentMSecsSinceEpoch
The compiler didn't complain that they were unused or -Werror / -WX was
not active.

Change-Id: Ib57b52598e2f452985e9fffd145a7b63a32189fd
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2016-06-22 23:26:43 +00:00
Thiago Macieira
bff15c547e QDateTime: introduce {to,from,set,current}SecsSinceEpoch
These new functions use a 64-bit integer in the API, instead of the
broken 32-bit unsigned integer that the previous xxxTime_t functions
used. That was a design flaw when the API was introduced back in Qt 4.2,
so I'm deprecating the API and slating it for removal in 6.0.

The changes to qfilesystemmetadata_p.h and quuid.cpp are necessary to
build the bootstrap library. The rest of the adaptation to the new API
will come in the next commit.

[ChangeLog][QtCore][QDateTime] Introduced toSecsSinceEpoch,
fromSecsSinceEpoch and setSecsSinceEpoch functions, which use 64-bit
integers to represent the number of seconds.

[ChangeLog][QtCore][QDateTime] The toTime_t, fromTime_t and setTime_t
functions are deprecated and will be removed in Qt 6.0. For new code,
use the equivalent functions with "SecsSinceEpoch" in the name, or the
equivalent ones with millisecond accurancy that have existed since
Qt 4.7.

Change-Id: Ib57b52598e2f452985e9fffd145a355d0e7ff48d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-22 18:34:27 +00:00
Ralf Nolden
9caac0f176 Add OpenBSD to list of targets that can't use --no-undefined in qtcore
A prior commit has already added the resetting of QMAKE_LFLAGS_NOUNDEF
in corelib.pro for FreeBSD due to environ(7) not being part of libc.
OpenBSD has the same issue, so add it to the list of BSD systems
affected for resetting the flags for qtcore.

Change-Id: I50a62271ffa05a9976e802de420d47a1425359c4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-22 16:25:22 +00:00
Oswald Buddenhagen
1824e43b51 make plugin meta data load failure error message less cryptic
Change-Id: I280673e7fd582c5877e8e17ed00318cb10cd537c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-22 15:12:36 +00:00
BogDan Vatra
930e750b7a Remove duplicated QT_HAS_BUILTIN define
QT_HAS_BUILTIN is already defined in qcompilerdetection.h which is
included in qglobal.h which is included in this header file.

Task-number: QTBUG-54068
Change-Id: I46c2e13d85fc21d3e6c426d0f35a584b21ae792b
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2016-06-21 18:58:27 +00:00
Liang Qi
ea438b2508 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/corelib/global/qglobal.cpp
	src/corelib/global/qsysinfo.h
	src/corelib/kernel/qcoreapplication_win.cpp
	src/gui/text/qdistancefield.cpp
	src/gui/text/qdistancefield_p.h
	src/plugins/platforms/windows/qwindowsglcontext.cpp
	src/plugins/platforms/windows/qwindowsglcontext.h

Change-Id: Ib3500acc2b28553bde06758cd9a2e19eb7fe2978
2016-06-21 08:39:41 +02:00
Liang Qi
5f0ec7305e Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7 2016-06-20 07:54:09 +00:00
Thiago Macieira
a2f319e9fb Fix MSVC warning about casting to pointer of different size
qdatetime.cpp(2834): warning C4312: 'reinterpret_cast': conversion from 'int' to 'QDateTimePrivate *' of greater size

Change-Id: Ib57b52598e2f452985e9fffd1458fe3ba3fcfb48
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-20 06:53:10 +00:00
Liang Qi
e32f1a4d61 Merge remote-tracking branch 'origin/5.6' into 5.7
And blacklisted a few tests in tst_QUdpSocket.

Conflicts:
	src/android/jar/src/org/qtproject/qt5/android/QtNative.java
	src/corelib/global/qglobal.cpp
	src/corelib/global/qsystemdetection.h
	src/corelib/io/qfileselector.cpp
	src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
	tests/auto/network/socket/qudpsocket/BLACKLIST

Task-number: QTBUG-54205
Change-Id: I11dd1c90186eb1b847d45be87a26041f61d89ef6
2016-06-20 08:00:26 +02:00
Thiago Macieira
683c30074e Add "-softfloat" to archdetect.cpp and clarify what to use when
Change-Id: I1cc7601489634e96833cfffd14563e033c85ff6d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-19 18:46:36 +00:00
Simon Hausmann
ee2eed350f Remove overload tag from QByteArray QIODevice::readAll()
This does not seem to be a function that is overloaded.

Change-Id: Icf8942dfb1e78a2ddb38cbd1c49657f745a61989
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-17 16:56:55 +00:00
Jake Petroules
2fa4a48ff6 Fix documentation of some QSysInfo functions.
Qt 5.8 no longer supports Windows CE, or versions of Windows where the
marketing version is not an orderable version number.

Change-Id: I8fab7d9b0d466f891e872b6c3fdf9d98ffe6ebc1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-17 16:43:04 +00:00
Thiago Macieira
691b867895 Fix warning about non-void function not returning anything
Found by ICC 17 Beta on Windows.

Change-Id: Ib57b52598e2f452985e9fffd1458b6990b70837a
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2016-06-17 16:12:52 +00:00
Olivier Goffart
f7a0968da4 Forward declarations for platform specific types should also be done with Q_QDOC
The clang based qdoc need to be able to parse properly anything that is
in #ifdef Q_QDOC

The #if for the forward declararion now match the one in which it is used.

Change-Id: Ia6cf84dd07a979b4e7aa8da764d9fb2fce74baa1
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-06-17 14:58:30 +00:00
Liang Qi
3cb56800d5 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp

Change-Id: If899cda251b4dc8b8a7c6764520e88ab719737cd
2016-06-17 10:53:42 +02:00
Liang Qi
3d8c8daae1 Merge "Merge remote-tracking branch 'origin/5.7.0' into 5.7" into refs/staging/5.7 2016-06-16 12:25:24 +00:00
Liang Qi
c4e472ea10 Merge remote-tracking branch 'origin/5.7.0' into 5.7
Conflicts:
	src/corelib/tools/qsimd_p.h

Change-Id: I7c6bfc5873d97ad7f51a540dd9c18b9359dde59f
2016-06-16 07:30:02 +02:00
Thiago Macieira
6cbc9c6d35 QArrayDataOps: silence Clang warning about memmove
Same as 9224255f13: some Qt types are
polymorphic and are marked as movable, so Clang complains.

qarraydataops.h:608:27: error: destination for this 'memmove' call is a pointer to class containing a dynamic class 'QPixmap'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]
qarraydataops.h:608:61: error: source of this 'memmove' call is a pointer to class containing a dynamic class 'QPixmap'; vtable pointer will be moved [-Werror,-Wdynamic-class-memaccess]

Change-Id: Ib57b52598e2f452985e9fffd145861e025b81550
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2016-06-16 04:34:05 +00:00
James McDonnell
b07736c0bc Correct a type mismatch in the QNX PPS code
It's a problem when building for 64-bit where the two types no longer
match.

Change-Id: I8c31915caf81a60d635c79816a3a2d5d36742ff9
Reviewed-by: Dan Cape <dcape@qnx.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-15 13:46:19 +00:00
David Faure
7b23ebefb2 QReadWriteLock: initialize member var currentWriter
Found by valgrind's memcheck.

Change-Id: I68f7c9279033e76d82f511b9d095548b4ef45723
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-06-15 08:57:01 +00:00
Alex Trotsenko
3c87c82e52 QDataStream: do not lose error status while reading containers
Otherwise, the code:

  ds >> s >> hash;

could set the stream status to ReadPastEnd, while deserialization
of the string is failed with ReadCorruptData status.

Proposed solution is to restore a previously latched error status
unconditionally in accordance with QDataStream::setStatus() docs.

Change-Id: Id3a7dccf709b02e5b018efb48d7647ee48fe5124
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-15 07:43:54 +00:00
Oliver Wolff
e85e7f4b81 Fixed developer build for MinGW
0 must not be used as a null pointer constant

Change-Id: I082d0e99c105fb02980b9cf390e7f6e4c9ad0869
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-15 06:31:35 +00:00
Jake Petroules
3e2bde3578 Update for the newest Darwin-family operating systems.
- Adapt to the OS X => macOS rename in Q_OS_ macros/docs, qmake scopes,
file selectors, etc.
- Add new QSysInfo values and MAC_OS_X / __MAC_ / __IPHONE_ values for
macOS 10.12 and iOS 9.1 through 10.0.
- Update prettyProductName with new macOS "Sierra" codename.

Change-Id: Id976530beeafa01b648ebaa16f4a8f0613fcaf75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-15 05:52:47 +00:00
Tor Arne Vestbø
58566686fc darwin: Add Foundation conversion functions for QSize/QSizeF
The fromCGPoint function was left out for QSize, as the foundation type is
using CGFloats internally. Clients should use an explicit QSizeF::toSize()
when potentially throwing away precision.

Change-Id: I12d43ae0881f09ad8d79f2caaa000c3983f4ef30
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-06-14 17:23:38 +00:00
Tor Arne Vestbø
197471beac darwin: Add Foundation conversion functions for QPoint/QPointF
The fromCGPoint function was left out for QPoint, as the foundation type is
using CGFloats internally. Clients should use an explicit QPointF::toPoint()
when potentially throwing away precision.

Change-Id: I12a37e8f81c86b7ada56066cc18ee29709cc21e3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-06-14 17:22:55 +00:00
James McDonnell
e969e6d2ca Fix cast warnings when pthread_t is smaller than a pointer
Push conversions from pthread_t to Qt::HANDLE and back into functions.
The casts that were being used didn't work for the unusual 64-bit
pointer/32-bit int combination that QNX is using for 7.0.  HANDLE ends
up as a 64-bit pointer and pthread_t ends up as a 32-bit integer.  g++
considers the precision loss when converting from the 64-bit pointer
to the 32-bit integer an error.  Better to have the casts hidden in
functions so it's easier to adjust them for unusual combinations such
as this.

Change-Id: Ia156b26224a0f7edc1c31e3d1ee8b21191381698
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-13 19:00:32 +00:00
Liang Qi
511790fd1a Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	config_help.txt
	configure
	mkspecs/features/uikit/sdk.prf
	src/corelib/global/qhooks.cpp
	src/corelib/io/qfilesystemwatcher.cpp
	src/corelib/io/qlockfile_unix.cpp
	src/corelib/tools/qalgorithms.h
	src/gui/kernel/qwindowsysteminterface.h
	src/gui/text/qtextdocument_p.cpp
	src/network/access/access.pri
	src/network/access/qnetworkaccessmanager.cpp
	src/network/access/qnetworkreplynsurlconnectionimpl.mm
	src/src.pro
	src/testlib/qtestcase.cpp
	src/widgets/kernel/qwidgetbackingstore_p.h
	src/widgets/styles/qwindowscestyle.cpp
	src/widgets/styles/qwindowsmobilestyle.cpp
	tests/auto/corelib/io/qdiriterator/qdiriterator.pro
	tests/auto/corelib/io/qfileinfo/qfileinfo.pro
	tests/auto/gui/kernel/qwindow/BLACKLIST
	tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
	tools/configure/configureapp.cpp

Change-Id: Ibf7fb9c8cf263a810ade82f821345d0725c57c67
2016-06-13 12:46:46 +02:00
Maurice Kalinowski
27e94bd9d1 winrt: Fix potential crash in QCoreApplication
GetModuleFileName exists for Windows 10 and upwards, hence use the
generic version from the win32 mkspec. This allows to create a
QCoreApplication object with nullptr argv, as the application filename
is identified via the binary itself and not via arguments. A couple of
auto-tests use this method to create multiple application objects during
runtime.

Unfortunately we cannot apply this for msvc2013, even though MSDN states
the GetModuleFileName exists, it fails to compile for Windows Phone 8.1.

Change-Id: I2b8b988107487ef3785462f8ca40b0a6e0623e32
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2016-06-13 06:13:19 +00:00
Maurice Kalinowski
038c57f4b3 winrt: Close IAsyncInfo manually in case of error
In case QEventDispatcherWinRT::runOnXamlThread returns an error the
runtime sets the status of IAsyncInfo to Error. At the point when the
IAsyncInfo destructor is invoked, an unhandled exception is thrown
indicating the error has not been handled, causing any application to
just crash deep inside the Windows platform libraries.

Hence, in case runOnXamlThread returns non-S_OK we have to manually
invoke Close() of the IAsyncInfo to tell the system we have taken care
of everything.

Change-Id: I3ac1e2ec2726f42e44f4f9a92191e454711120dd
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2016-06-13 06:13:15 +00:00
James McDonnell
d4e98a9a38 Move __cpp_constexpr check inside Q_COMPILER_CONSTEXPR check
Q_COMPILER_CONSTEXPR can be undefined (or not defined at all) to
indicate that constexpr should not be used regardless of the compiler's
ability to support it.  This is done for QNX because some C library
floating point functions used in the Dinkumware C++ library aren't
constexpr functions; i.e., the library doesn't have proper constexpr
support even though the compiler does.

(cherry picked from commit d87242968f)
Change-Id: If0bdeb2180710dd9ccd97d79fa91cf9ff42f7990
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-13 00:47:13 +00:00
Thiago Macieira
50d70fd1e3 Fix warning when compiling x86 with SSE2 but no AVX2
qstring.cpp:595:13: error: unused variable ‘nullmask’ [-Werror=unused-variable]

Change-Id: I1cc7601489634e96833cfffd1456474a529a79ed
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-06-11 20:50:04 +00:00
Tor Arne Vestbø
ebee64645a darwin: Add Foundation conversion functions for QRect/QRectF
The fromCGRect function was left out for QRect, as the foundation type is
using CGFloats internally. Clients should use an explicit QRectF::toRect()
when potentially throwing away precision.

Change-Id: I0d4c5c5a4e6a45ea3287e3f37a00b69b0bfdefcf
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2016-06-10 23:47:15 +00:00
Liang Qi
cbe332405a Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	configure
	mkspecs/macx-ios-clang/features/default_pre.prf
	mkspecs/macx-ios-clang/features/sdk.prf
	mkspecs/unsupported/freebsd-g++46/qplatformdefs.h
	src/widgets/styles/qgtkstyle.cpp
	tests/auto/corelib/io/qdiriterator/qdiriterator.pro
	tests/auto/corelib/io/qfileinfo/qfileinfo.pro

Change-Id: Ia943555d1e59234a66f7dc65bdfda838e40001b5
2016-06-10 23:27:10 +02:00
Thiago Macieira
cbe62a0e6d Add move constructor to QDateTime
The move constructor is slightly more interesting than the copy
constructor because we can reset other to a short data state on 64-bit
systems. The assembly of that function is simply:

       mov    (%rsi),%rax
       mov    %rax,(%rdi)
       movq   $0x1,(%rsi)
       retq

The move-assignment operator for QDateTime was already there. There's no
need for one for QDateTime::Data since it's never called.

Change-Id: I06bae9392f534e45b3f1ffff144dffdd7f23b170
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-10 17:57:17 +00:00
Thiago Macieira
72393ac3b6 Allow QDateTime to shrink back to short data mode on copy
We won't shrink on manipulation when we have memory allocated, but it's
a good idea to create a non-shared copy if we can. It's an unlikely
scenario, though, because it requires the QDateTime object to have been
set to a large state then manipulated back into a small state.

Change-Id: I06bae9392f534e45b3f1ffff144dfee755bafa01
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:57:13 +00:00
Thiago Macieira
d1395b76cf Move the QDateTime file static functions to their right place
The file has an organization, so let's follow it. This commit has no
other changes besides moving code around.

Change-Id: I06bae9392f534e45b3f1ffff144e0b1f6dd72622
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-10 17:57:08 +00:00
Thiago Macieira
fb498a6519 Long live the short QDateTime optimization
Well, maybe not for so long: we may want to revisit it for Qt 6. At the
very least, we should enlarge the size of QDateTime on 32-bit system so
that they too can benefit from the optimization.

With this optimization, on 64-bit systems, the most common uses of
QDateTime now no longer allocate memory at all. The range is slightly
reduced from 584,554,049 years to 2,283,414 years around 1970. The other
drawback is that calling QDateTime::offsetFromUtc() on a localtime now
needs to recalculate the offset, instead of using the cached offset.
(QDateTime::toMSecsSinceEpoch() didn't use the cache).

Change-Id: Id5480807d25e49e78b79ffff144a8b2c9af91814
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:57:03 +00:00
Thiago Macieira
3eb5b15d80 QDateTimePrivate refactor: static'fy the date/time manipulators
This commit moves QDateTimePrivate functions setTimeSpec, setDateTime,
getDateTime, checkValidDateTime and refreshDateTime outside the
class. Like the previous commit, this is done in preparation for the
"Short QDateTime Optimization" as the "msecs" field will be placed in
the short data, if possible.

By making them file-level static, this also improves code generation, as
the compiler doesn't know whether it has to emit the class members for
out-of-line use or not.

Change-Id: I06bae9392f534e45b3f1ffff144df4d73cbc9184
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:57 +00:00
Thiago Macieira
97eae54083 QDateTimePrivate refactor: static'fy access to d->m_status
This commit changes most accesses to the d->m_status (including
d->spec() and d->setSpec() uses) to use new static functions. This is
done in preparation to the "Short QDateTime Optimization" as the status
byte will be kept in the short data.

Change-Id: I06bae9392f534e45b3f1ffff144dbd795d03227a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-10 17:56:53 +00:00
Thiago Macieira
b726751cd1 Refactor & simplify QDateTime::setMSecsSinceEpoch
Change-Id: I06bae9392f534e45b3f1ffff144df5ce1aa52636
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:48 +00:00
Thiago Macieira
38a1f610ab Refactor & simplify QDateTimePrivate::refreshDateTime()
Change-Id: I06bae9392f534e45b3f1ffff144df51ae6159a97
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-10 17:56:45 +00:00
Thiago Macieira
8e12120a2b Simplify the QDateTimePrivate::setTimeSpec() function
Change-Id: I06bae9392f534e45b3f1ffff144df36cc98b5f3f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:41 +00:00
Thiago Macieira
d3279b3217 QDateTime: fix the massageAdjustedDateTime differently
Instead of using a macro for maybe passing an extra parameter, pass the
d pointer and let the function decide what to use and what not to use.

Change-Id: I06bae9392f534e45b3f1ffff144dbeb68a30cb48
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:37 +00:00
Thiago Macieira
31b926d679 Move QDateTimePrivate::toMSecsSinceEpoch() code into QDateTime
Change-Id: I06bae9392f534e45b3f1ffff144dbad485814779
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:33 +00:00
Thiago Macieira
0358b87102 Remove QDateTimePrivate::isNull{Date,Time}()
They're superfluous, since b491fab02a
removed the distinction between null and invalid. Just use the
isValidXxx equivalents.

Change-Id: I06bae9392f534e45b3f1ffff144db9badad010fd
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:28 +00:00
Thiago Macieira
6d311a23ad Stop QDateTimePrivate from inheriting QSharedData
We're going to have to stop using QSharedDataPointer because of the
upcoming short-datetime-optimization. By dropping the inheritance, I am
also able to rearrange the members and remove the padding hole that
existed.

The second padding hole was removed in the previous commit, which merged
two 32-bit fields into one.

On 64-bit systems, there's no way around a remaining 4-byte hole
somewhere due to the odd number of 32-bit members. I chose to leave it
in the middle of the struct, before the m_timeZone member, instead of
tail padding, so that the layout of the first members structure are the
same in bootstrapped and non-bootstrapped builds. That should help
debugging the bootstrapped tools in Qt Creator. It's also now the same
in 32- and in 64-bit systems.

Change-Id: Id69569111e7d4e619e22ffff144b1fba708885f7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-10 17:56:23 +00:00
Thiago Macieira
1a161c8ede QDateTimePrivate: merge the time spec, DST status and validity flags
Storing them in a single byte is the first step towards the Short
QDateTime Optimization.

The bump in the "private version" by 10 is to accommodate possible
changes in the Qt 5.7 branch.

Change-Id: Id5480807d25e49e78b79ffff144a59420457bcf0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-10 17:56:18 +00:00
Mitch Curtis
ea86f73640 Mention extension in QFileInfo's suffix-related documentation
This makes it easier for users to find out how to get a file's
extension when browsing docs.

Change-Id: I08a1b620dea5432462133324824fae85754b9a09
Task-number: QTBUG-53380
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-06-10 06:59:42 +00:00
Anton Kudryavtsev
1c9818c871 QString: use new QL1S::at() in lastIndexOf()
Make overloaded lastIndexOf() functions
more homogeneous.

Change-Id: If45aac88b43d26baf7f93caec3662a1085e26b97
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-06-09 18:01:50 +00:00
Thiago Macieira
b05741937c Plug padding holes in QHostAddressPrivate
On ABIs where quint64 is aligned on 8-byte boundaries (such 32-bit
Windows and all 64-bit systems), there was a padding hole of 4 bytes
between QHostAddressPrivate::a and the anonymous union. If we move the
member to after the union, there is no hole anymore.

That operation causes the tail padding to grow from 3 to 7 bytes. Since
we also don't need full 32 bits for the protocol, we can shrink the
structure by 8 bytes on those architectures and by 4 bytes on 32-bit
Unix systems.

Change-Id: I461e9fc7199748faa187ffff1415d6601a7bd777
Reviewed-by: hjk <hjk@theqtcompany.com>
2016-06-09 15:59:24 +00:00
Thiago Macieira
0a78d918f0 Replace qAllocMore with a pair of more useful functions
The first is "exact", not "more": qCalculateBlockSize. It ensures that
there's no overflow in multiplying, adding the header size or when
converting back to an int.

The second is the replacement for qAllocMore: it calculates the block
size like the first, but increases the block size to accommodate future
appends. The number of elements that fit in the block is also returned.

Task-number: QTBUG-41230
Change-Id: I52dd43c12685407bb9a6ffff13f5da09f816e667
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-09 15:32:14 +00:00
Thiago Macieira
43ff604f94 x86: Fix build with BMI but no LZCNT extensions
The GCC builtins for clzs and ctzs are enabled when the x86 extension
for LZCNT and TZCNT are enabled. The use of only __BMI__ in commit
f5f47987ce was incorrect.

But GCC needs both BMI and LZCNT enabled to enable this builtin.

Change-Id: I1cc7601489634e96833cfffd145647e9fc9f2f51
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2016-06-09 15:29:25 +00:00
Erik Verbruggen
923d869b0f Aarch64: vectorize ascii de-/encoding.
This works only on Aarch64, because the vaddv instruction is only
available on 64bit ARM. Doing something equivalent on 32bit ARM has the
high chance to run into micro-architecture differences: on an Cortex-a8,
transferring a single vector element from NEON to the regular CPU
registers takes 20 cycles(!).

Change-Id: Iccbfe84da82abb9b10f3f3dc35c8b950df69e251
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2016-06-09 08:06:04 +00:00
Thiago Macieira
48fd845c61 QElapsedTimer: Remove legacy code dealing with Windows pre-Vista and CE
GetTickCount64 is available on Windows Vista and WinRT. Since Windows CE
is no longer supported on dev, we don't need to dynamically resolve the
function anymore.

What's more, QueryCounterFrequency is documented to never fail since
Windows XP, so we haven't needed GetTickCount64 for years (no clue when
we dropped support for Win2k).

Change-Id: I115db302eb114bed8cd1fffd14558a81353d2aed
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-08 22:49:57 +00:00
Marc Mutz
a7ae92e67d QStringRef: add missing relational operators against QByteArray
QStringRef op QByteArray was ambiguous between

  bool QStringRef::operator op(const char*) const
  bool operator op(const QStringRef&, const QString&)

QByteArray op QStringRef was ambiguous between

  bool operator op(const QString&, const QStringRef&)
  bool operator op(const char*, const QStringRef&)

Fix by providing more overloads.

[ChangeLog][QtCore] Disambiguated the relational operators
comparing QByteArray with QStringRef (and vice versa).

Change-Id: I1cfa9ecfdd8b4102e652593faf35f6098289bc34
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-06-08 21:42:33 +00:00
Marc Mutz
f0d9eed064 QString: fix QChar <> QLatin1String relational operators for non-US-ASCII
The implementation used the QString::compare_helper(QChar*, int, char*, int)
overload, which, however, interprets the rhs as a UTF-8 sequence, not as
Latin-1.

Fix by using the (QChar*, int, QLatin1String) overload.

Extend the test to cover this case, too.

Change-Id: I59b26d63d0caec036b80ef8818c75d0cebe519d2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-08 21:35:54 +00:00
Jake Petroules
e672fd5432 Remove QSysInfo code related to unsupported versions of Windows.
Change-Id: Ia28f17146d61724dbea73939793dfbd503546e56
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-08 21:21:55 +00:00
Luca Bellonda
767319a5aa Add support for 8bit encodings not ASCII compatible in QXMLStreamWriter.
When using a 8 bit encoding to write a file, a test discovers if the
encoding is really ASCII compatible by examining a letter and one of the
XML reserved characters. EBCDIC, in the current base, was not well
handled.

[ChangeLog][QtCore][QXmlStreamWriter] Fixed a bug that prevented the
generation of valid XML files when using encoding with 8 bit per
character but not ASCII compatible. QXMLStreamWriter generated XML
markup using always ASCII in this case.

Change-Id: I9c86a122dd91b2290d50c358638442f99777d4ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-06-08 18:50:25 +00:00
Thiago Macieira
e454e986d5 Move the Q_DECL_UNUSED attribute elsewhere to satisfy ICC 17
It doesn't like the attribute there. I think it's a compiler bug, but I
can't be sure because the part of the standard dealing with the
placement of attributes and where they apply is very complex. Exercise
left for the reader to determine if ICC is correct or not to reject it
there.

Change-Id: I87e17314d8b24ae983b1fffd1454bde826b7bcf4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-06-08 18:34:10 +00:00