Commit Graph

3266 Commits

Author SHA1 Message Date
Thiago Macieira
4be50ecafd QTemporaryFile: fix issues with removing a file twice
The assertion in isUnnamedFile() we had was incorrect after the file was
removed, since we cleared the name and possibly reset back to the
template. Since ~QTemporaryFile() calls remove(), this was easy to
trigger if you attempted to remove the temp file and leave
QTemporaryFile like that.

Take this opportunity to add to the docs of setAutoRemove() explaining
the possibility of unnamed files.

#7  0x00007f69bcc2b50e in qt_assert (
    assertion=assertion@entry=0x7f69bcf194a0 "unnamedFile == d_func()->fileEntry.isEmpty()",
    file=file@entry=0x7f69bcf19458 "io/qtemporaryfile.cpp",
    line=line@entry=514) at global/qglobal.cpp:3123
#8  0x00007f69bcd672cf in QTemporaryFileEngine::isUnnamedFile (this=this@entry=0x55cd60644df0)
    at io/qtemporaryfile.cpp:514
#9  0x00007f69bcd683f7 in QTemporaryFileEngine::remove (this=0x55cd60644df0)
    at io/qtemporaryfile.cpp:396
#10 0x00007f69bcd48654 in QFile::remove (this=this@entry=0x7fffb393f7e0)
    at io/qfile.cpp:513
#11 0x00007f69bcd6653b in QTemporaryFile::~QTemporaryFile (this=0x7fffb393f7e0, __in_chrg=<optimized out>)
    at io/qtemporaryfile.cpp:719

Change-Id: I57a1bd6e0c194530b732fffd14f4ed28ca8185b2
Reviewed-by: Andreas Hartmetz <ahartmetz@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-23 05:27:23 +00:00
Allan Sandfeld Jensen
b8e352ad37 Add functions for fast bulk conversion of qfloat16
Both ARM and x86 can convert fp16 much faster in bulk than one at a
time. This also enables hardware accelerated conversion on x86, when
F16C isn't unconditionally available at compile time.

This code is implemented in C to ensure that there's no leakage of
inline symbols from the .obj file that was compiled by Visual Studio
with AVX support. Unfortunately, simd.prf uses $(CXX) instead of $(CC)
for all its sources, which means the file gets interpreted as C++ by
g++, clang++ and icpc. Those compilers at least don't leak any symbols.

Done-with: Thiago Macieira <thiago.macieira@intel.com>
Change-Id: I9d26d99e83392861fb09564e0e8e8d76cd8483b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-21 20:01:23 +00:00
Thiago Macieira
0ac2dca977 Add support for C11 static_assert and thread_local
Tested with Clang, GCC 4.5 & up, ICC 17 and MSVC 2017. No current
version of MSVC supports C11 and GCC implemented the features slightly
later in C than in C++.

Change-Id: I57a1bd6e0c194530b732fffd14f45c5074c9a052
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-11-21 20:01:18 +00:00
Liang Qi
7e360ccd4e Merge remote-tracking branch 'origin/5.9.3' into 5.10.0
Change-Id: I3224e0b877ec24b587e299083feb793518b0568c
2017-11-21 10:58:21 +01:00
Oswald Buddenhagen
bb3872d609 Merge 5.10 into 5.10.0
Change-Id: Ibfbaa8ef89cf45b87a2c65f1da4a708e5464f259
2017-11-20 13:48:33 +01:00
Svenn-Arne Dragly
ce08318a46 Add QThreadPool autotest to detect stale threads after tryTake
This test makes sure that we do not introduce a regression where the
threads exited the inner loop over the queue before the queue was
empty. This was triggered by calling tryTake at least maxThreadCount
times, which left the same number of null pointers in the queue
and caused the inner loop to exit too soon for all the threads.

Change-Id: I3a9d800149b88d09510ddc424667670b60f06a33
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-16 12:42:44 +00:00
Edward Welbourne
285596ee19 Special-case parsing of Zulu time-zone in date-times
When parsing a date-time's zone, a stray Z denotes UTC (a.k.a. Zulu
time), despite not being a valid name for the zone.  Clients parsing
such date strings had to treat the Z as a literal, rather than a
zone-ID, but then they got back a LocalTime instead of the UTC the
string actually described.  So teach QTimeZoneParser to handle this
special case and adapt an existing test (that used a time ending in Z,
but had to treat it as a local time) to check this works.

[ChangeLog][QtCore][QDateTime] When parsing a time-zone, "Z" is now
recognized as an alias for UTC.

Change-Id: Ib6aa2d8ea2dc6b2da526b39aec74dbc007f90fd8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-14 16:44:27 +00:00
Thiago Macieira
772863355a QLockFile/Unix: save the boot and machine IDs in the lock file too
This allows us to make sure that the PID we read is from the same boot
as we are right now running. The collision could happen on embedded
systems where the boot sequence is fixed, so all the same processes
would have the exact same PIDs after reboot as they did before.

[ChangeLog][QtCore][QLockFile] QLockFile can now properly conclude that
a lock file from a previous boot of the same device is stale and can be
removed. This is implemented only for Linux and Apple operating systems.

Task-number: QTBUG-63425
Change-Id: I0b48fc8e90304e0dacc3fffd14e8e3a197211788
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2017-11-14 15:54:56 +00:00
Thiago Macieira
4870282117 QSemaphore: fix regression when the timeout < 0
The issue was introduced by eaee1209f0, so
it affected only 5.9.2.

[ChangeLog][QtCore][QSemaphore] Fixed a regression that would make
tryAcquire() not to wait forever if the timeout was a negative
value. Note: new code is advised to only use -1 to indicate "forever",
as some other functions taking timeout periods do not accept other
values.

Task-number: QTBUG-64413
Change-Id: I57a1bd6e0c194530b732fffd14f58fce60d5dfc9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-14 11:07:30 +00:00
Tony Sarajärvi
212f92182a Merge "Merge remote-tracking branch 'origin/5.9' into 5.10" into refs/staging/5.10 2017-11-12 15:35:48 +00:00
Sami Nurmenniemi
3c63c8d2f2 Blacklist tst_qstandardpaths::testFindExecutable for b2qt/arm64
Task-number: QTBUG-64404
Change-Id: Ie04cf67574c4eb8b8e5bdb78e8e30173042edab7
Reviewed-by: Liang Qi <liang.qi@qt.io>
2017-11-12 15:35:21 +00:00
Thiago Macieira
08bf28de03 QRandomGenerator: add more of the std Random Engine API
This brings us to almost parity with the C++11 Random Engine API
requirements (see chapter 26.5.1.4 [rand.req.eng]). We don't implement
the templated Sseq requirements because it would require moving the
implementation details to the public API. And we don't implement the
<iostreams> code because we don't want to.

Change-Id: Icaa86fc7b54d4b368c0efffd14f05ff813ebd759
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-11 08:11:07 +00:00
Thiago Macieira
cfad4e298f QRandomGenerator: add securelySeeded(), to ensure appropriate seeding
Since we don't document how many bytes one needs (it's 2496), it's
difficult for the caller to provide just enough data in the seed
sequence. Moreover, since std::mt19937 doesn't make it easy to provide
the ideal size either, we can't actually write code that operates
optimally given a quint32 range either -- we only provide it via
std::seed_seq, which is inefficient.

However, we can do it internally by passing QRandomGenerator to the
std::mersenne_twister_engine constructor, as it's designed to work.

Change-Id: Icaa86fc7b54d4b368c0efffd14f0613c10998321
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-11 08:11:03 +00:00
Thiago Macieira
af456842e1 Change QRandomGenerator to have a deterministic mode
Now only QRandomGenerator::system() will access the system-wide RNG,
which we document to be cryptographically-safe and possibly backed by a
true HWRNG. Everything else just wraps a Mersenne Twister.

Change-Id: I0a103569c81b4711a649fffd14ec8cd3469425df
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-11 08:11:00 +00:00
Thiago Macieira
4502999ff0 QRandomGenerator: remove the per-thread buffer
Since we're adding a deterministic generator that inherently does not
use syscalls, and people should really use that one by default, there is
no point in optimizing the secure generator wrt syscalls. Besides,
keeping the random data in memory for longer than needed is likely
inadviseable.

Change-Id: Ib17dde1a1dbb49a7bba8fffd14ed0871117fe930
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-11 08:10:58 +00:00
Liang Qi
88cf044580 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/gui/kernel/qwindow.cpp
	src/plugins/platforms/cocoa/qcocoawindow.mm
	src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
	src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
	tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
	tests/auto/widgets/kernel/qaction/tst_qaction.cpp

Change-Id: Ifa515dc0ece7eb1471b00c1214149629a7e6a233
2017-11-09 11:47:57 +01:00
Oliver Wolff
579d0cb2be Fix tst_QFile::openDirectory for systems using builtin test data
To obtain "proper" directory behavior, we have to check against the
extracted "resources" directory instead of its qrc counterpart.

Change-Id: I4996ba74419945f78d356ad953a5b826ff663687
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-09 07:33:38 +00:00
Oliver Wolff
82c3c9d45d Fix tst_QFile::handle for systems using builtin test data
To obtain the file's handle, we need to obtain it from the extracted
test data instead of qrc.

Change-Id: I89c5c3f3a7da7e36205a439581a6d83efffdc07c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-11-09 07:33:37 +00:00
Oliver Wolff
bbc68dc815 Fix tst_QFile::useQFileInAFileHandler for systems using resources for test data
Resource files are extracted to m_dataDir in tst_QFile::initTestCase.
Instead of trying to access the file from the resource on systems that
use qrc for bundling the test data, we have to use the files that were
extracted at the beginning of the test.

Change-Id: I35453fbdeb27e317d1342ff1cb7bbea9cebea14d
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-11-09 07:33:35 +00:00
Oliver Wolff
e27bd98137 qfile tests: Make sure files are writable before deleting them
On some platforms (like UWP) files that are copied during
qfile auto tests are not writable by default. The cleanup will fail for
these files if the permissions are not set accordingly.

Change-Id: Id925dcadfc6b505c87f1f55d5ea05e286b60a5a5
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-11-09 07:33:35 +00:00
Thiago Macieira
19b0ce5daa Change almost all other uses of qrand() to QRandomGenerator
The vast majority is actually switched to QRandomGenerator::bounded(),
which gives a mostly uniform distribution over the [0, bound)
range. There are very few floating point cases left, as many of those
that did use floating point did not need to, after all. (I did leave
some that were too ugly for me to understand)

This commit also found a couple of calls to rand() instead of qrand().

This commit does not include changes to SSL code that continues to use
qrand() (job for someone else):
  src/network/ssl/qsslkey_qt.cpp
  src/network/ssl/qsslsocket_mac.cpp
  tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp

Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-08 09:14:03 +00:00
Edward Welbourne
90a78c9724 Fix typo in tst_QTimeZone::testEpochTranPrivate()
The milli-seconds since epoch value for an invalid transition is,
of course, invalidMSecs(), not invalidSeconds().
Added a comment while I was at it, explaining why we expect a
transition before the epoch, if such transitions are supported.

Change-Id: I0f376f9d69c0e6e79a309dc011943baa41175135
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-06 09:54:20 +00:00
Liang Qi
a7e4b645dc Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
	src/corelib/global/minimum-linux.S
	src/network/access/qhttpthreaddelegate.cpp
	src/widgets/kernel/qwidgetwindow.cpp

Change-Id: Id2e817e85f85c68f5482c9a12912d35590f9d5f8
2017-11-05 18:02:18 +01:00
Jake Petroules
cd542a82b0 Remove references to obsolete platforms
ultrix and reliant have not seen a release since 1995. dgux not since
2001. bsdi not since 2003. irix not since 2006. osf not since 2010.
dynix... unclear, but no later than 2002. symbian needs no mention.
All considered obsolete, all gone.

sco and unixware are effectively obsolete. Remove them until someone
expresses a real need.

Change-Id: Ia3d9d370016adce9213ae5ad0ef965ef8de2a3ff
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-05 06:33:53 +00:00
Gatis Paeglis
ad36da8ff4 testlib: start sharing common helper functions
... by moving them in QTestPrivate namespace (qtesthelpers_p.h). This
header file is a convenient staging area for helper APIs, eventually
some could be moved to public QTest API.

This header file utilizes the same pattern as other qtestlib header
files - wrapping functions with QT_${LIBNAME}_LIB to automatically
enable certain APIs based on what is in the projects dependencies,
e.g. QT += widgets.

Change-Id: Ic0266429939c1f3788912ad8b84fc6e0d5edd68b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-11-04 20:11:22 +00:00
Friedemann Kleint
254849b62a macOS: Blacklist tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations()
Task-number: QTBUG-64109
Change-Id: Iebe5a07d108ba647baa74ded71b730c867bd1c41
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2017-11-03 21:15:08 +00:00
Liang Qi
17d5141113 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/plugins/platforms/windows/qwindowswindow.cpp
	tests/auto/widgets/kernel/qaction/tst_qaction.cpp

Change-Id: Ia017a825ed2ca2d53ac586f4ae48df6f65818d40
2017-10-30 08:54:05 +01:00
Thiago Macieira
0e0f656f50 Mark the previously public qstringalgorithms.h functions private
Discussed during Qt Contributor Summit 2017. We concluded that we don't
want to make these functions public, as they do not follow Qt coding
style API. Specifically,

   qStartsWith(a, b)

is not easily understood which argument is the needle and which argument
is the haystack (same problem memcpy() has). Compare that to

   a.startsWith(b)

which can clearly be read in English as a subject-verb-object sentence.

This commit removes the unit tests that called compare().

Discussed-on: http://lists.qt-project.org/pipermail/development/2017-October/031060.html
Change-Id: Icaa86fc7b54d4b368c0efffd14ee6205eb9043fb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-10-29 10:13:13 +00:00
Thiago Macieira
81f2516600 QRandomGenerator: add system() and global()
Right now,this does really nothing. This commit is just to allow us to
transition the other modules (besides qtbase) to use the syntax that
will become the API.

I've marked three places to use the system CSPRNG:
 1) the QHash seed
 2) QUuid
 3) QAuthenticator

I didn't think the HTTP multipart boundary needed to be
cryptographically safe, so I changed that one to the global generator.

Change-Id: Ib17dde1a1dbb49a7bba8fffd14ecf1938bd8ff61
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-10-29 10:13:01 +00:00
Friedemann Kleint
1c3dc8cfb8 tst_QFile::largeUncFileSupport(): Use QTRY_VERIFY() to open the file
Open failures due to sharing violations have been observed in Coin.

Change-Id: If7fbe01a454b3c343c0b87f73db50c28eae901c3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
2017-10-27 20:02:58 +00:00
Friedemann Kleint
cd45d0f712 tst_QFile: Introduce StdioFileGuard
Guard the FILE * obtained by fopen() by a RAI class ensuring
the file is closed on destruction.

Change-Id: I9297f91ca2120238f3a44bad92bca5f920e01aa8
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
2017-10-27 20:02:53 +00:00
Thiago Macieira
9574436666 QUrl: make sure setPort(nonnegative) is taken as part of authority
There were a couple of corner cases where doing setPort() would result
in QUrl thinking that an authority was not present. Since the full URL
parsing implies that a host is always present if the authority is
present, then we also imply that setting the port number makes the host
be present too.

Change-Id: I69f37f9304f24709a823fffd14e67c12da18d69f
Reviewed-by: David Faure <david.faure@kdab.com>
2017-10-26 04:46:04 +00:00
Liang Qi
4f9b2cb026 Remove duplicate qnx from the platform file selector names
Update the QFileSelector tests for QNX.

Co-authored-by: James McDonnell <jmcdonnell@blackberry.com>
Change-Id: I68a8fde86725596323b539433287ac1a18fac1eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-10-24 16:43:39 +00:00
Allan Sandfeld Jensen
fa9d12f4a2 Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
	src/plugins/platforms/windows/qwindowsmousehandler.cpp
	src/plugins/platforms/xcb/qxcbimage.cpp
	tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
	tests/manual/qtabletevent/regular_widgets/main.cpp

Done-with: Friedemann Kleint<Friedemann.Kleint@qt.io>
Done-with: Mårten Nordheim<marten.nordheim@qt.io>
Change-Id: I5b2499513a92c590ed0756f7d2e93c35a64b7f30
2017-10-24 13:40:55 +02:00
Liang Qi
32f50225c4 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/plugins/platforms/direct2d/direct2d.pro
	src/plugins/platforms/ios/qiosclipboard.mm
	src/plugins/platforms/windows/windows.pro

Change-Id: Idffa03b3990bd642784f528821c5446b2e1008ef
2017-10-23 09:40:54 +02:00
Sami Nurmenniemi
9c58dd1588 Blacklist and skip failing tests for Boot2Qt / 64 bit arm
Task-number: QTBUG-60263
Change-Id: I05978915b5bb7ae31069e8e9ae1dc273e483ddb0
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2017-10-21 09:31:01 +00:00
Thiago Macieira
c90d9f95d2 QRandomGenerator: improve floating-point random generation
The previous version was good, just not optimal. Because the input was
an unsigned 64-bit number, compilers needed to generate extra code to
deal with HW instructions that only convert 64-bit signed input. And
that was useless because a double uniformly distributed from 0 to 1 can
only have 53 bits of randomness.

The previous implementation did exactly what the Microsoft libstdc++ and
libc++ implementations do. In my opinion, those implementations have an
imperfect distribution, which is corrected in this commit. In those, all
random input bigger than 0x20000000000000 has a different frequency
compared to input below that mark. For example, both 0x20000000000000
and 0x20000000000001 produce the same result (4.8828125e-4).

What's more, for the libc++ and MSVC implementations, input between
0xfffffffffffff001 and 0xffffffffffffffff results in 1.0 (probability 1
in 2⁵³), even though the Standard is very clear that the result should
be strictly less than 1. GCC 7's libstdc++ doesn't have this issue,
whereas the versions before would enter an infinite loop.

Change-Id: Ib17dde1a1dbb49a7bba8fffd14eced3c375dd2ec
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-10-20 18:10:33 +00:00
Orgad Shaneh
0354ba816f Clean dynamic function resolving done for XP in QFileInfo tests
Change-Id: I15364b1e8c4f4406fef2be68ca221a8867d0dcfa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-10-19 10:59:04 +00:00
Liang Qi
7e4571b7e7 Merge "Merge remote-tracking branch 'origin/5.9' into 5.10" into refs/staging/5.10 2017-10-17 18:29:37 +00:00
Liang Qi
d0a0a3c041 Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
	examples/network/fortuneclient/client.cpp
	examples/network/fortuneserver/server.cpp
	src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h
	src/plugins/platforms/cocoa/qcocoabackingstore.h
	src/plugins/platforms/cocoa/qcocoaintegration.h
	src/plugins/platforms/cocoa/qcocoascreen.h
	src/plugins/platforms/ios/qiosbackingstore.h
	src/plugins/sqldrivers/oci/qsql_oci.cpp
	src/widgets/kernel/qwidgetwindow.cpp

Change-Id: Ia6dd2c52d4a691b671cf9a2ffca70deccece8f10
2017-10-17 10:34:24 +02:00
Liang Qi
01afc8c810 Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: I3cf73c53cf131d0babfb558c2507bed0e0fc5f08
2017-10-16 22:21:52 +03:00
Thiago Macieira
65eed6d597 configure: make C++11 <random> a required functionality
Error out if it's missing or broken (Mersenne Twister not present).

This ensures that we never have a low-quality random generator in Qt.

Change-Id: I0a103569c81b4711a649fffd14ec80649df7087e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-10-16 16:25:34 +00:00
Joerg Bornemann
b5f2bf1a71 Fix QWinEventNotifier for auto-reset events
Auto-reset events are automatically reset to non-signaled when we get
notified about the signaled state. This implies that we cannot check the
event state again in activateEventNotifiers. Instead, store the signaled
state in a QAtomicInt and test and decrement that.

This amends commit 85403d0a.

Task-number: QTBUG-63555
Change-Id: I0adee3d2929783f98d91060f9106c8b5266d72fa
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-10-15 16:14:04 +00:00
Thiago Macieira
f27e029ef2 Autotest: use _exit() instead of exit() to simulate an unclean exit
We're not going to crash to avoid core dumps getting recorded by
systemd, filling up filesystems or showing dialog boxes. We just need to
exit without running destructors. Now, exit() isn't supposed to run
function-scope destructors, so just in case we use _exit().

Change-Id: I0b48fc8e90304e0dacc3fffd14e909ff248ce1a1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-10-08 06:41:05 +00:00
Giuseppe D'Angelo
cb08b40976 Move detection of <future> to a configure test
<future> is needed by QThread::create. Instead of a fragile series
of preprocessor tests, move its detection to a configure test.
This dramatically simplifies the code, but on the other hand ties
the availability of QThread::create() to the system used to compile
Qt (rather the one used to compile an application).

Change-Id: If1b06363379bf29126cfa68f2a0651cbb78a67f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-10-06 05:51:54 +00:00
Thiago Macieira
f62768d046 QUrl: re-fix the setPath("//path") case leading to scheme://path
Commits aba336c2b4 (in Qt 5.2) and
aba336c2b4 (in 5.6) both tried to deal
with this problem, with different levels of success. This is the third
attempt (and hopefully the charm).

Instead of modifying the path that the user provides, go straight ahead
and declare it invalid. This is supported by RFC 3986, which declares
this expansion impossible:

   relative-part = "//" authority path-abempty
                 / path-absolute
                 / path-noscheme
                 / path-empty
   path-abempty  = *( "/" segment )
   path-absolute = "/" [ segment-nz *( "/" segment ) ]
   path-noscheme = segment-nz-nc *( "/" segment )

The "path-abempty" and "path-noscheme" cases are the two issues we
already handle. This commit adds the third one: path-absolute, which
requires that the first segment of the path be of non-zero length.

That is, it is now possible again to have http://example.com//path
constructed piece-wise, without it producing http://example.com/path.
Additionally, it catches the case of http://example.com//path parsed
from full URL then followed by setAuthority("").

Change-Id: I69f37f9304f24709a823fffd14e67a5e7212ddcd
Reviewed-by: David Faure <david.faure@kdab.com>
2017-10-06 03:49:40 +00:00
Tor Arne Vestbø
08e083e682 Ensure result of all QTest::qWaitFor are verified
The qWaitFor functions themselves can not trigger a test failure, as that
will not result in the test function exiting early, so every single call
to qWaitFor needs to be wrapped in a QVERIFY.

Change-Id: Id15a1549f31d06cdbf788e1d84ea431c28636ec8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-10-05 15:15:36 +00:00
Svenn-Arne Dragly
ba423261cd Improve performance in QThreadPool
When many runnables are executed, this improves the
performance by not resizing the queue for each runnable,
which was the case in the previous version, because of
many calls to QVector::takeFirst().

Also add a test that makes sure tryTake() is safe to
call and does not leave the queue in a bad state that
tries to use nullptr entries.

Change-Id: I608134ecfa9cfc03db4878dcbd6f9c1107e13e90
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-10-04 12:00:33 +00:00
Tor Arne Vestbø
c3e93391ee qmake: Allow non-bundle apps and libs to have an Info.plist
Change-Id: I5fe5c8d3214876520b5259d478ac9ef887c61e95
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-09-29 10:08:08 +00:00
Jake Petroules
7fd3cc3980 Clean up OS version checks for Apple platforms
Convert QSysInfo/QOperatingSystemVersion to __builtin_available where
required or possible, or to QOperatingSystemVersion where
__builtin_available cannot be used and is not needed (such as negated
conditions, which are not supported by that construct).

Change-Id: I83c0e7e777605b99ff4d24598bfcccf22126fdda
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-29 03:30:13 +00:00
Thiago Macieira
f7350ac99e Improve qustrlen further by avoiding the alignment prologue
This avoids looping prior to the main 16-byte loop, by performing one
load that may include bytes prior to the start of the string. This is
guaranteed not to fault, since str points to a valid character, but it
may cause Valgrind to print warnings.

Change-Id: I6e9274c1e7444ad48c81fffd14dcae854bba24b2
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-26 18:19:35 +00:00
Liang Qi
aadfe7d634 Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
	src/gui/kernel/qguiapplication.cpp
	src/platformsupport/input/libinput/qlibinputpointer.cpp
	src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
	src/plugins/platforms/cocoa/qcocoawindow.h
	src/testlib/qtestsystem.h

Change-Id: I5975ffb3261c2dd82fe02ec4e57df7c0950226c5
2017-09-26 16:14:54 +02:00
Thiago Macieira
282065d443 QRandomGenerator: update API to better name
"generate" is better than "get", and we already have "generate(it, it)"
which uses std::generate(). This changes:

 - get32()    →   generate()
 - get64()    →   generate64() and QRandomGenerator64::generate()
 - getReal()  →   generateDouble()

Change-Id: I6e1fe42ae4b742a7b811fffd14e5d7bd69abcdb3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-09-22 15:29:42 +00:00
Liang Qi
01bc69f99f Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/plugins/styles/mac/qmacstyle_mac.mm
	src/widgets/util/qcompleter.cpp
	src/widgets/widgets/qmainwindowlayout.cpp
	src/widgets/widgets/qmdisubwindow.cpp

Change-Id: If0e96981af07ce36ac68f2e69211bc2120f93973
2017-09-20 11:58:32 +02:00
Kevin Funk
58c14c4a7e Replace Q_NULLPTR with nullptr where possible
Remaining uses of Q_NULLPTR are in:
src/corelib/global/qcompilerdetection.h
  (definition and documentation of Q_NULLPTR)
tests/manual/qcursor/qcursorhighdpi/main.cpp
  (a test executable compilable both under Qt4 and Qt5)

Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-09-19 11:53:55 +00:00
Kevin Funk
47c92fbb0b Replace Q_DECL_OVERRIDE with override where possible
Remaining uses of Q_DECL_OVERRIDE are in:

src/corelib/global/qcompilerdetection.h
src/corelib/global/qglobal.cpp
doc/global/qt-cpp-defines.qdocconf
  (definition and documentation of Q_DECL_OVERRIDE)
tests/manual/qcursor/qcursorhighdpi/main.cpp
  (a test executable compilable both under Qt4 and Qt5)

Change-Id: Ib9b05d829add69e98a86238274b6a1fcb19b49ba
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-09-19 11:53:42 +00:00
Jake Petroules
83122b1932 Remove unnecessary VxWorks ifdef
Change-Id: Ie655bdff9a09c6060f66e4346b94ba52443241f4
Reviewed-by: Tuomas Heimonen <tuomas.heimonen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-18 21:06:25 +00:00
Jake Petroules
69b16a46e8 Exclude QSystemSemaphore test with -no-feature-systemsemaphore
Change-Id: I9db6b68c3d26b27a0203c68c48ab73602eb15095
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
2017-09-18 08:56:53 +00:00
Giuseppe D'Angelo
fc208838ae QScopedPointer: add get()
For self-consistency with QSharedPointer and minor consistency
with std::unique_ptr (although QScopedPointer isn't movable, so we
can't claim STL compatibility with it).

[ChangeLog][QtCore][QScopedPointer] Added get().

Change-Id: Ib58f936afa0e0d5bce57a61d1467b69956f37ceb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-17 11:42:26 +00:00
Giuseppe D'Angelo
72f700edd6 tst_qidentityproxymodel: map the index to the source model
In data(), index belongs to the proxy, not to the source. It needs
to be mapped back to it first.

Change-Id: Ie5dcbf13166dadf62f3d85b594d3227383132521
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-09-15 13:52:10 +00:00
Jake Petroules
7127202358 Exclude tst_QDir::mkdirOnSymlink on Unix platforms without symlinks
One example is VxWorks.

Change-Id: I253df715a9417c1f9cede79b1e1860924e0da8a9
Reviewed-by: Tuomas Heimonen <tuomas.heimonen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-09-15 11:20:32 +00:00
Thiago Macieira
3b61cd6ad7 QStringView: De-inline the length calculation so we can use SSE2
Performance is more important in this case than the theoretical benefit
of constexpr. This commit implements the SSE2 search for 16-bit null and
it might be possible to implement the equivalent for AArch64
(investigation required). It also adds a fallback to wcslen() for
systems where wchar_t is short (non-x86 Windows or 32-bit x86 build with
-no-sse2).

We can re-add the constexpr loop once the C++ language has a way of
overloading constexpr and non-constexpr. GCC has a non-standard way to
do that with __builtin_constant_p, which is also implemented in this
commit, but note that the inline function is still not constexpr.

Change-Id: I6e9274c1e7444ad48c81fffd14dcaacafda5ebdc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-13 16:19:45 +00:00
Ulf Hermann
3b5b8f1d4a QXmlStreamWriter: Avoid writing invalid characters
Some valid UTF-16 characters cannot be expressed in XML 1.0 and a
QString may contain invalid unicode. In both cases we should not write
the respective data to the output stream, as that generates invalid XML,
which then cannot be read back by QXmlStreamReader. In addition we
should report an error if we encounter them.

The change filters the incorrect strings from the output and introduces
an "encodingError" flag which is reported from hasError().

[ChangeLog][Important Behavior Changes] Characters invalid in XML, such
as 0x0 or 0xfffe, as well as strings containing unmatched UTF-16
surrogates are now suppressed from the output of QXmlStreamWriter and
cause the error flag to be set.

Task-number: QTBUG-63150
Change-Id: Ia29bab768fed9681dd68e8934da2a7e3fcdfc3cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-13 07:29:00 +00:00
Giuseppe D'Angelo
71a2dd955c QSharedPointer: add get() for STL compatibility
[ChangeLog][QtCore][QSharedPointer] Added get(), for compatibility
with std::shared_ptr.

Change-Id: I77189c89bc6a222313b9b2353f1fb3969433c750
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-09-12 14:05:21 +00:00
Tor Arne Vestbø
d2a988512e macOS: Detect use of heap-allocated QMacAutoReleasePool
QMacAutoReleasePool is backed by an NSAutoreleasePool, which documents that
"you should always drain an autorelease pool in the same context (invocation
of a method or function, or body of a loop) that it was created".

This means allocating QMacAutoReleasePool on the heap is not a supported
use-case, but unfortunately we can't detect it on construction time.

Instead we detect whether or not the associated NSAutoreleasePool has been
drained, and prevent a double-drain of the pool.

Change-Id: Ifd7380a06152e9e742d2e199476ed3adab326d9c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-08 12:05:21 +00:00
Liang Qi
19dd2ca93b Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	examples/opengl/qopenglwidget/main.cpp
	src/3rdparty/pcre2/src/pcre2_printint.c
	src/plugins/platforms/cocoa/qnsview.mm
	src/widgets/widgets/qcombobox.cpp

Change-Id: I37ced9da1e8056f95851568bcc52cd5dc34f56af
2017-09-06 13:26:31 +02:00
Orgad Shaneh
ced0f54ec3 Fix resolution of relative links on Windows
[ChangeLog][QtCore][QFileInfo] Relative symbolic links on Windows are
now resolved to their absolute path by symLinkTarget().

Task-number: QTBUG-62802
Change-Id: I5826517130bd389aef994bf3f4b6d99b2a91b409
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-09-04 07:35:09 +00:00
Thiago Macieira
541a031552 tst_QMutex: produce less noise with MSVC
Since MSVC doesn't have <chrono> (according to QT_HAS_INCLUDE), the QSKIP
in the test was printed for every line in the table. Instead, add the
skip in the _data() function.

Change-Id: I6e9274c1e7444ad48c81fffd14dbcee5e5a322aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-09-01 16:36:17 +00:00
Liang Qi
112a4af107 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	examples/examples.pro
	qmake/library/qmakebuiltins.cpp
	src/corelib/global/qglobal.cpp
		Re-apply b525ec2 to qrandom.cpp(code movement in 030782e)
	src/corelib/global/qnamespace.qdoc
	src/corelib/global/qrandom.cpp
	src/gui/kernel/qwindow.cpp
		Re-apply a3d59c7 to QWindowPrivate::setVisible() (code movement in d7a9e08)
	src/network/ssl/qsslkey_openssl.cpp
	src/plugins/platforms/android/androidjniinput.cpp
	src/plugins/platforms/xcb/qxcbconnection.cpp
	src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
	src/widgets/widgets/qmenu.cpp
	tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp

Change-Id: If7ab427804408877a93cbe02079fca58e568bfd3
2017-08-31 14:31:31 +02:00
Alex Trotsenko
ca0df4b269 Introduce QIODevice::skip()
[ChangeLog][QtCore][QIODevice] Added skip() method to improve
performance in read operations.

Change-Id: I79068a3e9df108756abe37ba3d431e27e7413621
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-27 06:17:09 +00:00
Orgad Shaneh
0f11fab6f7 Fix resolution of relative symlinks from relative path on unix
Consider the following:
/root/target - a file
/root/path/link -> ../target
/root/path/other/exe - executable

Running from /root/path/other.

exe is:

#include <QDebug>
#include <QFileInfo>

int main()
{
    qDebug() << QFileInfo("../link").symLinkTarget()
    return 0;
}

The link references /root/target, but the current output is
/root/path/target.

The link doesn't depend on the PWD. It depends on its own directory.

Change-Id: I61e95018154a75e0e0d795ee801068e18870a5df
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-27 02:39:57 +00:00
Thiago Macieira
189e9c93d7 QTemporaryFile: Add support for Linux's O_TMPFILE
That means a file is never created, unless you ask for the name. There's
no chance of left-over temporary files being left behind. QSaveFile also
benefits from this, since the save file is not present on disk until
commit(). Unfortunately, QSaveFile must go through a temporary name
because linkat(2) cannot overwrite -- we need rename(2) for that (for
now).

[ChangeLog][Important Behavior Changes][QTemporaryFile] On Linux,
QTemporaryFile will attempt to create unnamed temporary files. If that
succeeds, open() will return true but exists() will be false. If you
call fileName() or any function that calls it, QTemporaryFile will give
the file a name, so most applications will not see a difference.

Change-Id: I1eba2b016de74620bfc8fffd14cc843e5b0919d0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-23 04:02:19 +00:00
Morten Johan Sørvig
d044b0b1e3 Remove timer checks from testQuitLock
This test sets up two timers:
	- a 100ms recurring timer
	- a series of 10 200ms single-shot timers.

After quitLock lets exec() return it then uses a signal
spy to check if the 100ms timer fired at least 17/20
of the times it should.

However there is no guarantee that the 100ms timer
will fire more often than the 200ms timer. If the
native timer callbacks happen at 500ms intervals then
Qt will fire both timers (once) at that interval.

In practice this seems to happen on macOS CI under
system load and/or with the test app napping.

The primary goal for the test is to verify that exec()
returns when it should; we can remove the timer signal
spy.

Remove testQuitLock from BLACKLIST.

Timely timer:

  524429311.389913 runLoopTimerCallback
  524429311.389979 200ms fire
  524429311.389997 100ms fire
  524429311.490056 runLoopTimerCallback
  524429311.490130 100ms fire
  524429311.589752 runLoopTimerCallback
  524429311.589929 200ms fire
  524429311.589976 100ms fire

Delayed timer:

  524429428.690887 runLoopTimerCallback
  524429428.691002 100ms fire
  524429428.691143 200ms fire
  524429433.692103 runLoopTimerCallback
  524429433.692205 100ms fire
  524429433.692331 200ms fire

Change-Id: Iff4faaa1de3741cf4e217949d5ed17d4e70c6af2
Task-number: QTBUG-61499
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2017-08-22 05:10:48 +00:00
Liang Qi
106d3b9bf9 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/plugins/platforms/cocoa/qcocoamenu.h
	src/plugins/platforms/cocoa/qcocoamenu.mm
	src/plugins/platforms/cocoa/qcocoawindow.mm
	src/widgets/styles/qstylehelper_p.h

Change-Id: I54247c98dd79d2b3826fc062b8b11048c9c7d9bb
2017-08-15 16:31:48 +02:00
Thiago Macieira
10b46fe474 Autotest: Fix test when running on a non-Unicode-capable locale
Like my default FreeBSD environment.

Change-Id: I3868166e5efc45538544fffd14d8a7f2dffa6ac9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-12 07:56:39 +00:00
Thiago Macieira
5d2240718c Autotest: fix blacklisted test about position on non-regular files
On BSD systems (tested on macOS and FreeBSD), you *can* lseek(2) or
ftell(3) on a pipe and get its current position. But QFile will not get
the position when the file is sequential, so we need to return 0.

Technically speaking, we ought to do the same for block devices, but if
you're redirecting stdin, stdout or stderr in the unit test to or from a
block device, you deserve the extra work to add that yourself to the
test.

Change-Id: I3868166e5efc45538544fffd14d8a74e92963fe7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
2017-08-08 21:48:28 +00:00
Thiago Macieira
6504bc6bbc QFileInfo: harmonize QFileInfo() and QFileInfo("")
If a QFileInfo was constructed with an empty path, which could happen
with QFileInfo(QFile()) or via QDir, etc., then it would issue system
calls to empty paths and could even produce warnings. This commit makes
am empty path name be the same as a default-constructed QFileInfo and
corrects the use if 0 for ownerId and groupId to match the
documentation.

[ChangeLog][Important Behavior Changes] QFileInfo on empty strings now
behaves like the default-constructed QFileInfo. Notably, path() will now
be the empty string too, instead of ".", which means absoluteFilePath()
is no longer the current working directory.

Change-Id: I8d96dea9955d4c749b99fffd14ce34968b1d9bbf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-08 21:48:23 +00:00
Thiago Macieira
883dfb3d15 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/widgets/kernel/qwidget.cpp

This merge also extends the expected output of the pairdiagnostics
teamcity output (added in dev in commit
c608ffc56a) after the recent addition of
the flowId attribute to the teamcity output (commit
8f03656211 in 5.9).

Change-Id: I3868166e5efc45538544fffd14d8aba438f9173c
2017-08-08 11:48:10 +02:00
Thiago Macieira
6c3a3d498a Filesystem: Use "birth time" to avoid confusion with Unix ctime
The Unix stat fields "st_ctime" and "st_ctim" mean "change time", the
last time that the file/inode status fields were changed. It does not
mean "creation time". So this commit splits all of the internal API to
"birth" and "metadata change" instead of "creation" to avoid the
conflict.

Change-Id: I149e0540c00745fe8119fffd1463fe78b619649e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-05 16:41:38 +00:00
Thiago Macieira
261c6713bd Introduce QFileInfo::birthTime and metadataChangeTime
[ChangeLog][QtCore][QFileInfo] Deprecated created() because it could
return one of three different file times depending on the OS and
filesystem type, without the ability to determine which one is which. It
is replaced by metadataChangeTime() and birthTime().

[ChangeLog][QtCore][QFileInfo] Added QFileInfo::metadataChangeTime(),
which returns the time the file's metadata was last changed, if it is
known, and falling back to the same value as lastModified() otherwise.
On Unix systems, this corresponds to the file's ctime.

[ChangeLog][QtCore][QFileInfo] Added QFileInfo::birthTime(), which
returns the file's birth time if it is known, an invalid QDateTime
otherwise. This function is supported on Windows and on some Unix
systems.

Change-Id: I0031aa609e714ae983c3fffd1467bd8b3e3a593d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-08-05 16:41:32 +00:00
Thiago Macieira
4934138be2 Allow QSettings to synchronize non-atomically
This is required so that one can use QSettings in situations that
temporary files or renaming may not work.

[ChangeLog][QtCore][QSettings] Added setAtomicSyncRequired(), which
allows one to use QSettings with config files in unwriteable directories
or in Alternate Data Streams on NTFS on Windows. This used to work
before Qt 5.4, but remains a non-default behavior due to the potential
of data corruption.

Task-number: QTBUG-47379
Change-Id: I81480fdb578d4d43b3fcfffd14d4f77112f0402f
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2017-08-04 17:30:16 +00:00
Thiago Macieira
66500b9d75 Support Alternate Data Streams in QSaveFile
We can't use MoveFile to do atomic commits on an ADS, so QSaveFile needs
to detect when the target name is ADS and then use the direct fallback
mode.

[ChangeLog][QtCore][QSaveFile] Saving to Alternate Data Streams on NTFS
on Windows is now possible, but requires setDirectWriteFallback(true).

Task-number: QTBUG-47379
Change-Id: I81480fdb578d4d43b3fcfffd14d4bc062ae1750d
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2017-08-04 17:30:13 +00:00
Thiago Macieira
3d6cbe3409 Long live QTemporaryFileName!
So we can use it in QTemporaryFile, QTemporaryDir and QFile::rename()

[ChangeLog][QtCore][QTemporaryDir] The class now supports the "XXXXXX"
replacement token anywhere in the template, not just at the end. This
behavior is similar to what QTemporaryFile supports.

Change-Id: I1eba2b016de74620bfc8fffd14ccb645729de170
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-08-04 17:30:03 +00:00
Allan Sandfeld Jensen
74197140be Implement conversion from nullptr QVariant to QString and QByteArray
A nullptr QVariant should become a null QString or QByteArray,
since null strings have previous in our APIs represented the null value
in the absence of a dedicated null metatype.

Change-Id: I3b8f6386ece314d7c196959fbcf042c4fe0508a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-04 11:19:44 +00:00
Edward Welbourne
a9c111ed8c Clean-up in QDateTime's parsing of ISODate{,WithMs}
Actually check that there's a T where ISO 8601 wants it (instead of
just skipping over whatever's there), with something after it; move
some declarations later; add some comments; and use the QStringRef API
more cleanly (so that it's easier to see what's going on).  Simplify a
loop condition to avoid the need for a post-loop fix-up.

This incidentally prevents an assertion failure (which brought the
mess to my attention) parsing a short string as an ISO date-time; if
there's a T with nothing after it, we won't try to read at index -1 in
the following text.  (The actual fail seen had a Z where the T should
have been, with nothing after it.)

Add tests for invalid ISOdate cases that triggered the assertion.

Change-Id: Ided9adf62a56d98f144bdf91b40f918e22bd82cd
Reviewed-by: Israel Lins Albuquerque <israelins85@yahoo.com.br>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-04 11:19:35 +00:00
Allan Sandfeld Jensen
f2c6e10ad5 QVariants of null pointers should be null
Changes the QVariant::isNull() implementation for
pointer types so they return true if null.

[ChangeLog][QVariant] QVariants containing pointers will now return
true on isNull() if the contained pointer is null.

Change-Id: I8aa0dab482403837073fb2f376a46126cc3bc6b2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-04 11:19:25 +00:00
Thiago Macieira
b12fd1fa9d Long live qEnvironmentVariable()
[ChangeLog][QtCore] Added qEnvironmentVariable, which returns the value
of an environment variable in a QString, while qgetenv continues to be
used to return it in a QByteArray. For Unix, since most environment
variables seem to contain path names, qEnvironmentVariable will do the
same as QFile::decodeName, which means NFC/NFD conversion on Apple OSes.

I opted not to #include <qfile.h> from qglobal.cpp to implement that
QFile::decodeName functionality, so qglobal.cpp doesn't depend on
corelib/io and to avoid possible recursions.

Task-number: QTBUG-41006
Change-Id: I14839ba5678944c2864bffff141794b8aaa7aa28
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-04 11:19:13 +00:00
Oswald Buddenhagen
d61ac601d8 unbreak tst_qresourceengine for prefix builds
don't try to execute a binary from the install dir.

amends 8e776d39f.

Change-Id: I37990bc83b295379f0c93f4ca712e1bbf980fd44
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2017-08-03 04:54:56 +00:00
Frederik Gladhorn
6c2bfbf88e Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/dev 2017-08-02 23:15:27 +00:00
Morten Johan Sørvig
e44ff19783 Add QThreadPool::stackSize
Allows setting the stack size for the thread pool
worker threads. Implemented using QThread::stackSize.

Task-number: QTBUG-2568
Change-Id: Ic7f3981289290685195bbaee977a23e0c3c49bf0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2017-08-02 21:58:54 +00:00
Allan Sandfeld Jensen
bef7e4a222 Allow conversion of QVariants with real null values
Update documentation to be clearer on the special null variant state
with no value as opposed to a variant with a null value, and only block
conversions of the former.

Change-Id: I24fd50285414e049de87de54a63700a89bd5adf1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-02 21:09:19 +00:00
Oswald Buddenhagen
ee07b912a1 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/plugins/platforms/xcb/qxcbconnection.h
	src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
	src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
	src/plugins/styles/mac/qmacstyle_mac.mm
	src/widgets/widgets/qdockarealayout.cpp
	src/widgets/widgets/qmainwindow.cpp
	src/widgets/widgets/qmainwindowlayout.cpp
	src/widgets/widgets/qmainwindowlayout_p.h
	tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
	tests/auto/other/macnativeevents/BLACKLIST
	tests/auto/widgets/widgets/qmenu/BLACKLIST

Change-Id: Ic8e724b80a65e7b1af25511b0e674d209265e567
2017-08-02 22:52:32 +02:00
Edward Welbourne
60a9747bb5 Add a date-time test for time-zones near epoch and odd transitions
Check we do handle DST after epoch and don't before.
Check we do notice various unusual transitions.
Check we do handle non-whole-hour-offset zones.
(Unfortunately, MS-Win lacks data for some of the zones and is wrong
about the two date-line crossers, so we skip those for it.)

Change-Id: If420d61b9db7f914ca25c22297c16e917ad2307a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-31 09:24:31 +00:00
Joerg Bornemann
85403d0af0 Support more than 62 instances of QWinEventNotifier, take 2
QWinEventNotifiers were limited to 62 instances, because of
WaitForMultipleObject's limitation to MAXIMUM_WAIT_OBJECTS - 1 handles.

Use the RegisterWaitForSingleObject API which does not have this
restriction and executes waits in threads managed by the system. A
central manual reset event per event dispatcher is signaled in the
RegisterWaitForSingleObject callback and waited for in the event loop.

Task-number: QTBUG-8819
Change-Id: I3061811c18e669becf9de603bbdd7ba96e4d2fcd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2017-07-30 19:11:49 +00:00
Friedemann Kleint
3bdd59920f Refactor tst_qdir::entryList()
Split the test in two: one test that requires the symlinks
and test files and one that does not need them.
In the test with test files, verify each step and the deletion
of the files.

Task-number: QTBUG-58654
Task-number: QTBUG-50835
Change-Id: I14de57ce7a1df2d834d5a7565c804dead1d89088
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-29 09:51:50 +00:00
Edward Welbourne
8b628bb251 Add test for time zone transitions near the epoch
This needs a zone with transitions near the epoch; and the only CET
with DST that winter was Italy (copied by Malta), for which the Olson
database had a recent (2016) correction to its data, for that winter.
That means we get inconsistent results on O/Sen of different ages.

So add a separate testEpochTranPrivate(), alongside testCetPrivate(),
and test it with America/Toronto.  (Unfortunately, MS-Win gets the
date wrong on the first transition after the epoch, so we have to code
round that.)

Since information before the epoch isn't reliably available, only test
the search backwards if nextTransition does find something before it.
(We can safely assume all real transitions happened since 1601;
non-celestial time-keeping wasn't accurate enough, before that, for
anyone to synchronize with anything but celestial time.)

Change-Id: I984b46938a2805b93bb2afd6855e317b5d66b386
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-28 08:14:36 +00:00
Thiago Macieira
15df77f683 Fix use of getentropy on larger blocks
Found while working on suppressing the warning about the return value
(which is either 0 or -1) was being ignored.

Task-number: QTBUG-61968
Change-Id: I02d22222fff64d4dbda4fffd14d148b1724547ca
Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-27 23:19:05 +00:00
Thiago Macieira
7c45c6a3c4 Revert "Make QFile::open fail when using an invalid file name"
This reverts commit 346cd79192. The bug
report was incorrect, since the suggested file name is actually valid,
it just happens to name an Alternate Data Stream (ADS) "20:803Z.txt" in
file "testLog-03".

[ChangeLog][QtCore][QFile] Reverted an incorrect change from Qt 5.9.0
that forbade the creation and access to Alternate Data Streams on NTFS
on Windows. This means that file names containing a colon (':') are
allowed again, but note that they are not regular files.

Task-number: QTBUG-57023
Change-Id: I81480fdb578d4d43b3fcfffd14d4f2147e8a0ade
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2017-07-27 15:42:55 +00:00
Jüri Valdmann
af7e756155 Return "en" for QLocale::c().bcp47Name()
Currently QLocale::c().bcp47Name() returns "C" which, according to [BCP47], is
not a valid language tag. In particular it does not conform to the ABNF grammar
in section 2.1 which specifies a minimum length of 2 characters for all language
tags.

[BCP47]: https://tools.ietf.org/html/bcp47

This patch changes the return value to "en" seeing as the documentation for
QLocale::Language states that the C language is identical in behavior to
English.

Task-number: QTBUG-61949
Change-Id: I2a381def8fb7156467e01d105da92bb1f4821204
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-07-26 08:22:51 +00:00
Jüri Valdmann
2031196ad1 Add test for QLocale::bcp47Name()
Task-number: QTBUG-61949
Change-Id: I34fece0441afb1e69ea84ae59b90c5e2b7cf133f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-26 08:22:43 +00:00
Edward Welbourne
cff39f1818 tst_QTimeZone: improve readability of code and failure reports
When QCOMPARE(,) reports two 12-digit numbers, it's not always
immediately obvious what the difference is (much less what 1/3600000
of it is); nor is it obvious that (or why) a given 12-digit number is
in fact correct.  In contrast, our eyes can make sense of a
QDateTime's reported value quite well, enabling us to see what's
different; and it's possible to at least confirm the plausibility of
2-or-3 am on a spring or autumn day at a plausible transition (or even
to confirm it exactly by consulting suitable web-sites).  Also
document the actual transition happening in each case (since I *did*
consult a suitable web-site).  So prefer to QCOMPARE(,) two QDateTime
values instead of two 12-digit qint64s.

Where a that would be unsuitable, at least compare the difference to
zero, to make the error easier to understand (except when one of the
twelve-digit numbers consists entirely of 9s; that, for once, actually
is easy to see).

Write various multiples of 3600 as the relevant intelligible whole
number times 3600, rather than premultiplying, to make it obvious to
reders what's going on.

None of this changes what is actually tested.

Change-Id: I488e751283a55d4623c93612af13ad631144900d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-25 14:09:03 +00:00
Edward Welbourne
37b0a4d2e1 Fix a loop-test and the bogus data the loop expected
A loop initialized i = 0 and used i > 2 as its condition; it didn't
get very far.  Consequently, the test it was in never checked whether
CET's 2011 transitions happened at the times expected - which they
didn't, as the times in question were in fact the times at which
Pacific/Auckland had its transitions that year.

Change-Id: I94d1f8df615c5bcfe48e73d41b4c7faf2beccb96
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-25 14:08:55 +00:00
Allan Sandfeld Jensen
a06148e341 Improve symmetry of variant json conversions
Make QVariant::toJsonValue do conversions as well as
QJsonValue::fromVariant.

Change-Id: I175d43677061470691e2e0104a800be355fbbd3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-25 09:00:46 +00:00
Marc Mutz
94cf203f36 Use QSharedPointer::create() more
This is the result of running the (experimental) clang-tidy check
   qt-modernize-qsharedpointer-create

Discarded changes:

- tst_qsharedpointer.cpp: not sure we want these replacements there
  (→ separate change)
- tst_collations.cpp: hit in a template specialization that is
  instantiated with both QSharedPointer and QSharedDataPointer.

Change-Id: I203c2646e91d026735d923473af3d151d19e3820
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-19 13:40:42 +00:00
Morten Johan Sørvig
4585889467 Fix race condition in the processEvents test
This test verifies processEvents(WaitForMoreEvents)
behavior by first processing all pending events (in
a loop) and then verifying that a following processEvents
call actually waits.

But there is no guarantee that the OS won’t introduce
more events after the first loop has completed. This
does indeed seem to happen on recent versions of macOS.

Change the test to not require that the processEvents
call blocked and de-blacklist.

Task-number: QTBUG-61131
Change-Id: Ic8fa74a6085165442791264f6f137a2fa6083138
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2017-07-19 12:29:53 +00:00
Gabriel de Dietrich
d38fe875c7 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
    src/widgets/widgets/qmainwindowlayout.cpp

Change-Id: I306b4f5ad11bceb336c9091241b468d455fe6bb6
2017-07-13 16:36:10 -07:00
Allan Sandfeld Jensen
b3f7bea105 Handle conversion and comparison between qvarianthash and qvariantmap
QVariant claims to be able to QVariantHash and QVariantMap, but the
actual conversion implementation is missing.

Task-number: QTBUG-61471
Change-Id: I0cba74642aa77dc423effed289bc7619922a89eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-11 21:10:54 +00:00
Edward Welbourne
9381ca77b2 tst_QDateTime::toTimeSpec(): verify round-tripping works cleanly
Change-Id: I811fa4249dae923e5e4e434910d8bf96c15bff25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-07 18:09:33 +00:00
Edward Welbourne
cf9187f8c9 tst_QFileInfo: generalize old-file test
Now that QFileDevice::setFileTime() provides a portable way to prepare
our test file, we can verify QFileInfo does handle the distant past,
notably including negative time_t values.  The old MS-specific code
used a time back in 1601, which we can't hope to support
cross-platform, so use one in 1901 that's a little inside the range of
32-bit time_t.

Task-number: QTBUG-47985
Change-Id: I2de3e79d8c7864221f92395813b63f373e4d8a3b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-07 18:09:24 +00:00
Edward Welbourne
fcb423d1f2 Q(Date|Time)+: in QDebug's <<, handle invalid explicitly
The output didn't previously make clear that the datum was invalid.
It's now explicitly invalid.  At the same time, use QDebug's space()
and nospace() methods to make spacing choices explicit.
Revised a QDate test to match.

Change-Id: I4699f5897530b4caa31c22fdb07de149832b30f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-07 18:08:59 +00:00
Edward Welbourne
cc3b9cf3b3 Clarify tst_QDateTime::fromStringToStringLocale() using a macro
Separate the part varying between tests from the common form of all
the tests, so the reader can see the common pattern and know for sure
that there's not a typo or copy-and-paste glitch.

Change-Id: I3145a26ab42c104eb27756d906ac87f937024bad
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-07 18:08:51 +00:00
Thiago Macieira
bcd19b723a QLocale: fix handling of milliseconds in string format and document
[ChangeLog][QtCore][QLocale] Fixed the conversion of QTime to string
form and parsing from string form to always treat the value as the
decimal fraction of the seconds component. That is, the string format
".z" produces/parses ".2" for 200 milliseconds and ".002" for 2
milliseconds. Use of "z" or "zzz" is discouraged outside decimal
fractions to avoid surprises.

Task-number: QTBUG-53565
Change-Id: Ia19de85ad35e4eb7bb95fffd14792caf9b4a5156
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-07-07 07:21:53 +00:00
Friedemann Kleint
e1d7f7dfbc QFileSystemWatcher/Windows: Recreate handle for files
QWindowsFileSystemWatcherEngine uses one change notification
per directory to watch directories or files within that
directory. Adding files and their directories in a sequence
caused the value in QWindowsFileSystemWatcherEngineThread::HandleForDirHash
to be overwritten.
Relax the check for the flags (watcher attributes) to use >= and recreate
the change notification of a directory should its flags be insufficient.
This triggers when a file is added after its directory since files
require more attributes.

Task-number: QTBUG-61792
Change-Id: I371a72f1934fa82c53aaf84beb907825031f1c81
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-07 07:02:45 +00:00
Aram So
06904a7a77 Make calling QCoreApplication::translate() thread-safe
Fixed crash on QCoreApplication::translate() call from qqmlThread while
QCoreApplication::{install,remove}Translator() is called from the GUI
thread.

[ChangeLog][QtCore][QCoreApplication] Calling
QCoreApplication::translate() is now thread-safe.

Task-number: QTBUG-57095
Change-Id: Ie5340a42040a829f311c01332e05d4bbaf60462c
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2017-07-06 18:26:41 +00:00
Liang Qi
7f269a5db8 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	.qmake.conf

Change-Id: I43531e087bb810889d5c1fbfcdffb29b78804839
2017-07-06 13:54:25 +02:00
Friedemann Kleint
d3d5c22ccb tst_QProcess/tst_QFile: Extend blacklisting to MSVC2017
Extend the blacklisting introduced by
0ebebeb983.

Task-number: QTBUG-48455
Task-number: QTBUG-48504
Change-Id: Idf44948a5ede433435a8d0b61fef6413bb0b69bc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-07-05 12:42:14 +00:00
Liang Qi
c2b224a758 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/corelib/io/qprocess_unix.cpp
	src/plugins/platforms/xcb/qxcbconnection.cpp
	src/plugins/platforms/xcb/qxcbwindow.cpp
	src/widgets/util/util.pri
	tests/auto/corelib/thread/qthread/qthread.pro
	tests/auto/corelib/thread/qthread/tst_qthread.cpp

Change-Id: I5c45ab54d46d3c75a5c6c116777ebf5bc47a871b
2017-07-04 16:05:53 +02:00
Thiago Macieira
8616b2112c Fix parsing of 0E+1 and 0E-1 (capital 'E')
Since the result is an actual zero, this section of code looking for
underflows kicks in. But we forgot to take the capital letter into
account when parsing the number.

Task-number: QTBUG-61350
Change-Id: Ia53158e207a94bf49489fffd14c6abbd21f0bac0
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-07-03 16:01:01 +00:00
Edward Welbourne
f881120fd0 Fix offset calculation to be valid at the correct time
tst_QLocale::macDefaultLocale() was determining local-time's current
offset from UTC and using it when working out what to expect the
offset at 1:2:3 today to be.  When a transition happens after 1:2:3 on
its day (which is usual for DST changes in Europe), this lead to using
the new offset to test a time before the transition; the test was thus
wrong and failed.

Use the time to be tested (and current date) to compute the offset to
use, instead of using the current date-time.

Change-Id: I1c02a5579bca859e1d1aeb4f45b24871a08287af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-07-03 09:03:28 +00:00
Friedemann Kleint
9656e972d1 Remove remains of wince in .pro files
Task-number: QTBUG-52590
Change-Id: I444fc9eedc8a8e4ad2ede224d66e7c410bedbb48
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-07-03 05:32:51 +00:00
Sami Nurmenniemi
d23e18189c Skip QThread stress test on Qemu
Qemu uses some memory for each generated thread. This test creates
> 80000 threads and consumes about 10Gb of memory which is too
heavy for a VM.

Task-number: QTBUG-59966
Change-Id: I1bb8a0d7955778f5201948b41befcb9f1f391514
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-07-02 15:58:40 +00:00
Thiago Macieira
120ecc976f QRandomGenerator: use getentropy on Linux & OpenBSD
The getentropy function, first found in OpenBSD, is present in glibc
since version 2.25 and Bionic since Android 6.0 and NDK r11. It uses the
Linux 3.17 getrandom system call. Unlike glibc's getrandom() wrapper,
the glibc implementation of getentropy() function is not a POSIX thread
cancellation point, so we prefer to use that even though we have to
break the reading into 256-byte blocks.

The big advantage is that these functions work even in the absence of a
/dev/urandom device node, in addition to a few cycles shaved off by not
having to open a file descriptor and close it at exit. What's more, the
glibc implementation blocks until entropy is available on early boot, so
we don't have to worry about a failure mode. The Bionic implementation
will fall back by itself to /dev/urandom and, failing that, gathering
entropy from elsewhere in the system in a way it cannot fail either.

uClibc has a wrapper to getrandom(2) but no getentropy(3). MUSL has
neither.

Change-Id: Ia53158e207a94bf49489fffd14c8cee1b968a619
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-30 21:19:10 +00:00
Friedemann Kleint
5d31b52a12 Fix some MSVC warnings in tests
tst_qvariant.cpp(80): warning C4309: 'initializing': truncation of constant value
tst_qvariant.cpp(4635): warning C4309: 'initializing': truncation of constant value
tst_qbytearray.cpp(1438): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data
tst_qbytearray.cpp(1440): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data
http2srv.cpp(64): warning C4018: '<=': signed/unsigned mismatch
tst_qinputdialog.cpp(352): warning C4804: '<=': unsafe use of type 'bool' in operation

Change-Id: Id012d88b7b20c5c9f128f2ef53753cc1d479f358
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-28 17:58:13 +00:00
Friedemann Kleint
807f3d32b1 tst_QSharedPointer: Terminate hanging qmake-processes
Change-Id: I580ff3ccbecba81c09ce3fc3e082b906f956171d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-06-28 17:53:24 +00:00
Liang Qi
80406bd620 Revert "Support more than 62 instances of QWinEventNotifier"
It breaks sth in QLocalSocket which is used in QtRemoteObject.

This reverts commit 5c6210e345.

Task-number: QTBUG-61668
Change-Id: Ib11890923773496e5d998b7709ef93b0a839a759
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-06-28 12:28:39 +00:00
Stephen Kelly
3ffcfc357d QSFPM: Avoid following a reset with unnecessary layoutChanged
Follow the pattern used to guard Private::sort() calls elsewhere in the
class.

Because QAbstractItemModel::sort() is not called in the unit test, the
content is not sorted after resetting.

[ChangeLog][QtCore][QSortFilterProxyModel] QSortFilterProxyModel
now does not emit an unnecessary layoutChanged() following a model
reset.

Change-Id: I0a36c7fbb172bdd06ecddb489c5595debbef6cb9
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
2017-06-28 07:00:20 +00:00
Allan Sandfeld Jensen
6ca65dd97d Move qle_bitfield to qendian_p.h
Makes the qle_bitfield template more generic and moves it to qendian_p.h
It is also hardened to be more reliable.

Change-Id: I53214ec99cceee4f5e8934ae688c99e555a5fb42
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-27 22:16:56 +00:00
Allan Sandfeld Jensen
88e56d0932 Improve rounding of QRect::toRect
Avoid the dimensions of the rounded QRect being off by more than one
pixel. This ensures the aligned containing rect also contains the
rounded rect.

Task-number: QTBUG-56420
Change-Id: Ib79110e51ab80de2dc83d01ea83fc5fbf3852e75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-26 21:35:38 +00:00
Joerg Bornemann
5c6210e345 Support more than 62 instances of QWinEventNotifier
QWinEventNotifiers were limited to 62 instances, because of
WaitForMultipleObject's limitation to MAXIMUM_WAIT_OBJECTS - 1 handles.

Use the RegisterWaitForSingleObject API which does not have this
restriction and executes waits in threads managed by the system. A
central manual reset event per event dispatcher is signaled in the
RegisterWaitForSingleObject callback and waited for in the event loop.

[ChangeLog][QtCore][QWinEventNotifier] QWinEventNotifier is not
restricted to 62 instances anymore.

Task-number: QTBUG-8819
Change-Id: I2c749951453a4b699cc50dada0d6017440b67a4a
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2017-06-26 05:05:38 +00:00
Tor Arne Vestbø
5176ebc9ca Merge remote-tracking branch 'origin/5.9.1' into 5.9
Change-Id: Ie585425d2d8d05c6ead283b70b88b00e1e3dc1fe
2017-06-25 15:18:37 +00:00
Thiago Macieira
0669f71b0c QRandomGenerator: don't internally rely on QT_HAS_INCLUDE
GCC didn't support it until version 5 or 6, so add configure tests for
both <random> and <sys/auxv.h>. Normally I'd say "upgrade", but this is
too low-level and important a feature.

There's a good chance that all our supported compilers have <random>
anyway. As for <sys/auxv.h>, it's present on Glibc, Bionic and MUSL, but
I don't see it in uClibc (AT_RANDOM is a Linux-specific feature).

Change-Id: Ia3e896da908f42939148fffd14c5b2af491f7a77
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-06-20 16:37:35 +00:00
Edward Welbourne
68f19fb630 QDateTimeParser: implement parsing of time-zone specifiers
The serialization of date-times understood time-zones (indicated by a
't' in a format string) but the parsing didn't (so viewed the 't' as a
literal element in the format string, not matched by the actual zone
it needs to parse), although some tests expected it to.
This made round-trip testing fail.

Implemented parsing of time-zones.
Re-enabled the formerly failing tests.

[ChangeLog][QtCore][QDateTime] Added support for parsing of time-zones.

Task-number: QTBUG-22833
Change-Id: Iddba7dca14cf9399587078d4cea19f9b95a65cf7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-20 09:54:07 +00:00
Edward Welbourne
02b7ec05d5 Be (somewhat more) consistent about the value of pi
Use M_PI (and friends), where possible, in favor of hand-coded
approximations of various (in)accuracies.  Where that's not available
(e.g. fragment shaders), use the same value that qmath.h uses for
M_PI, for consistency.  Replaced math.h with qmath.h in places that
defined a fall-back in case math.h omits it (it's not in the C++
standard, although M_PI is in POSIX); or removed this entirely where
it wasn't used.

Reworked some code to reduce the amount of arithmetic needed, in the
process; e.g. pulling common factors out of loops.  Revised an
example's doc to not waste time talking about using a six-sig-fig
value for pi (which we no longer do) - it really wasn't relevant, or
anything to be proud of; nor did the doc mention its later use.

Task-number: QTBUG-58083
Change-Id: I5a31e3a2b6a823b97a43209bed61a37b9aa6c05f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-20 09:53:46 +00:00
Edward Welbourne
82deb0ad16 Update CLDR to v31.0.1
The formatting of times in Norwegian has changed to use colon rather
than dot between hours, minutes and seconds:
http://cldr.unicode.org/index/downloads/cldr-30#TOC-Other
tst_QLocale gets a matching revision.

Change-Id: I35a16080def5fbadd62144a0b44be8110b9be29b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2017-06-20 09:53:21 +00:00
Shawn Rutledge
9d23aebb27 Add QLocale::formattedDataSize and consolidate use cases
It should be easier to translate sizes in bytes to human-readable
strings consistently rather than having to repeat this code (and the
string translations) in various places.  The FileDialog in QtQuick.Controls
has a use for this, too.

[ChangeLog][QtCore][QLocale] Added QLocale::formattedDataSize() for
formatting quantities of bytes as kB, MB, GB etc.

Done-with: Edward Welbourne <edward.welbourne@qt.io>
Change-Id: I27bca146c3eba90fa7a5d52ef6626ce85723e3f0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-20 09:53:14 +00:00
J-P Nurmi
7011252145 Blacklist tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup()
It is flaky on macOS 10.12.

Task-number: QTBUG-61500
Change-Id: I3dfb6979808dec3a20896c2579dd1f5124c94a70
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2017-06-19 18:33:47 +00:00
J-P Nurmi
8ae55f0d00 Skip unreliable tst_QTimer::moveToThread() on macOS 10.12
Randomly timeouts in the CI.

Task-number: QTBUG-59679
Change-Id: I28410b747b2033fc0ef6286a11c88cd0c07eb247
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2017-06-19 18:32:55 +00:00
Liang Qi
ce09ef4313 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/corelib/io/qprocess_unix.cpp
	src/corelib/io/qprocess_win.cpp
	src/plugins/platforms/android/qandroidplatformintegration.h
	src/plugins/platforms/windows/qwindowscontext.cpp
	src/plugins/platforms/windows/windows.pri
	src/tools/uic/cpp/cppwriteinitialization.cpp
	src/widgets/doc/src/widgets-and-layouts/gallery.qdoc

Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
2017-06-19 16:12:34 +02:00
Oliver Wolff
9ed46c2853 winrt: Fix tst_qurl
Change-Id: Ia7e33e3892f888ead1357f5cd522480f514421e3
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-19 07:06:02 +00:00
Oliver Wolff
0086bf62a2 winrt: Fix tst_qtextstream
Change-Id: I5e8076a344a50f70e9618ff7b2e9258182601957
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-19 07:06:01 +00:00
Oliver Wolff
096cdb3c04 Fix tst_qfile::size for configurations using builtin test data
As the files are packaged into the binary, they have to be
extracted, before they can be ::open'ed.

Change-Id: Ie83086a2b9a73b6b0de462bdb52a71bb277ae06f
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-19 07:05:57 +00:00
Tony Sarajärvi
603963e07d Extend blacklisting of tst_QElapsedTimer::elapsed to cover macOS 10.12
Task-number: QTBUG-58713
Change-Id: I0c467c1abcdd1284910e0a61f98646e943eae377
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
2017-06-18 12:58:58 +00:00
Tony Sarajärvi
8875e28372 Blacklist flaky tst_QTimeLine tests on macOS 10.12
Task-number: QTBUG-61037
Change-Id: I604bbc815c16a5ab436d2ff4936d96d3a2d27dab
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
2017-06-18 12:58:53 +00:00
Joerg Bornemann
7ad55ca65f Support standard channel redirection in QProcess::startDetached
[ChangeLog][QtCore][QProcess] Added support for standard channel
redirection using setStandard{Input|Output|Error}File to
QProcess::startDetached.

Task-number: QTBUG-2058
Task-number: QTBUG-37656
Change-Id: Iafb9bd7899f752d0305e3410ad4dcb7ef598dc79
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-13 16:49:38 +00:00
Thomas Sondergaard
65a317e674 Use QMap in QProcessEnvironment so variables are sorted
The motivation for this change is to make it simple to pass a
correctly sorted environment block to Win32 CreateProcess(). It is
also nice in other contexts that the environment variables are
sorted. The change is made for all platforms. This keeps it simple and
the only ill effect is slightly slower lookups.

Concerning the environment block passed to Win32 CreateProcess:

The environment block that is passed to CreateProcess() must be sorted
case-insensitively and without regard to locale. See
 https://msdn.microsoft.com/en-us/library/windows/desktop/ms682009(v=vs.85).aspx

The need for sorting the environment block is also mentioned in the
CreateProcess() documentation, but with less details:
 https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

Task-number: QTBUG-61315
Change-Id: Ie1edd443301de79cf5f699d45beab01b7c0f9de3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-13 06:09:40 +00:00
Andy Shaw
26fd805f50 macOS/iOS: Correctly ignore punctuation in QCollator
When punctuation is ignored then the kUCCollatePunctionSignificantMask
should not be set. This was originally thought to not be working due to
a bug on the Apple platforms, but this is not the case.

[ChangeLog][Platform Specific Changes][macOS][iOS] QCollator now
respects the ignorePunctuation property on Apple based platforms
correctly.

Task-number: QTBUG-41978
Change-Id: I62044076387d6e4479f4aaef3c2f48f49dbd160e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-13 04:08:56 +00:00
Thiago Macieira
5483b30868 QTemporaryFile: fix the generation of names from templates
First and most importantly, let's not use more than half of the template
for the application's PID. With over 71% of all PIDs on a typical Linux
system and 90% of those on a Darwin system having 5 decimal digits,
using them all in a template that is usually 6 characters long is
wasteful. That leaves only 1 character for the random part, thereby
reducing the number of temporary files possible to only 52. So limit the
PID to half the characters of the template.

Second, let's use QRandomGenerator::bounded to create the the random
part, instead of qrand (which is often unseeded at this point).

Change-Id: Icd0e0d4b27cb4e5eb892fffd14b52eda5e467395
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-12 06:14:43 +00:00
Thiago Macieira
593f022515 Long live QRandomGenerator
This class provides a reasonably-secure random number generator that
does not need seeding. That is quite unlike qrand(), which requires a
seed and is low-quality (definitely not secure).

This class is also like std::random_device, but better. It provides an
operator() like std::random_device, but unlike that, it also provides a
way to fill a buffer with random data, not just one 32-bit quantity.
It's also stateless.

Finally, it also implements std::seed_seq-like generate(). It obeys the
standard requirement of the range (32-bit) but not that of the algorithm
(if you wanted that, you'd use std::seed_seq itself). Instead,
generate() fills with pure random data.

Change-Id: Icd0e0d4b27cb4e5eb892fffd14b4e3ba9ea04da8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-12 06:14:34 +00:00
Tor Arne Vestbø
c3a115b90d json: Add operator[] to QJsonDocument for implicit object and array access
Makes it easier to pull out data from a document when the structure is
known up front, while still supporting default values if the structure
does not match the expectation, eg:

 int age = QJsonDocument::fromJson(ba)["users"][0]["age"].toInt(-1);

Change-Id: Ief0899bbb81610f6f22a56e2ac846121bffe77a0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 11:23:55 +00:00
Tor Arne Vestbø
a7823b4878 json: Add operator[] to QJsonValue for implicit object and array access
Saves a lot of manual toArray() and toObject() calls when the
JSON structure is usually known anyways. Read only access for now.

Change-Id: I5fd787144198e0443e4da285a11ce2597b66f99f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 11:23:46 +00:00
Chris Wilson
147aa29162 Fix sending UTC-offset QTimeZones through QDataStream
QTimeZone("UTC") should be valid, as "UTC" appears in the list of
availableTimeZoneIds(), and tst_QTimeZone::dataStreamTest() constructs
timezones like this, which are considered valid.

The internal representation of a QTimeZone("UTC") as created by
QTimeZone::QTimeZone(const QByteArray &ianaId) is a QUtcTimeZonePrivate
which isValid(), so the containing QTimeZone isValid() too.

When QTimeZone is serialized into a QDataStream, it calls
tz.d->serialize(ds) which is QUtcTimeZonePrivate::serialize. This
writes QStringLiteral("OffsetFromUtc") followed by the IANA ID and
the offset (etc.) to the datastream.

When QTimeZone is deserialized it looks for this marker string, and if
present, it passed all of the parameters to the QTimeZone constructor
(not just the name). However, that constructor does not support standard
IANA timezones (only custom ones), and when it detects that the supplied
IANA ID is actually listed in availableTimeZoneIds(), it leaves the
pointer to the QTimeZonePrivate uninitialized (NULL), which leaves
the QTimeZone invalid (isValid() returns false).

Thus, a valid timezone which was serialized and then deserialized has
become invalid. This also affects serialization of QDateTimes with
timezones.

Fixed by calling the name-only constructor first, which works (only) for
IANA standard timezones and leaves the QTimeZone invalid (isValid()
returns false) otherwise. In which case, we can call the many-argument
contructor to create a custom timezone with the same offset as the one
which was originally serialized.

[ChangeLog][QtCore][QTimeZone] Fixed sending IANA standard UTC-offset
QTimeZones through QDataStream, which previously came out invalid after
deserialization.

Task-number: QTBUG-60595
Change-Id: Id9c47e8bda701faae4d800e012afb6db545b2fe9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-06-08 08:34:31 +00:00
Oliver Wolff
5441f399af Fix tst_QDir::emptyDir
It is possible that tmpdir already exists as a leftover from previous
tests. That is no reason for the test to fail.

Change-Id: I010633fb92defb064093af9872ae6fd2178f07dd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-08 07:40:16 +00:00
Oliver Wolff
8e776d39ff Fix tst_qresourceengine for platforms with embedded test data
load(resources) makes embedding the test data into the executable
fail for platforms that use builtin test data. As the load call
is only used to obtain QMAKE_RCC we can avoid that call by
assuming that rcc was not renamed and assembling the path ourself.

Change-Id: I25b982d10f5617d9a213803e7e4bcc85fc66b2e7
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-08 07:40:15 +00:00
Friedemann Kleint
6a6cdccee4 tst_QSharedMemory::readOnly: Skip on macOS
The binary hangs rather than segfaults on that platform.

Task-number: QTBUG-59936
Change-Id: Id7d38edb7c746e3c0cd4b4941e0e19b3d42a628a
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2017-06-07 16:21:49 +00:00
Liang Qi
7cbee56296 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/widgets/widgets/qmenu.cpp

Change-Id: I6d3baf56eb24501cddb129a3cb6b958ccc25a308
2017-06-07 14:02:43 +02:00
Joerg Bornemann
ea57a23d7a Remove QWinOverlappedIoNotifier
This class in unused in qtbase since Qt 5.6.1.

The only outside usage was in qtserialport, which got its own copy of
QWinOverlappedIoNotifier in commit qtserialport/65dba188.

Change-Id: I7668e67a1cc49c4418c66141784b180cd5f9d479
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-06-02 20:01:43 +00:00
Tony Sarajärvi
40a7c57ba9 Blacklist tst_QTimer::basic_chrono on macOS
Task-number: QTBUG-61013
Change-Id: I1c877aeb3e141e0e19b71bf9e595ff478e313b10
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-01 07:27:59 +00:00
Thiago Macieira
c214c000cc qEnvironmentVariableIntValue: fix the case of a non-numeric value
The documentation says that it's equivalent to
    qgetenv(varName).toInt()

But the implementation wasn't. QByteArray::toInt() verifies that the
entire string was consumed, so QByteArray("1a").toInt() == 0, but
qstrtoll alone doesn't. That is, qstrtoll("1a", ...) == 1.

The implementation also detected the base, a behavior I kept. Instead, I
updated the documentation.

Change-Id: I0031aa609e714ae983c3fffd14676ea6061a9268
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-06-01 06:02:10 +00:00
David Faure
f33cf18d88 QAbstractItemModel::supportedDragActions: fix regression
This method now returns -1 by default, due to commit 6255cb893d
which mistakenly replaced -1 with Qt::IgnoreAction (0x0).

As a result, dropping is forbidden in a number of applications
(I detected this in zanshin).

Change-Id: I4922451216e08d5d3fe36f8ba87364a361b691bf
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2017-05-31 18:54:00 +00:00
Tony Sarajärvi
600454578d Extend blacklisting of tst_QSemaphore
tryAcquireWithTimeout(0.2s) was already blacklisted and
now the same failed with "(2s)".

Task-number: QTBUG-58745
Change-Id: I82363238c08056d2969a7616e3a6e5af080d537d
Reviewed-by: Liang Qi <liang.qi@qt.io>
2017-05-31 18:53:50 +00:00
Oliver Wolff
00d9033fa0 Fix tst_QFile for configurations without process support
Change-Id: Icca2d55f0b9402bf4bcb009d972f21075d144f87
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-05-31 13:10:04 +00:00
Oliver Wolff
a0d3b5bb2b Fix tst_qmessagehandler for configurations without process support
Change-Id: If61a7b1e389e7fffb9cfa85d6b5d77a7b777215f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-05-31 13:10:03 +00:00
Liang Qi
6a772fd201 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	.qmake.conf
	mkspecs/common/msvc-desktop.conf
	mkspecs/win32-g++/qmake.conf
	mkspecs/win32-icc/qmake.conf
	src/platformsupport/fontdatabases/mac/coretext.pri
	src/plugins/platforms/cocoa/qcocoawindow.h
	src/plugins/platforms/cocoa/qcocoawindow.mm

Change-Id: I74a6f7705c9547ed8bbac7260eb4645543e32655
2017-05-29 10:54:41 +02:00
Tony Sarajärvi
315f634180 Fix autotest not to open too many files on a Unix
tst_QSharedPointer can't create a pipe as the OS has too many files
open. Systems like macOS have a lower limit to these simultaneous files
open.

Task-number: QTBUG-60410
Change-Id: I21e89f992ada2a7d09b706522a05b5952f00ec33
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-29 06:46:50 +00:00
Tony Sarajärvi
b09c4cc48e Blacklist tst_QEventLoop:testQuitLock as it is flaky on macOS
Task-number: QTBUG-60992
Change-Id: I9474fd67b6429f01ddbbc9ae17af4ae8635e53df
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-23 14:52:31 +00:00
Tony Sarajärvi
1c13d130c6 Extend blacklisting of qeventdispatcher to cover macOS
They have been blacklisted on windows previously and now fail on
macOS 10.12 as well.

Task-number: QTBUG-60993
Change-Id: Ib7a3acfc7f2285c0a587d4abd88a4a218391d623
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-23 14:52:09 +00:00
Albert Astals Cid
2ca187caa3 moc: Allow NOTIFY signals defined in parent classes
Limitation is that the signal needs to be parameter-less

[ChangeLog][moc] moc now supports NOTIFY signals of parent classes in Q_PROPERTY

Change-Id: Iad64c96c3ec65d4be8ad9ff1a9f889938ab9bf45
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
2017-05-23 11:11:52 +00:00
Liang Qi
d6248ed80e Merge "Merge remote-tracking branch 'origin/5.9.0' into 5.9" into refs/staging/5.9 2017-05-19 20:27:29 +00:00
Friedemann Kleint
c4addd221e tst_QTimer::timeout(): Use QTRY_VERIFY_WITH_TIMEOUT
The test has been observed to be flaky on Windows. Introduce
QTRY_VERIFY_WITH_TIMEOUT for diagnostics.

Change-Id: I72abdd2e5544f8f35199876486ab15151f60e5f2
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-05-19 17:42:24 +00:00
Liang Qi
550e16b814 Merge remote-tracking branch 'origin/5.9.0' into 5.9
Change-Id: Ia8ac1960387c0f78c32f9d0385bb0aa9a8209af1
2017-05-19 08:57:59 +02:00
Marc Mutz
cafefd1d33 QStringView/QLatin1String: add trimmed()
... using the same qt_trimmed(), qTrimmed(), Q..::trimmed() split we've
been using for all other out-of-line string-view member functions to
avoid forcing string-view objects onto the stack for the passing of 'this'.

In the test, had to fix nullness not being propagated from a QByteArray
to the QLatin1String constructed from it. Probably worth fixing in
QLatin1String(QByteArray), too.

[ChangeLog][QtCore] Added qTrimmed() free functions.

[ChangeLog][QtCore][QLatin1String] Added trimmed() function.

Change-Id: I73c18ef87e203f30f7552c10dd5c84223bcfae0e
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-05-16 09:34:59 +00:00
Marc Mutz
3c592a17f1 QStringView: add constructor from pointer pair
This is often more natural than (ptr, len), and I need it in the
implementation of QStringView::trimmed().

Change-Id: I1d99b5ddaf76eee0582150b0233ef6ce9c37d25d
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-05-16 09:34:50 +00:00
Oliver Wolff
5c38bbf9ba winrt: Fix tst_QSocketNotifier::asyncMultipleDatagram
Change-Id: I90de7487b0ddcd5655434e99a05eef7f29def59b
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-05-11 06:37:36 +00:00
Oliver Wolff
7e7bc031e9 winrt: Fix tst_qcoreapplication
On winrt, the default application version is determined by its
manifest file. The template's default version is 1.0.0.0.

Additionally addRemoveLibPaths should not fail if libraryPaths
only contains currentDir.

Change-Id: Ifdd517f1bfe2fdf641f3d728ebe1fa144df1a8ca
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-05-11 06:37:34 +00:00
Marc Mutz
38bbd8fbac Add some missing breaks in switch statements
Found by GCC 7.

Change-Id: I90267617a038558e5b5213c598a949baf8d4d9be
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-05-10 16:09:42 +00:00
Frederik Gladhorn
6881e1613a Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I172e3e19ddcc5b7665e6c8382d725e7cc4f9794f
2017-05-10 10:11:57 +02:00
Filippo Cucchetto
be0a221ae4 Fix missing handling of columns when merging selection ranges
This commit fixes two bugs:
1) Two ranges should not be merged if they are of different columns.
The old code would have merged (0,0) with (1, 1). Tranforming a selection
of just two indexes in a rectangle of four indexes.
2) The QItemSelectionRange appended had wrong column and worked only for
indexes of the first column. For example if 'tl' was (0, 1) than br was (0, 1)
so the QItemSelectionRange would have be ((0,1), (0, 1-1)) so ((0,1), (0,0)).
This QItemSelectionRange is invalid because topLeft columns is greater than
bottomRight column. The fix take in consideration the bottomRight column.

Task-number: QTBUG-58871
Change-Id: I591ef0bcc63926f24a7b1ced002af9b7737a4b6e
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2017-05-09 13:46:51 +00:00
David Faure
74d79fcf1a QMimeDatabase: update freedesktop.org.xml to shared-mime-info 1.8
... and update the unittest accordingly.

Compared to the 1.8 release there is one change in freedesktop.org.xml,
the magic for application/x-java-keystore was changed from host32 to
big32, as done upstream, see https://bugs.freedesktop.org/show_bug.cgi?id=99328

Task-number: QTBUG-60608
Change-Id: I47de71c9396cfc3eabc884d5679c73a3e4850a17
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-05-08 18:04:24 +00:00
Giuseppe D'Angelo
b7da94ce52 QObject: turn the narrowing test into static_asserts
The conditions checked are compile-time conditions anyhow.
Simplify or strenghten a few conditions while at it.

Change-Id: If07f2aedca4c3632d852a8fdb2b3f7eb55a96c93
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2017-05-08 14:24:02 +00:00
Sami Nurmenniemi
be36fca32b tst_qmessagehandler: fix qMessagePattern for arm with optimizations on
Backtrace logging tests were not passing for arm when -O2 option was used.
Set "-fno-inline" on for the app whose backtrace is to be inspected.

Task-number: QTBUG-59966
Change-Id: Id1bbf78c31dc524357a30c7d39c239689621b155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-05-08 11:18:10 +00:00
Alberto Mardegan
a6f3bb21e3 QMimeType: add Q_GADGET
The QMimeType class can be quite useful to graphical QML applications,
especially on the desktop.

[ChangeLog][QtCore][QMimeType] Add Q_GADGET, so that QML applications
can make use of QMimeType's properties and methods.

Change-Id: I03e6e82062558a72f5b97e65bbddfc4b7470e735
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Jeremy Katz <jeremy@panix.com>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-08 06:51:29 +00:00
Glen Mabey
cab9bc8fba Eliminate ambiguous casts involving qfloat16
The operator double() and operator long double() members of qfloat16
are causing cast ambiguities.  This removes them, leaving only
operator float() which seems to be adequate.

Also, additional arithmetic operator tests were added which without
this removal fail to compile.

Change-Id: Id52a101b318fd754969b3de13c1e528d0aac2387
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-05-07 16:44:55 +00:00
Liang Qi
d1ea481345 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/network/access/qnetworkreply.cpp
	tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp

Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
2017-05-07 13:08:18 +02:00
Samuel Gaist
ae292be869 Implement key-value iterator
This patch implements an iterator that returns a pair containing both the
key and the value of an entry in QHash/QMap.

[ChangeLog][QtCore][Containers] Added an stl-like iterator to go through
QHash/QMap returning both the key and the value of the element pointed to.
That lets QHash/QMap interoperate better with stl's algorithms like
std::set_union.

Change-Id: Idbf8a8581510b3493648c34ab04c556de9fa4aa7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-05-05 14:25:56 +00:00
Giuseppe D'Angelo
dbd55cdaf3 QHash/QMultiHash: fix operator==
The existing QHash::operator== does not work when the same
keys appear in different order between the two hashes being compared.
However, relying on iteration order on a QHash is (as usual) a bad
idea and one should never do it.

Task-number: QTBUG-60395
Change-Id: Ifb39a6779230e26bbd6fdba82ccc0247b9cdc6ed
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-05 12:18:25 +00:00
Marc Mutz
38134ff41e Enable c++17 in the QStringApiSymmetry test
Because it's the correct thing to do.

Change-Id: I1d9fb482ffed6f4c36b4bc25d05cabcd07d87a78
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-05 07:11:57 +00:00
Tor Arne Vestbø
58114b5ab0 tst_qscopedpointer: Actually test what test name says it should test
Change-Id: Idda6e34c4438d1695f8268426fe923ad51ff6d10
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-05-03 20:10:00 +00:00
Marc Mutz
2a86c565e8 tst_QStringApiSymmetry: add checks for trimmed()
All good (now).

Change-Id: I666773856a239826e646398a943e7df30bd81671
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-05-03 19:58:02 +00:00
Marc Mutz
96edd0e440 tst_qstringapisymmetry: also check potential rvalue overloads of transformations
For transformations, regardless of whether they're currently
overloaded on rvalue-this or not, check the results of calls to const
lvalues as well as mutable rvalues.

Use the new mixed-type QCOMPARE more.

Change-Id: Ibaa436cd88b40e5c0823c3bbe5b04a9964e7e987
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-03 19:57:52 +00:00
Alex Trotsenko
124b9a6ff8 Improve suppression of spurious socket notifications under Windows
There were still two cases where spurious notifications would be
possible:

    - user calls hasPendingDatagrams()/pendingDatagramSize() on UDP
      socket somewhere outside the slot connected to readyRead()
      signal (::WSARecvFrom posts FD_READ notification, even if
      a notification for incoming datagram already exists in the
      message queue);
    - a socket was registered to receive several types of event and
      WM_QT_ACTIVATENOTIFIERS message is located between the
      different events for this socket in the queue.

Provided patch ensures that the message queue is synchronized with
the Qt event processing mechanism and adds a way to detect spurious
notifications inside the window procedure.

Task-number: QTBUG-58214
Change-Id: I49609dace601f300de09875ff1653617efabd72f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Peter Seiderer <ps.report@gmx.net>
2017-05-03 06:46:18 +00:00
Olivier Goffart
9d918495ee Add a few std::move in functions accepting slots
This allows the use of move-only function objects

Task-number: QTBUG-60339
Change-Id: If3595fca338cf7f3039eb566cc02e4e73cd04c86
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-29 08:24:24 +00:00
Olivier Goffart
a6c091c2d1 Support move-only function objects in QObject::connect
[ChangeLog][QtCore][QObject] Added connect() support for move-only
function objects.

Task-number: QTBUG-60339
Change-Id: Iae5e48432bb64517b0607b0c2ba23931957f432e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-29 08:24:18 +00:00
Marc Mutz
3644e722c2 QLatin1String: add startsWith()/endsWith()
[ChangeLog][QtCore][QLatin1String] Added startsWith(), endsWith().

Change-Id: I7f75a5a1f0409f4b9d3e41b73f4fb5d137572b09
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-28 16:41:42 +00:00
Marc Mutz
d21a147e2b QStringView: add startsWith(), endsWith()
Change-Id: I72aef9236daedc3013c62d3f1d737159f85572b8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-28 16:41:36 +00:00
Marc Mutz
5f3d6ce570 QString/Ref: add startsWith/endsWith(QStringView) overloads
[ChangeLog][QtCore][QString/QStringRef] Added startsWith(), endsWith()
overloads taking QStringView.

Change-Id: Ice6332492d19fd7477d5ac43ecbf6b70175b23ca
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-28 16:41:26 +00:00
Thiago Macieira
cf0c44fe83 Fix test build with ICC: QFlags does not auto cast to uint
I don't know why.

 tst_qflags.cpp(114): error: no instance of function template "verifyConstExpr" matches the argument list argument types are: (Qt::MouseButton)
 tst_qflags.cpp(91): note: this candidate was rejected because there is a type mismatch after argument substitution

Change-Id: I84e363d735b443cb9beefffd14b9581d77933cb8
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2017-04-28 12:37:09 +00:00
Nikita Krupenko
7ef398e8fa QFileDevice/QFileInfo: Add fileTime() and setFileTime()
[ChangeLog][QtCore][QFileDevice] Added fileTime() and setFileTime().

[ChangeLog][QtCore][QFileInfo] Added fileTime().

Task-number: QTBUG-984
Change-Id: I84dfb05b9454a54e26b57b78edee5773dc4c5c3c
Initial-patch-by: Raphael Gozzo <raphael.rg91@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-27 18:44:15 +00:00
Marc Mutz
8d32204592 QStringRef: fix trimmed() returning null strings on empty input
The QString API symmetry test strikes again, showing that this is
inconsistent with both QString and QByteArray, which both return empty
for empty inputs.

The fix actually makes the implementation simpler.

Extend the QStringRef test to cover null inputs, too. I can't merge
the trimmed() test in the API symmetry test until everything is
actually consistent.

[ChangeLog][QtCore][QStringRef] trimmed() now returns an empty
string-ref for an empty input. Before, it would return a null one.

Change-Id: I6b35c5f498053c4e15a4a9dd465bc696258e7393
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2017-04-27 17:04:32 +00:00
Marc Mutz
e63daaa2ac tst_qstringapisymmetry: merge truncate() test into left() test
Less code duplication, since truncate() is the action version of
left().

This is done in preparation of adding more actions for the string
transformations we have.

Change-Id: I55027b5143ad3349d46091ac1cc3d24a9707caee
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-27 04:35:21 +00:00
Thiago Macieira
4ba740b3ba QHash: make it so a zero seed selects a constant algorithm
That's the only value for which we will guarantee a stable result across
Qt versions and across invocations of the same application on different
architectures is zero. For any other value, we reserve the right to
change the algorithm. We'll now print a warning when we detect that.

Task-number: QTBUG-47566
Change-Id: I27b55fdf514247549455fffd14b1135e10d24ab4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-04-26 15:22:44 +00:00
Marc Mutz
309b4b877f tst_qstringviewapisysmmetry: add a check for startsWith()/endsWith()
All good.

Can't check QByteArray::startsWith(), as it is lacking the
Qt::CaseSensitivity parameter.

Change-Id: I7f2379e520617c14514fc66d8fb3413cfb7c9147
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-26 09:12:54 +00:00
Sami Nurmenniemi
a1e94bcfbb Fix tests that assume system files are owned by root for qemu
If QEMU is provided sysroot with QEMU_LD_PREFIX, it opens files from there. If their
owner is the current user, testing their access rights based on assumption that they
are root fails. Skip the tests in that case similarly as is already done when the
tests are run as root.

This fixes following tests:
- tst_QTemporaryDir::nonWritableCurrentDir
- tst_QNetworkReply::getErrors(file-permissions)
- tst_qstandardpaths::testCustomRuntimeDirectory

Task-number: QTBUG-59966
Change-Id: I972ce37b4b5a7747cdd732a8e4a737ef09cbc6a5
Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-26 09:12:12 +00:00
Marc Mutz
979f9f4d34 QLatin1String: fix qt_compare_strings(QLatin1String, QLatin1String) for null strings
qstrcmp sorts null strings before empty ones, while the Qt string
classes consider them equal.

The qt_compare_strings() overload for QLatin1String was using
qstrcmp(), but is supposed to implement the semantics that Qt string
classes use, so we need to add an extra check.

Was uncovered by tests for QLatin1String::startsWith(), but added a
new test for qCompareStrings() now, which is a bit more complicated
than desired, due to the lack of QUtf8String.

Change-Id: I0493c4491df928a68861a1bc7f0962f1c870a416
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-26 09:11:27 +00:00
Thiago Macieira
9e2c6899e0 QUrl: fix IDN conversion when the ACE form is invalid
We guarded against the Unicode form being invalid and did not produce an
encoded form. But we did not guard against proper Punycode sequences
that decode to forms that had not passed the proper Nameprep stage. So
check for that and, if it fails, just keep the label in the form we
found it in (it's valid STD3 anyway).

[ChangeLog][QtCore][QUrl] Fixed a bug that caused certain domain names
that look like Internationalized Domain Names to become corrupt in
decoded forms of QUrl, notably toString() and toDisplayString().

Task-number: QTBUG-60364
Change-Id: Iadfecb6f28984634979dfffd14b833142cca8d0d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-25 00:51:43 +00:00
Marc Mutz
09f6227653 QtTest: add support for printing QStringViews
[ChangeLog][QtTest][QCOMPARE] Now supports printing QStringViews in
case of test failures.

Change-Id: I4dc2542cd1013fd63c094c249e721d7102387bde
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-24 19:35:11 +00:00
Thiago Macieira
21dd5d314a QUrl: fix IDN whitelist checking when the TLD is in Unicode
The whitelist is kept in ACE form, so if the TLD came in Unicode, we
need to run ToASCII before we can check the whitelist. This is slightly
inefficient because we'll run the same operation later in this domain.

Change-Id: Iadfecb6f28984634979dfffd14b831f37b0f4818
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
2017-04-24 19:29:57 +00:00
Michael Brasser
47fdb2c8e3 Add support for scoped enums to QMetaObjectBuilder
Change-Id: I7b3c3973ff4396a854014f5b2b671b71007e80da
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-04-24 19:19:44 +00:00
Giuseppe D'Angelo
597d4ff796 QThread: add static create function
In the spirit of std::thread, which takes a function to call and its
parameters, and runs it in a new thread. Since the user might want to
connect to signals, move QObjects into the new thread, etc., the new
thread is not immediately started.

Although technically all of this _should_ be implementable in pure
C++11, there is nothing in the Standard to help us not reinvent all the
plumbing: packing the decay'd parameters, storing them, invoking the
function over the parameters (honoring INVOKE/std::invoke semantics).
std::function does not do the job, as it's copiable and therefore does
not support move-only functors; std::bind does not have INVOKE
semantics.

I certainly do not want to reimplement all the required facilities
inside of Qt. Therefore, the full blown implementation requires C++17
(std::invoke).

In order to make this useful also in pre-C++17, there are two additional
implementations (C++11 and C++14) that support just a callable, without
any arguments passed to it. The C++11 implementation makes use of a
class to store and call the callable (even move-only ones); basically,
it's what a closure type for a C++14 lambda would look like.

An alternative implementation could've used some of the existing
facilities inside QObject::connect implementation that store a functor
(for the connect() overload connecting to free functions), namely:
the QtPrivate::QFunctorSlotObject class. However:

* QFunctorSlotObject does not support move-only callables (see
QTBUG-60339);
* QFunctorSlotObject itself is not a callable (apparently by design),
and requires to be wrapped in a lambda that calls call() on it;
* the moment QTBUG-60339 is solved, we'd need the same handwritten
closure to keep QFunctorSlotObject working with move-only callabes.

So: just use the handwritten one.

The C++14 implementation is a simplified version of the C++11 one,
actually using a generalized lambda capture (corresponding to the
handwritten C++11 closure type).

All three implementations use std::async (with a deferred launch policy,
a nice use case for it!) under the hood. It's certainly an overkill for
our use case, as we don't need the std::future, but at least std::async
does all the plumbing for us.

[ChangeLog][QtCore][QThread] Added the QThread::create function.

Change-Id: I339d0be6f689df7d56766839baebda0aa2f7e94c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-24 15:24:22 +00:00
Tony Sarajärvi
148188fef3 Rename macos blacklisting to osx
Change-Id: I7e370ad8e1e2cb87188e149c96681e4c18abaa4f
Reviewed-by: Liang Qi <liang.qi@qt.io>
2017-04-24 07:24:08 +00:00
Tony Sarajärvi
485b6c99db Blacklist tst_qsemaphore on macOS 10.12
Task-number: QTBUG-58745
Change-Id: I085a2ac60cc24c287140788a88512657238a2c4b
Reviewed-by: Liang Qi <liang.qi@qt.io>
2017-04-24 07:24:01 +00:00
Joerg Bornemann
b137734e6b Support setCreateProcessArgumentsModifier in QProcess:startDetached
Factor out both CreateProcess calls into one function that also calls
the modifier callback for the CreateProcessArguments struct.

Task-number: QTBUG-57687
Change-Id: I9d2ef4f2d7cd077aa4c3eba926ab4dfb9e570291
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-23 18:10:50 +00:00
Olivier Goffart
d4cdc45426 Fix QMetaMethod::invoke and automatic type registration
This was simply not working for two reasons:
 - The index passed to QMetaObject::metacall was not right (there was an offset
   because of the return type)
 - If the registration succeeded, the arguments were not even initialized.

The tests in tst_moc always called QMetaMethod::parameterType before calling invoke,
which was properly registering the type. So this was not seen in the tests before.

[ChangeLog][QtCore][QMetaMethod] Fixed crash in invoke() with QueuedConnection and
types whose metatype gets automatically registered.

Task-number: QTBUG-60185
Change-Id: I4247628484214fba0a8acc1813ed8f112f59c888
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-22 11:25:49 +00:00
Marc Mutz
dfc2a4a537 QLoggingRegistry: remove rules vector
It only contained a concatenation of the individual rule sets,
probably to fix their order in a central place, as well as
simplifying iteration in defaultCategoryFilter().

Fix these two issues differently, but introducing a RuleSet
enum that lists rule sets in the order in which they should
be applied by defaultCategoryFilter(), and turn individual
rule sets vectors into a C array of vectors.

This enables two nested loops in defaultCategoryFilter to
replace the one loop over 'rules'. Apart from building up
'rules' in updateRules(), this was the only access to that
member. That leaves updateRules() with just the task of
running defaultCategoryFilter() on the new rule sets.
Consequently, a call to updateRules() can now replace the
identical loop in installFilter().

Performance should not suffer. Iterating over a fixed-size
array of vectors is hardly any slower than iterating over
a single vector, and while the construction of 'rules'
was probably a one-off task in most programs, this way
of keeping the rules also saves memory because rules are
not kept in two different vectors.

It is also more maintainable, of course.

Change-Id: Ibc132d096c8137dd02b034752646212e51208637
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-04-21 07:16:33 +00:00
Marc Mutz
5311eb0d8e Use new Q_STDLIB_UNICODE_STRINGS and Q_COMPILER_UNICODE_STRINGS
... instead of the combination with Q_OS_WIN we used so far.

This patch adapts ocurrences that are new in 5.10.

Change-Id: If392df481713e56c776c2326e0e02324a3a80c89
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-20 18:10:59 +00:00
Marc Mutz
7d4bf142d7 QUuid: add fromString(QStringView/QLatin1String)
As for the formatting code, de-duplicate the parsing code by only
parsing char*s, converting QChars to Latin-1 first in a small buffer.

The QUuid(const char*) ctor performed no length checking, relying
instead on the checks performed within _q_uuidFromHex(), which
includes an implicit check for premature end (because NUL is not
a valid token for the parser).

The (QString) and (QByteArray) ctors did perform length checking.
To the extent possible, this is removed, since it is handled by
_q_uuidFromHex(). Failure cases need not be optimized. Only the
QLatin1String overload needs to do some checking, because views in
general are not NUL-terminated. The QStringView overload can just
append a NUL when it converts to Latin-1.

The only check I added to _q_uuidFromHex() is that for src ==
nullptr. It would otherwise be duplicated in several callers.

While touching the internal functions, port to passing and returning
by value.

Saves 1.6KiB in text size on optimized GCC 6.1 Linux AMD64 builds,
even though we added new API.

Port some users to the new functions. Expand fromString() test.

[ChangeLog][QtCore][QUuid] Added fromString(QStringView/QLatin1String).

Change-Id: I519339419129550c86e0ea80514865cd6a768f5d
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-20 17:02:44 +00:00
Giuseppe D'Angelo
af211b3993 QVariant: fix the test
8a375341cf added swap() to QJson* classes
and marked them shared-not-movable-until-qt6.

That unveiled a broken test in QVariant which was relying on QJsonDocument
being not relocatable. So fix the test by using a proper datatype for the task.

Change-Id: Ic35f09f936b00dfaeb368ccb42aecf35cc506029
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
2017-04-20 15:33:49 +00:00
Liang Qi
7950b6b283 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/corelib/tools/qbytearray.h
	src/corelib/tools/qdatetime.h
	src/corelib/tools/qstring.h
	src/corelib/tools/qversionnumber.h
	src/plugins/platforms/android/qandroidplatformintegration.cpp
	tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp

Change-Id: Iefd92a435e687a76cd593099e40d9a9620a1454d
2017-04-20 12:31:27 +02:00
Giuseppe D'Angelo
0794d61c82 QMetaType: fix the test
8a375341cf added swap() to QJson* classes
and marked them shared-not-movable-until-qt6.

This change made QMetaType start reporting that QJson* classes were
movable; however, the test used QTypeInfo and not QTypeInfoQuery to
double check that information.

Port the test to QTypeInfoQuery.

Change-Id: I3227a70a8f24c0013257e180e9cb9cfebe9947f9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-20 07:19:57 +00:00
Marc Mutz
126c4eae84 Split Q_COMPILER_UNICODE_STRINGS: add Q_STDLIB_UNICODE_STRINGS
Since commit bf2160e72c, we can rely on
charNN_t support in all compilers except MSVC 2013, and since that
commit, we use (in 5.10, not 5.9, yet)

  !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS)

when we only need charNN_t, the type, as opposed to its library
support (u16string, char_traits<char16_t>, ...).

This patch splits the Q_C_UNICODE_STRINGS macro into two, adding
Q_STDLIB_UNICODE_STRINGS for when we need std::uNNstring, leaving
Q_C_UNICODE_STRINGS for when we need just charNN_t support.

In QDebug, when constructing a QChar out of a char16_t, cast to ushort
first, since QChar(char16_t) was only officially introduced in Qt 5.10.

[ChangeLog][Potentially Source-Incompatible Changes] The internal
Q_COMPILER_UNICODE_STRINGS macro is now defined if the compiler
supports charNN_t, even if the standard library does not. To check for
availability of std::uNNstring, use the new Q_STDLIB_UNICODE_STRINGS
macro.

Change-Id: I8f210fd7f1799fe21faf54506475a759b1f76a59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-20 06:50:36 +00:00
Tor Arne Vestbø
924b02aecb Revert "Initialize QLoggingRegistry rules on first use, not qApp construction"
This reverts commit 47cc9e23a3.

We use QCoreApplication::applicationDirPath in the logging initialization to find
a possible qtlogging.ini file. Because QCoreApplication::applicationDirPath requires
a QCoreApplication instance this leads to a qWarning, which in turn leads to a
recursive call to the logging initialization, and in turn to a recursive mutex deadlock.

Task-number: QTCREATORBUG-18031
Change-Id: Ic75e1e8c062eb647991725378489bf87c9648cca
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-04-19 22:59:43 +00:00
Tor Arne Vestbø
47cc9e23a3 Initialize QLoggingRegistry rules on first use, not qApp construction
Allows categorized logging before QCoreApplication has been created,
which otherwise would silently fail to output anything because the
category would never be enabled, despite QT_LOGGING_RULES being set.

Change-Id: Ia733105c5b6f28e22af511ced5271e45782da12b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-18 21:09:43 +00:00
Marc Mutz
a21a9efacb QLatin1String: add chopped(), chop(), and truncate()
[ChangeLog][QtCore][QLatin1String] Added chopped(), chop(),
truncate().

Change-Id: I69b31aae560e94a120d7e8a36e06ea957ccd2003
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-18 09:43:32 +00:00
Marc Mutz
fc8cc2573c QStringView: add chopped(), chop(), and truncate()
Change-Id: I33925f5b2b3e0904f47f18f3cbab480d7f844734
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-18 09:43:26 +00:00
Marc Mutz
d176808eef QByteArray, QString, QStringRef: Add chopped()
We have two functions to get a substring without doing some
calculations involving size():

- mid(p):    mid(p, size() - p)
- right(n) : mid(size() - n, n)

(left does not involve size(), so isn't in that set). What was missing
was a name for

- f(n): mid(0, size() - n)

As an action, it's called chop(), so call the transformation version
chopped().

I made chopped(n), n < 0 or n > size(), undefined, because QString(Ref)
::left() is broken[1], while the QByteArray implementation is not. This
is the only way to get consistent behavior among the three classes.

I's also the correct thing to do.

[1] instead of returning the empty string for negative indexes, it
returns the whole string.

[ChangeLog][QtCore][QString/QStringRef/QByteArray] Added chopped(n), a
const version of chop(n).

Change-Id: I6c2c5b16e0060fa924ced5860f21f2d0f23bd023
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2017-04-18 09:43:18 +00:00
Liang Qi
18934bcb0c Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/corelib/global/qglobal.cpp

Change-Id: I375fa4afa662fa411a15f212ebd5f2f0dffdba7f
2017-04-18 10:46:22 +02:00
Ihor Dutchak
d1210281e4 Fix undefined behavior in QSharedPointer::create()
Initialize a deleter for a new object, created by
QSharedPointer::create(), only after the object is actually
constructed.

[ChangeLog][QtCore][QSharedPointer] Fixed undefined behavior when
creating an object with QSharedPointer::create() and its conscructor
throws an exception.

Task-number: QTBUG-49824
Change-Id: I07f77a78ff468d9b45b8ef133278e8cdd96a0647
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-04-17 09:56:15 +00:00
Marc Mutz
e1c8451ffe QVariant: implement QByteArray ↔ QUuid conversion
Seems like an obvious omission.

[ChangeLog][QtCore][QVariant] Can now convert QUuid to and from
QByteArray, not just QString.

Change-Id: Ib56ae86ca0c27adaf1e095b6b85e64fe64ea8d18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-14 12:54:21 +00:00
Marc Mutz
58a4f41af2 QDate/Time: add toString(QStringView) overloads
[ChangeLog][QtCore][QDate/QTime/QDateTime] Added toString() overloads
taking the format as a QStringView.

Change-Id: I322fa22e6b13fe8ba4badf0a3133425bd067ef32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-12 11:12:09 +00:00
Marc Mutz
d68c162c1b QLocale: add toString(Q(Date|QTime)+, QStringView format) overloads
While at it, change the interface of qt_repeatCount() to just take
a single QStringView, since QStringView::mid() is so cheap. Add some
\internal docs.

[ChangeLog][QtCore][QLocale] Added toString(QDate/QTime/QDateTime)
overloads taking the format string as a QStringView.

Change-Id: Ic078796677a6db06227c8a3e276dbdb1039ceead
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-12 11:12:04 +00:00
Thiago Macieira
cdc5f47aeb Restore compatibility with Qt 5.7.0 and 5.6.1
QSysInfo::productType() returned "osx" for all versions of macOS, even
10.12. Change 3e2bde3578 was incorrect.

[ChangeLog][Important Behavior Changes] QSysInfo::productType() and
QFileSelector behavior on macOS was restored to match what Qt used to
return in version 5.7.0 and earlier. The behavior found in Qt 5.6.2,
5.7.1 and 5.8.0 is removed.

[ChangeLog][Future Compatibility Notice] The identifiers that
QSysInfo::productType() and QFileSelector will use to identify macOS
systems will change in Qt 6.0 to match the Apple naming guidelines which
will be current then.

Task-number: QTBUG-59849
Change-Id: Ib0e40a7a3ebc44329f23fffd14b2b39392210c4f
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2017-04-12 05:14:19 +00:00
Thiago Macieira
e7493c8b54 tst_qhashfunctions: Test non-zero seeds too
Change-Id: Ib0e40a7a3ebc44329f23fffd14b2e927021a1a2e
Reviewed-by: David Faure <david.faure@kdab.com>
2017-04-11 06:38:14 +00:00
Marc Mutz
de3785b8bc QVersionNumber: add fromString(QStringView/QLatin1String) overloads
The parsing code anyway operated on a QByteArray created from
toLatin1(), so expose this to the user by providing a QLatin1String
overload.

Also provide a QStringView overload, since we can. Port one user (in
qmake) to the new overload.

[ChangeLog][QtCore][QVersionNumber] Added QStringView and
QLatin1String overloads of fromString().

Change-Id: Idbff44c3997f5cfa86ea1bce8b3da4b700a3d9cc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-08 05:40:52 +00:00
Thiago Macieira
23d08ce2ed Fix QDir::mkpath() when the path contains "symlink/../"
It is incorrect to collapse a "symlink/.." segment because the parent
directory of the symlink's target may not be the directory where the
symlink itself is located.

[ChangeLog][QtCore][QDir] Fixed a bug that caused QDir::mkpath() to
create the wrong directory if the requested path contained a symbolic
link and "../".

Change-Id: Iaddbecfbba5441c8b2e4fffd14a3e367730a1e24
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-04-07 20:26:02 +00:00
Thiago Macieira
795a54ff96 QDataStream: add operator<< and >> for std::nullptr_t
std::nullptr_t is nullary: it accepts only one value, nullptr. So we
don't need to read or write anything. This commit simply adds the two
operators that allow generic code to operate on std::nullptr_t if
required.

This commit also adds the actual use to QMetaType::load/save, even
though there's no change in behavior.

[ChangeLog][QtCore][QDataStream] Added operator<< and operator>>
overloads that take std::nullptr_t, to facilitate generic code.

Change-Id: Iae839f6a131a4f0784bffffd14aa37e7f62d2740
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-07 17:41:06 +00:00
Marc Mutz
399ab058c9 Add front()/back() to QString, QStringRef, QByteArray and QLatin1String
These STL-compatibility functions are present on our generic
containers, but not on the string classes.

[ChangeLog][QtCore][QString/QStringRef/QByteArray/QLatin1String] Added
front() and back() for STL compatibility.

Change-Id: I536019396b319abd1e2daf9c64ebab4e7a35b334
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-07 08:32:32 +00:00
Marc Mutz
5dc1e08c8c Add qConvertTo{Utf8,Latin1,Local8Bit,Ucs4}() and corresponding QStringView methods
Like the qt_compare_strings()/qCompareStrings() split, distinguish
between the internal and exported functions.

Because of the circular dependency between qstring.h and qvector.h,
the inline toUcs4() function has to be in qvector.h.

At some point, we need to refactor the headers so qvector.h is lower
in the dependency chain than qstring.h. It's not the first time this
bites.

Change-Id: Ief9f3bd92c83cdd1f31c51c700f42e146916eefd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-07 08:54:16 +00:00
Liang Qi
191a210478 Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/dev 2017-04-07 09:38:34 +00:00
Marc Mutz
dea78262e5 tst_QStringApiSymmetry: Add tests for truncate() and chop()
All good.

Change-Id: Id791a04fd5e2c9bc7f54660eaaa95d6db61a5674
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-07 08:34:49 +00:00
Marc Mutz
95263dbf7a Add a test for container API symmetry
Akin to the successful tst_QStringApiSymmetry, add such a test for
generic containers, too. Yes, we have tst_collections, but it's a
cut'n'paste mess that makes it hard to systematically perform
cross-class checks for consistency. This new test, still in its
infancy, uses templates and thus ensures that exactly the same checks
are run on all containers.

Starting out with front()/back(), which the string classes were found
to lack, we will build this test up, as we did and continue to do with
the string API one.

Change-Id: I07323340b5612ecc658232b2776d788018010d0d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-07 08:32:24 +00:00
Marc Mutz
5e93361888 Add a test for consistency of hash values between QString{,Ref,View}
Change-Id: I64a169fd6c8e2444bfe67e3ecd5375ea7b6a81ee
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-07 08:30:17 +00:00
Liang Qi
5d6073be27 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	mkspecs/linux-icc/qmake.conf
	mkspecs/macx-icc/qmake.conf
	mkspecs/win32-icc/qmake.conf
	src/gui/painting/qgrayraster.c

Change-Id: Ib08c45ea3215be05f986ecb3e1f4b37d209aa775
2017-04-07 10:24:33 +02:00
Sami Nurmenniemi
ac76b2424d tst_qmessagehandler: fix qMessagePattern for arm
Backtrace logging tests were not passing for arm. Added compile option
-funwind-tables to support backtrace on arm.

Task-number: QTBUG-59966
Change-Id: I5e2443b1e3a644a239dab68db990e75ae8fade24
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-07 08:12:14 +00:00
Sami Nurmenniemi
bbb67ca32c Fix tst_Collections for gcc/arm
- Alignment test was not compiling or passing on GCC / arm
- Using C++11 alignas() enforces maximum limit for the alignment, which
  at least on GCC / arm is __BIGGEST_ALIGNMENT__ multiplied by 8
- On GCC 6.2.0 / x86_84, maximum alignment accepted by alignas is 128
- On GCC 5.3.0 / arm, maximum alignment accepted by alignas is 64
- This change calculates biggest tested alignment on ARM targets
  and compilers supporting alignas() to the value calculated
  from __BIGGEST_ALIGNMENT__

Task-number: QTBUG-55492
Change-Id: If2b70000ff9cdc5ae8c5a00e39f79efcc6ba1221
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-07 05:54:04 +00:00
Marc Mutz
f672bd6316 Extend the check for null and empty QString hashing to QString{Ref,View}
Change-Id: I5c41287991f6dd2eeb3d54699da0f653bfac59be
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-06 22:19:41 +00:00
Liang Qi
c50f6a8329 Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9 2017-04-06 14:35:54 +00:00
Sami Nurmenniemi
60f6e4428f Fix tst_QFile for qemu
Qemu does not report /proc/self/maps size correctly. Added expected
failure for it

Change-Id: I4019884702b8f9a33717b02e79c9e0c042b2449f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-06 12:19:55 +00:00
Liang Qi
0fc569184c Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp
	src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
	src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
	src/widgets/widgets/qtabbar.cpp

Change-Id: Iaa9daee5f7a6490d56257a3824730a35751ceb05
2017-04-06 14:16:31 +02:00
Marc Mutz
e1e6506c8d QString: add QStringView/QLatin1String overload of (non-multi) arg()
Use the new overload directly in QXmlStream*.

Saves 129B in QtCore text size on optimized GCC 6.1 Linux AMD64
builds, even though we added two more functions.

[ChangeLog][QtCore][QString] Added arg(QStringView),
arg(QLatin1String) overloads.

Change-Id: Idf7236dcab763824593f34182e4e0b16b5ed4321
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-06 12:06:18 +00:00
Marc Mutz
c928d08267 QTextCodec: add QStringView overloads
[ChangeLog][QtCore][QTextCodec] Added fromUnicode()
and canEncode() overloads taking QStringView.
[ChangeLog][QtCore][QTextEncoder] Added fromUnicode()
overload taking QStringView.

Change-Id: I2599f25570480d967921ccd4414e092bfc90d821
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-06 12:05:33 +00:00
Marc Mutz
be49235266 QStringView: use qssize_t as size_type
Nothing changes, we've just given 'QIntegerForSizeof<size_t>::Signed'
a better name in qglobal.h and now use it in QStringView API and
users.

Change-Id: Ibea1ae26e95b3a96708400fd4b0cd120459d57b6
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2017-04-06 02:38:25 +00:00
Liang Qi
aeb3f9d168 Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/dev 2017-04-04 16:15:55 +00:00
Liang Qi
9419dfe8ee Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
	src/plugins/platforms/xcb/qxcbwindow.cpp

Change-Id: Ic747c3c50e68c005b425e7a1ec2a90965527c8bd
2017-04-04 18:09:33 +02:00
Giuseppe D'Angelo
5eb74ad4f5 QRegularExpressionMatch: add QStringView-related functions
Change-Id: Ia81ba131cc2c7f56acb3312fbc7d62ffe5e18da4
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-04-04 15:35:22 +00:00
Marc Mutz
8b5aa7b6c4 QStringView: add an array ctor
With sufficient enable_if magic, the array ctor can overload the
pointer ctor and statically determine the size of the array passed.
Consequently, remove the sizeof in QStringViewLiteral again.

Change-Id: I486baa3cafefde60ccc5f2b47eb94ee53cefe63c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-04 11:33:08 +00:00
Marc Mutz
d40dcee642 QStringIterator: port to QStringView
Pretty straightforward, as the implementation already used only
an iterator range internally.

Change-Id: I6e6b809329e2e2548bba6db414a3d107d09637d1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-04-03 15:41:09 +00:00
Kai Koehne
b2efaeba79 tests: Unify license to GPL-EXCEPT
Change-Id: Ic718650a8a7bddd4ee28c5650a3f5baf70886e51
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2017-04-03 07:18:46 +00:00
Benjamin Terrier
d2388f15e7 Add QMetaObject::invokeMethod() overloads for function pointers
The new overloads do not accept parameters for the invoked function, this
use case is handled by using lambda.
Overloads for non member function pointers and functors are separated as
the return type is not retrieved in the same way.
Move QSlotObjectBase, QSlotObject and QFunctorSlotObject from
qobject_impl.h to qobjectdefs_impl.h in order to make them available in
qobjectdefs.h.
Update autotests of previous overloads because of a soft break in source
compatibility: passing null literals (0, NULL, nullptr, etc.) for the
second parameter of invokeMethod() is not supported anymore.

[ChangeLog][QtCore] Added QMetaObject::invokeMethod() overloads for function
pointers.

Task-number: QTBUG-37253
Change-Id: I6fb67e086d315ae393ce32743c4eb1abd6cc9139
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-04-02 08:00:27 +00:00
Joerg Bornemann
6ba8708a2f QProcess::startDetached: support custom process environment
Starting a detached process with a custom process environment can now be
achieved by:

    QProcess p;
    p.setProgram("foo");
    p.setProcessEnvironment(myEnv);
    p.startDetached();

[ChangeLog][QtCore][QProcess] Added the ability to set a custom process
environment for detached processes.

Task-number: QTBUG-2284
Change-Id: I49406dffb64fa2aed41ea05cb271bd42eeabb729
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 17:37:30 +00:00
Marc Mutz
0b9fb15b1a QStringView: add mid(), left(), right()
Change-Id: If1d2cf175d51b3c02881e21937b0a2d33b78aadd
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-31 11:23:59 +00:00
Marc Mutz
54dd87ca0f QStringView: add tests for relational operators
Remove most of the std::equal() tests that were used to determine
equality in pre-relational-operator-times again.

Amends a1421e4787.

Change-Id: Iff64808f5ac60861caee899d594b512b58046636
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2017-03-31 11:23:11 +00:00
Giuseppe D'Angelo
88a8feeacb QCryptographicHash: make SHA3 calculate SHA3, not Keccak
The SHA3 family is a modified version of Keccak. We were
incorrectly calculating Keccak (and even *testing* Keccak!),
but claiming it was SHA3.

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

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

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

Task-number: QTBUG-59770
Change-Id: Iae694d1a1668aa676922e3e00a292cddc30d3e0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 07:58:35 +00:00
Thiago Macieira
9a0d47bcf1 tst_largefile: fix the mapOffsetOverflow case to match actual behavior
Unix mmap(2) system calls do allow for mapping beyond the end of the
file, though what happens after you try to dereference the pointers it
gives is unspecified. POSIX[1] says that implementations shouldn't allow
it:
 The system shall always zero-fill any partial page at the end of an
 object. Further, the system shall never write out any modified portions
 of the last page of an object which are beyond its end. References
 within the address range starting at pa and continuing for len bytes to
 whole pages following the end of an object shall result in delivery of
 a SIGBUS signal.

However, Linux allows this in read-write mode and extends the file
(depending on the filesystem).

Windows MapViewOfFile never allows mapping beyond the end.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html

Change-Id: Ie67d35dff21147e99ad9fffd14acc8d9a1a0c38d
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-31 06:31:25 +00:00
Tony Sarajärvi
c031ba30d5 Blacklist a QSequentialAnimationGroup autotest
Task-number: QTBUG-59806
Change-Id: Ib63614dbd9d57283a6394bfc4079308a3f4ddc93
Reviewed-by: Liang Qi <liang.qi@qt.io>
2017-03-30 12:10:31 +00:00
Marc Mutz
7180236063 QStringView: improve manual overload management
We want to prevent

  QStringView(QChar|QLatin1String|QByteArray|const char*)

from compiling as QStringView(QString(...)), so I added = delete'ed
ctors for these types to QStringView. However, that makes QStringView
participate in overload resolution for these types. Even if the
QStringView ctor will always fail to compile, the presence of these
ctors alone makes calls to functions overloaded on QString and
QStringView ambiguous:

   f(QStringView);
   f(QString);
   f(foo);        // ambiguous
   f(QChar('f'))    // ambiguous
   f(QLatin1String(foo)); // ambiguous
   f(QByteArray(foo));    // ambiguous

Fix by making the QString and QStringRef constructors templates
constrained to accept only these two types. This should also help to
move the QStringView definition to before the QString one (as soon as
we get rid of or start to ignore QString::Null), simplifying a lot of
code in qstring.h down the line.

This should also fix MSVC's accepting of two user-defined conversions
which caused static non-compile-tests to fail in the initial
QStringView patch, and which were therefore removed. This patch brings
them back.

Change-Id: I95ac38c0d31cd8c726f7e952017569d32e484413
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-29 12:29:35 +00:00
Liang Qi
b48a13fd68 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	examples/examples.pro
	tests/auto/corelib/tools/qchar/tst_qchar.cpp
	tests/auto/other/qaccessibility/accessiblewidgets.h

Change-Id: I426696c40ab57d14dc295b8103152cede79f244c
2017-03-28 09:28:31 +02:00
Sami Nurmenniemi
514fff1e39 Fix largefile tests on ARM and QEMU targets
- Test tst_LargeFile::mapFile fails on Qemu for files over 4Gb.
  Fixed by limiting maxSizeBits to 28 (must be n*4 and < 32).
- Bug QTBUG-21175 is also effective on ARM targets. Fixed by
  expecting failure also on ARM.

Change-Id: I9103727e618a17259b4785ec8c284f3bb60ebea7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-28 06:55:32 +00:00
Liang Qi
7702fe8602 Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: Icdd71e9713725bda9c305e338f5c8b41a92ed8e8
2017-03-27 10:42:08 +02:00
Marc Mutz
59928d23fc Port QLocalePrivate::*ToCode() to QLatin1String
The returned data is in US-ASCII (or else Latin-1), and resides in
consecutive memory. We can therefore return it in a QLatin1String,
which, however, will in general not be NUL-terminated.

Many users use the return value as part of a QStringBuilder
expression, and those which are not are not pessimized further by
this change.

The caller in qtimezoneprivate_icu looks as if it could simply zero
-terminate the return value and use it as-is, as opposed to
converting to UTF-8, but I left the code equivalent to the original
just the same.

Change-Id: I0e628af8c1320fcff8d0aacf160e859681d2b85a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-26 06:44:29 +00:00
Marius Kittler
38550c562d json encoder: Harmonize number serialization with ES6
Ensures that numbers representable as 64-bit integer
are not printed using exponent notation.

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

Change-Id: Ic3ac718b7fd36462b4fcabbfb100a528a87798c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-25 14:26:30 +00:00
Marc Mutz
8092a01f84 QDebug: add op<<(QStringView)
[ChangeLog][QtCore][QDebug] Added streaming of QStringViews.

Change-Id: Id81fae223b60188d541b255b67bc316f9f1b6bef
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-24 20:43:03 +00:00
Marc Mutz
00a8be85d1 Long live QStringView!
QStringView is a simple container for (const QChar*, int) and (const
char16_t*, size_t). It acts as a replacement interface type for const
QString and const QStringRef, and enables passing all kinds of
string-like types to functions otherwise expecting const QString& -
without the need to convert to QString first.

The use of this new class is guarded by a macro that enables three
levels of QStringView support:

 1. offer QStringView, overload some functions taking QString with
    QStringView

 2. like 1, but remove all overloads of functions taking QStringRef,
    leaving only the function taking QStringView.  Do this only where
    QStringRef overloads tradionally existed.

 3. like 2, but replace functions taking QString, too.

This is done in order to measure the impact of QStringView on code
size and execution speed, and to help guide the decision of which
level to choose for Qt 6.

This first patch adds QStringView with most of its planned
constructors, but not much more than iterators and isNull()/isEmpty().

Further patches will add support for QStringView to QStringBuilder,
add QStringView overloads of functions taking QString, and add the
complete API of const QString to QStringView.

[ChangeLog][QtCore][QStringView] New class, superseding const QString
and QStringRef as function parameters, accepting a wide variety of
UTF-16 string data sources, e.g. u"string", std::u16string{,_view},
and, on Windows, L"string", std::wstring{,_view} without converting to
QString first.

Change-Id: Iac273e46b2c61ec2c31b3dacebb29500599d6898
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-24 18:34:35 +00:00
David Faure
83038a7acf QSFPM optimization in dataChanged: don't re-sort if the order didn't change
We can quickly check if the change affects sorting by checking whether
lessThan(N-1, N) and lessThan(N, N+1) are still true. If this is the case
for all changed rows, then we can skip the whole remove+insert+layoutChanged().

Task-number: QTBUG-1548
Change-Id: Ia778b3e8880cc9909eef1f8a016c84235870353d
Reviewed-by: Stephen Kelly <steveire@gmail.com>
2017-03-23 14:19:09 +00:00
Edward Welbourne
058642eae9 tst_QTimeZone: fix #if-ery to use Q_OS_DARWIN
Avoid using deprecated define in test.

Change-Id: I33550ae6cfb1ebe03550826371c763afa35f1972
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2017-03-22 17:12:21 +00:00
Ulf Hermann
329385a5d5 Build examples and tests only if their requirements are met
If the respective modules aren't available we cannot build the tests
and examples. We drop the qtConfig(opengl) requirement for the opengl
examples as
a, we would need to make the QtGui configuration available for that to
   work, and
b, we should not add too much detail to the tests and examples build
   configurations. Checking each test and example for every feature it
   uses would be too much.

Task-number: QTBUG-57255
Change-Id: Ifb043c81ec9e5c487765297bd65704812cd281fc
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-03-22 15:55:55 +00:00
Edward Welbourne
c587036dc6 Mark some methods in test code as overrides
CustomTextWidgetIface marked its text() method as an override;
DropOnOddRows marked its canDropMimeData() as an override; each
neglected some other methods that are overrides.  Convert
Q_DECL_OVERRIDE to the keyword in affected classes, to match.

Change-Id: I78b38e20a81e3e6aab282a1cb3d70cdf8a5f4135
Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-03-22 14:29:58 +00:00
Marc Mutz
1ebd23a670 tst_QArrayData: fix unused variable warning in reallocate()
Trailing QFETCHes can be dropped.

Change-Id: I4dbc5ff07a6bf418a09822424a8fb036d8349114
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-03-22 09:22:34 +00:00
Thiago Macieira
cd58abb1db Autotest: make tst_QDir more reliable on tests being run out of order
mkdir(data2) depended on mkdir(data1) being run before, or it would
fail. In addition, the rmdir() test required the equivalent mkdir() test
being run before. So drop these annoying dependencies and make the tests
cleaner by having clear separation of the test data and merging the two
tests into one

The entryList() test still depends on the testdir being clean: it will
fail if mkdirRmdir() previously failed.

Change-Id: Iaddbecfbba5441c8b2e4fffd14a3e35972d2a3d8
Reviewed-by: David Faure <david.faure@kdab.com>
2017-03-22 06:40:59 +00:00
Liang Qi
65faf45655 Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/plugins/platforms/eglfs/eglfs-plugin.pro

Change-Id: Id76cdbb41b7758572a3b8ea4dcb40d49bac968db
2017-03-21 19:07:53 +01:00
David Faure
05924ddff9 tst_qurl: skip test with ':' in filename, on Windows
Task-number: QTBUG-59622
Change-Id: Ib4b458b5d0fc2dd9ea6758b8517a953f6d768a39
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2017-03-21 13:15:53 +00:00
Thiago Macieira
99fc96fd37 QMetaType & QVariant: "load" and "save" std::nullptr_t
We don't load and save pointers usually because the pointer value cannot
be guaranteed to remain across program invocations. However, nullptr is
an exception: a null pointer is always a null pointer.

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

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

Task-number: QTBUG-59391
Change-Id: Iae839f6a131a4f0784bffffd14aa374f6475d283
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-20 21:53:32 +00:00
Tony Sarajärvi
bd6838d54d Blacklist tst_QPauseAnimation::multipleSequentialGroups on all macOS
Task-number: QTBUG-59218
Change-Id: Ic839a36af1ecab39da0c3394c34181b6717e24e2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-20 16:53:16 +00:00
David Faure
035e0eafa6 QUrl::fromUserInput: fix handling of files with a ':' in the name
QUrl::isRelative(str) would be false for such files, so first check for
file existence before doing any URL parsing.

Change-Id: I51b6229251ad94877ac408b2f8018456d3e10a36
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-20 12:55:36 +00:00
Liang Qi
dd613e65ea Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/dev 2017-03-20 10:56:29 +00:00
Liang Qi
ae2695535a Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/corelib/io/qfilesystemengine_win.cpp
	src/gui/text/qdistancefield.cpp
	src/plugins/platforms/xcb/qxcbconnection.h

Change-Id: I1be4a6f440ccb7599991159e3cb9de60990e4b1e
2017-03-20 09:00:44 +01:00
Anton Kudryavtsev
1dc4c3817b QStringList: add contains(QLatin1String) overload
... to avoid the expensive conversion from QString to QL1S.

[ChangeLog][QtCore][QStringList] Added contains(QLatin1String) overload.

Change-Id: Ie75839ce9e46e03fe5155a02c7dcf00277b95c8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-20 06:16:59 +00:00
Anton Kudryavtsev
4a97e3b98a QMap, QHash: make key_iterator satisfy the DefaultConstructible concept
Change-Id: Ifc3f481ddb902b26c217516412c93a4a39a32b1c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-20 04:36:42 +00:00
Marc Mutz
5c724a6087 QChar: fix ambiguous comparisons with 0, '\0', ... for good
Commit e0ea0f6178 optimized QChar <->
QString(Ref) comparisons by adding more overloads to avoid creating
QStrings from QChars just to compare them.

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

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

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

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

Change-Id: I680dd509c2286e96894e13078899dbe3b2dd83bc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-17 20:28:32 +00:00
Marc Mutz
93a4bf5c8b Blacklist also tst_QSemaphore::tryAcquireWithTimeout(2s)
It has started failing recently on the CI, too.

Task-number: QTBUG-58745
Change-Id: I4c8834917e6455d00c300549ed448b06da75d5bc
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
2017-03-17 20:19:20 +00:00
Marc Mutz
1b73d13975 tst_QMimeDatabase: increase update-mime-database timeout to 4mins
in the vain hope to get the CI unstuck again.

Change-Id: I1b01bb1d59a8850f68d1d80838f5606f4159bcbd
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
2017-03-17 20:08:56 +00:00
Jesus Fernandez
346cd79192 Make QFile::open fail when using an invalid file name
Fixes the bug in QFile which allowed opening a file with reserved
characters in its name.  If the name is a long file path, CreateFile
opens a file with a truncated name instead of failing, so we have
to catch reserved characters ourselves.

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

Task-number: QTBUG-57023
Change-Id: I01d5a7132054cecdfa839d0b8de06460039248a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-17 11:06:43 +00:00
Marc Mutz
208c71768c QChar: add (char16_t) and (wchar_t) ctors
... for better std C++ integration.

[ChangeLog][QtCore][QChar] Added constructors from char16_t and, on
Windows, wchar_t.

Change-Id: I2d18ea3a37e869b8ea9f4036d7200d9d13c7d929
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-17 01:14:54 +00:00
Filipe Azevedo
7f1a220ee4 Add support for recursive filtering in QSFPM
You can now use the recursiveFiltering property to recurse into
children to find potential matching children to filter in.

Change-Id: I411a2fb29489fd56b9c881b3e6b8d1860cce630c
Reviewed-by: Stephen Kelly <steveire@gmail.com>
2017-03-14 21:34:37 +00:00
Olivier Goffart
7ac100ddd1 tst_QObject: Test if the new connect style works with multiple inheritance
Change-Id: I638630ef84a3aee98688dac000efd3dfa7472175
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-14 13:55:36 +00:00
Liang Qi
0c034a649f Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/widgets/widgets/qpushbutton.cpp

Change-Id: I615de00e6e64540c50f658d4d8ab3e002d701a81
2017-03-14 10:52:24 +01:00
Liang Qi
77e71dac16 Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9 2017-03-13 19:45:20 +00:00
Liang Qi
d51c3ecf8e Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	examples/network/network.pro
	mkspecs/features/mac/default_post.prf
	src/corelib/io/qfilesystemengine_win.cpp
	src/corelib/io/qprocess.cpp
	src/corelib/io/qprocess.h
	src/corelib/io/qprocess_p.h
	src/corelib/io/qprocess_unix.cpp
	src/corelib/io/qprocess_win.cpp
	src/corelib/thread/qmutex.cpp
	src/platformsupport/fontdatabases/windows/windows.pri
	src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
	tests/auto/corelib/io/io.pro

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

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

Change-Id: Idc9453af993e7574a6bddd4a87210eddd3da48a9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-13 11:03:47 +00:00
Marc Mutz
75f5e2bef2 Deprecate QString::null
It's a Qt 3 compatibility vehicle, and as such inherits the now-alien
property to distinguish empty and null strings. Particularly worrisome
is the following asymmetry:

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

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

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

Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2017-03-12 17:41:16 +00:00
Olivier Goffart
b52b509ae4 QLockFile: Don't deadlock if the lock file has a mtime in the future
Stale Lock files in the future can happen in some situations. For exemple
two computers with different clocks access the same file system. It could
be that one of the timestamp is totaly off (several years into the future).

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

Change-Id: I8dac98a0e898c76bcef67f8c195e126c996b6add
Reviewed-by: David Faure <david.faure@kdab.com>
2017-03-10 17:09:24 +00:00
Marc Mutz
1567a7c0f4 Use new QSemaphoreReleaser in tst_QThreadPool
... replacing a hand-rolled version there.

Change-Id: I0db50acd1ecf591d608eb719021a6fcd06aeb226
Reviewed-by: David Faure <david.faure@kdab.com>
2017-03-09 19:04:33 +00:00