Systematic testing in tst_QStringApiSymmetry revealed a bug in
QStringRef::toLatin1(): a null input did not result in a null output,
but an empty one. This is fixed, for consistency with
QString::toLatin1(), and QString(Ref)::toUtf8(), which behaved
correctly already.
The same bug was found in QString(Ref)::toLocal8Bit(), which is
particularly hideous, as it's documented to fall back to toLatin1(),
which preserves null inputs. Fixed, too.
[ChangeLog][QtCore][QString] toLocal8Bit() now preserves nullness of
the input QString (outputs null QByteArray).
[ChangeLog][QtCore][QStringRef] toLocal8Bit() and toLatin1() now
preserve nullness of the input QStringRef (output null QByteArrays).
Change-Id: I7026211922c287e03d07e89edbad2987aa646e51
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
tst_QDateTime::operator_insert_extract() was setting the time-zone and
taking care to restore it at the end of the test; however, if the test
were to fail, the restore would be skipped. Package the zone-setting
and restore in a class instance, so that premature return can't bypass
the restore.
Change-Id: I3df63260da17e481ef4d0d107d9f0fdea3e147e7
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
We keep the runnables from finishing by having them block
on a QSemaphore::acquire() call inside run().
If we fail a test that precedes the call to sem.release()
further into the test, the early return will cause the
thread pool to be destroyed, which will then attempt to
wait for the runnables to finished, which, in turn wait
for the semaphore to be released.
-> dead lock
Fix by introducing a RAII object to release the semaphore
with a sufficiently large number to unblock all runnables.
That number will in some situations be too large, but that
does not matter.
Change-Id: I1ec7e29b37bc36309e93e6e30708cc7db3c9579c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In order to get reproducible runs of the test, we need to
wait in the main thread until all runnables have started
executing. Otherwise, what the cancel() loop below actually
does will vary from run to run.
Change-Id: Ib912b0943e7bbd55c9480ae6fd4011ba20ac457e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Instead of allocating a statically-sized array on the heap,
use an automatic C array instead.
Replace some magic numbers with named constants.
Change-Id: I17d29a76a67c4a413453ac26a5dee8cd54a8a37d
Reviewed-by: David Faure <david.faure@kdab.com>
Manipulating a simple int from multiple threads is a data race,
thus undefined behavior.
Fix by using QAtomicInt and atomic operations instead.
Change-Id: I5418bc260da57fe353a71b8e5c7c1c97adbe7597
Reviewed-by: David Faure <david.faure@kdab.com>
This should reduce the failure rate. We're still doing qSleep of the
same amount of time, but we now only fail if the slip is over 100 ms.
Task-number: QTBUG-58713
Change-Id: I536c32a88bff44dab37afffd14a1afdf0b2e522a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
currencySymbol == "$" does not mean negative currency values will be formatted
as "($value)". With all locales I have on my mac machines (10.11/10.12) the
result is different from what this test expects. Also, the results are very
different for different locales. Apparently, we never saw this problem before
since in our CI "macs" we never have US Dollar/en_US selected in System Preferences.
Task-number: QTBUG-58784
Change-Id: Ic2c3a3172bf1e715e99092ddee8f461b216d995a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
The runUpdateMimeDatabase() call was timing out on the CI due to
running out of the default 30s timeout for QProcess::waitForFinished()
(on my machine, that call takes less than 0.5s, reliably...).
Increase to two minutes.
Change-Id: I61b2e060ea9c2508b853847ba7040ad499e0084c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
When one of the QCOMPAREs in Consumer::run() fails, the consumer
returns early, leaving the producer deadlocked in a QSemaphore's
acquire() call. Change these to tryAcquire() with a large timeout,
so the producer, too, eventually leaves run().
Change-Id: I7421d43305decd4754e09c8e092363594d1be06b
Reviewed-by: David Faure <david.faure@kdab.com>
This test was determined to be flaky on the CI.
Task-number: QTBUG-58741
Change-Id: I43196d3a27f726fb96b427f5071e726b571a0404
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
This is a simple RAII class that makes semaphore releasing
reliable in the face of exceptions and early returns.
This code originates from KDTools' KDSemaphoreReleaser[1], but
has been extensively reworked to support C++11 move semantics.
[1] https://docs.kdab.com/kdtools/2.3.0/class_k_d_semaphore_releaser.html
[ChangeLog][QtCore][QSemaphore] Added a new RAII class, QSemaphoreReleaser,
to reliably perform release() calls.
Change-Id: I6aff64d37cc0882b17c4419817bde60b542f34d9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Add proper support for 'so' and 'bundle' suffixes. Qt wrongly assumes
.so libraries are not versioned on Apple platforms, which is
wrong. Also, the shared library .bundle which is what Apple recommends
instead of .so, are also versioned (not to be confound with the
different Core Foundation bundles, which are directory hierarchy).
For more info, see http://docstore.mik.ua/orelly/unix3/mac/ch05_03.htm.
Especially the part that reads:
"Loadable modules, called bundles in Mac OS X, have the file type
MH_BUNDLE. Most Unix-based software ports usually produce bundles with a
.so extension, for the sake of consistency across platforms. Although
Apple recommends giving bundles a .bundle extension, it isn't
mandatory."
Task-number: QTBUG-50446
Change-Id: Iacd5136397a12d65d83821434f332eb602550b4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Vectorized versions of ucstrncmp work on larger chunks of text
(typically 8 characters and an optional 4 more in some cases), so there
are now 4 extra sets of tests:
- strings of 1-65 characters, all different
- strings of 1-65 characters, all the same
- strings of 1-65 characters, all the same *except* the last character
- strings of 16 characters long, all the same except one, and that one
is different for every string (i.e. first string differs in first
char, second in second char, etc)
This should excercise both 1 or more iterations of the vectorized loop,
the detection logic inside the loop, and off-by-one cases.
The input is all ascii, so the ::compare() test will run them for both
QChar-QChar comparisson and for QChar-latin1 comparisson.
Change-Id: Ifaa7e019c63b581d4af5aef6dcfb3e7456c7d360
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This reverts commit b0c1e07d64.
The unit tests it introduced trigger errors with the macOS and
Win32 implementations, which means the there's something seriously
wrong with either the API, our implementation or the tests.
Revert for now until this gets fixed. Blacklisting was also the
wrong tool to use. The tests should have used QEXPECT_FAIL.
Change-Id: Ida20c6bbe0c019835a22464535029585e8e1e367
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There weren't any, at all.
Testing on the CI showed that the implementation is broken on
macOS, and, to a lesser extent, on Windows, so blacklist the
failing tests until the implementation can be fixed. No need
to hold back testing the other implementations.
Task-number: QTBUG-58737
Change-Id: I9ae16ab778dbe2e95a6ca5e0bae00df4bad65cb2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This test was determined to be flaky on the CI, depite attempts
to stabilize it (b750a3786f).
Task-number: QTBUG-58745
Change-Id: I933199cd537002699906147d172bb797f1dc90c1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This test was determined to be flaky on the CI.
Task-number: QTBUG-58713
Change-Id: Ie6e6a69b8ea625e3a3102c88d52f1f0fbec242aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
When a non-QString-backed mode (via the (QChar*, int) ctor) was added
for Qt 4.5, the author forgot to adjust the setCaseSensitivity()
function. It still uses q_pattern instead of (p.uc, p.len) as the
pattern for which to create the skip-table. Since there is no
setPattern() overload for this mode, the correctness of the matcher is
not harmed by this, but its performance degrades to that of a linear
scan: the skip-table, being filled from an empty pattern, will be
all-zeros, sending bm_find() into the 'possible match' case at every
character.
Since matching is still correct, but slow, it's not possible to write
a test for this. I did, however, leave my attempts in the auto-test,
for when we add QStringView overloads of setPattern() which will then
be able to expose the bug.
Change-Id: I7b803e8624b0352a0a974900affbbfc0c260d93b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
When a QFile object is reused, the atEnd() method may return incorrect
values. The reason for this is that QFileDevicePrivate::cachedSize is
not cleared. Setting cachedSize = 0 in the close() method fixes this issue.
Task-number: QTBUG-57698
Change-Id: I828a2cf844e98d581098f2c781fa47d2cd3275ce
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
At 200 ms, the error on first firing could be 10 ms.
Task-number: QTBUG-58519
Change-Id: Ifaee7464122d402991b6fffd14a02a4ce782f11f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
tst_qsortfilterproxymodel.cpp:3997:14: warning: 'data' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
tst_qsortfilterproxymodel.cpp:4004:9: warning: 'rowCount' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
accessiblewidgets.h:101:11: warning: 'interface_cast' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
accessiblewidgets.h:115:13: warning: 'textBeforeOffset' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
accessiblewidgets.h:121:13: warning: 'textAtOffset' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
Change-Id: I75ba00a0109ff25a2a22554980b8e541e661f806
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
On macOS, the code that read the plist is using
QByteArray::fromRawCFData. When we return the data directly
we need to detach the QByteArray so that it does not point
CFData's data that will get deallocated just after the call.
Task-number: QTBUG-58531
Change-Id: If829a304b986c99c8fc2aeeb992f2d539a4eef3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
As used in recent qtdeclarative commits, so better make sure it keeps working.
Change-Id: I6d0ceda76201e3e7f75661cb6449e1ff32329126
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There was a test that tested this, but was wrong.
[ChangeLog][QtCore][QVariant] Fixed a bug that caused wrong results for
comparisons of QVariants containing either NaN or infinite numbers.
Task-number: QTBUG-56073
Change-Id: I33dc971f005a4848bb8ffffd1475d29d00dd1b7f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This constitutes a fairly complete submission of an entirely new
floating point type which conforms to IEEE 754 as a 16-bit storage
class. Conversion between qfloat16 and float is currently performed
through a sequence of lookup tables. Global-level functions
qRound(), qRound64(), qFuzzyCompare(), qFuzzyIsNull(), and
qIsNull() each with a qfloat16 parameter have been included
for completeness.
[ChangeLog][QtCore] Added new qfloat16 class.
Change-Id: Ia52eb27846965c14f8140c00faf5ba33c9443976
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Under certain circumstances, VS2015 reported ambiguous options in using
the operator>(Enum,int) operator. This change adds a static_cast<qint64>
to remove any ambiguity. In the process of testing this change, a gap
in the existing logic was identified: the handling (just in the test
code) of large negative enum values. Consequently, and additional
test case was added, and additional if-conditions were added to account
for that case.
Change-Id: Ife2c471ba4caa4b9a0107722042114e58145c4d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The first one was already suppressed for GCC, so also do that for clang:
/Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:1076:16: warning: format string is not a string literal (potentially insecure)
[-Wformat-security]
a.sprintf( zero );
^~~~
/Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:1076:16: note: treat the string as an argument to avoid this
a.sprintf( zero );
^
"%s",
The second one could also occur with other compilers, so fix it in a
generic way.
/Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:6382:5: warning: ignoring return value of function declared with
warn_unused_result attribute [-Wunused-result]
string.repeated(3);
^~~~~~~~~~~~~~~ ~
2 warnings generated.
Change-Id: Id999179e795580a37b5be673ee54d6fa1a006dd7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Because on Windows, the .ini files are saved with CRLF, but the files in
the Qt resource are just LF (.gitattributes makes them so).
Task-number: QTBUG-25446
Change-Id: I5eab0d9620bd1ba675b0a87c554f62cef0f98fcc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- port from inefficient QLists to QVector
- mark types held in Qt containers (incl. QVariant) as Q_MOVABLE/PRIMITIVE_TYPE
- remove pointless user-defined copy special members which prevent the class
from having nothrow move special members
Fixes errors reported by my local tree's static checks.
Change-Id: If3910484cea81a8e2c5ab737908c9443f75782c5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
There was an off-by-one error in the while loop for aarch64: we start
counting at 0 for the first position, so the last valid input position
is "a+7", not 8.
This wasn't covered by the tests, nor was the SSE2 version, so now there
are also tests for both versions.
Change-Id: I7eb8c5708e6179f45ea56885b0e66e1a37969c1d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Implements isNull for QVariants of a nullptr so they always return
true to isNull(), instead of depending on how they were constructed.
Task-number: QTBUG-58296
Change-Id: Ibddec795cdadedef7e17d22c265c29e752d8f99f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Do not wait up to the timeout ms after already having waited several
times. At the same time upgrade to using the QDeadlineTimer which
is designed for this purpose.
Change-Id: Iaf5e4f4655605d5143ce91040c6eb6706752e504
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Remove the qWait() and introduce a QTRY_COMPARE()
checking for the end value first.
Task-number: QTBUG-58402
Change-Id: I2d3758178de5f67881008f28c406076ad27c4a90
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Use QTRY_COMPARE with a timeout to check for the stopped state
unless BAD_TIMER_RESOLUTION is defined.
This speeds up the test by 1s and prints diagnostic information
should an interval be too short (as seems to be the case on macOS,
currently).
Change-Id: I8f884cd66ad33314124d3130d9f49606e6dfe9f3
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
[ChangeLog][QtCore][QFileSelector] Removed the requirement for an unused
default base file in case you want to load only a variant.
When the base file (e.g. /image.jpg) was missing, no selectors were
considered and it was not possible to load variants of this file (e.g.
/+android/image.jpg, /+android/+tablet/image.jpg) without specifying the
directory as well.
As a work around, one previously had to place a default file in
the base location, which is undesirable in some cases because:
1. The extra file consumes unnecessary space.
2. It is impossible to encapsulate platform-specific implementation
details by hiding files in a subdirectory.
Task-number: QTBUG-51230
Change-Id: I4c7f9ec952bff6e5b7738d8cabe3c762c208a38e
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
This is a version of QByteArrayMatcher that calculates the
Boyer-Moore skip table at compile-time instead of at run-time,
making this class more generally applicable than QByteArray-
Matcher itself, at least for statically-known strings.
The compile-time part requires C++14 constexpr support, but
the class should compile and work even in C++98 mode, just
with runtime initialization of the skip-table.
While touching tst_qbytearraymatcher, clean up the static
global QByteArrayMatchers there and add tests with needles
longer than 255 characters for QByteArrayMatcher, too.
[ChangeLog][QtCore] Added QStaticByteArrayMatcher.
Change-Id: I0662f262ab19b79ae4096f3ab384d5b3ada72347
Reviewed-by: David Faure <david.faure@kdab.com>