Commit Graph

3160 Commits

Author SHA1 Message Date
Mårten Nordheim
06044df0e3 Android: tst_qthread: terminate is not supported
"terminate" and "terminated" both fail on Android since
QThread::terminate not supported on Android. So we should skip them.

Task-number: QTBUG-68596
Change-Id: Id0d1dde2cfa02bb2978e5dd16087bf8f3bf112b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-21 14:14:27 +00:00
Edward Welbourne
9f8938b89a Cope if mktime() deems times in a spring forward gap to be invalid
In tst_QDateTime::springForward(), we test correct handling of times
in the gap; these are formally invalid and a mktime() implementation
may reasonably reject them causing our date-time code to produce an
invalid result.  So handle that case gracefully in the tests, only
insisting on consistency between the two ways of preparing the date.
In one test, package the repeated code I was going to adapt into a
macro to save repeitition.

Task-number: QTBUG-68832
Task-number: QTBUG-68839
Change-Id: Ib8a16ff007f4e75ab2ccff05b1ccf00a45e50dc8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2018-06-21 10:40:43 +00:00
Edward Welbourne
b248a35a09 Add Android to exceptions in tst_QDateTime::toString_textDate_extra()
Android doesn't use the proper zone-abbreviation, so just check it
starts with the right date-time.  Revised the way the #if-ery for that
is handled, to avoid repetition of the (now more complex) condition in
the two tests affected.

Task-number: QTBUG-68833
Change-Id: Iceb5469f46c69ba5cdbaf7ca050ad70f2bb74f44
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-21 10:40:36 +00:00
Edward Welbourne
e08ba34f26 Cope with Android's lack of time-zone abbreviations
Have a test expect what it does produce rather than fail what we can't
fix.

Task-number: QTBUG-68837
Change-Id: Icda7bd9968682daf97d46d597f8bb0433560cde2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-21 10:38:09 +00:00
Edward Welbourne
67bbe59a37 Make some QEXPECT_FAIL()s consistent in form and content
They used different messages for the same excuse, which weren't well
worded in any case; and their #if-ery was differently decorated.

Change-Id: I28f5032693aff1036cb086ac4032c669110a5cb5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2018-06-21 10:37:56 +00:00
Edward Welbourne
91f3687ee5 Make QString's formatting of doubles be consistent with other places
QString::sprintf(), like the C printf-family, always includes two
digits in any exponent it outputs.  Up to 5.6, number() and arg()
taking a double did the same; but changes at 5.7 to enable opting out
of the leading zero this implies for a single-digit exponent
accidentally opted out of it in args() and number().  This commit
fixes number() and arg() to include QLocaleData::ZeroPadExponent in
the flags they pass down to the C locale's doubleToString(), restoring
the prior behavior, including consistency with sprintf().

[ChangeLog][QtCore][QString] Formatting of doubles with single-digit
exponent, by number() or args(), now includes a leading zero in that
exponent, consistently with sprintf(), as it did up to 5.6.

Task-number: QTBUG-63620
Change-Id: I10c491902b8556e9f19e605177ead8d9fd32abd9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-06-14 09:13:36 +00:00
Allan Sandfeld Jensen
d517d5428c Use qFuzzyCompare instead of qFuzzyIsNull in QPointF ==
qFuzzyIsNull has a fixed range, where qFuzzyCompare can tell if numbers
are different in a more relative range. Without it QPointFs that are
heavily scaled will be interpreted as identical, when they are quite
different at their own scale.

Task-number: QTBUG-60359
Task-number: QTBUG-62161
Change-Id: Ic4ba90e9e994aedff5548d690f053eb309b0a60b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-30 08:28:11 +00:00
Mikhail Svetkin
6b98d97670 macOS: Fix QFileSystemWatcher to watch paths with the same prefix
It happens because our filesystemwatcher thinks it is subdirectory and not
two different paths

Task-number: QTBUG-60676
Change-Id: Ic753e9481cb26303a030044e0a5ab4d703bc529f
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-05-29 06:32:46 +00:00
Christian Ehrlicher
e15fc26e9f QSortFilterProxyModel: don't assert when old model gets destroyed
When a new model was set with setSourceModel() and the mapping was
built up, the destruction of the old model caused a reset in the
QSortFilterProxyModel which lead to an empty view or an assertion.
Now we properly disconnect the old model again and also clean up the old
mapping/persistent indexes when a new source model is set.

Task-number: QTBUG-44962
Task-number: QTBUG-67948
Task-number: QTBUG-68427
Change-Id: I2e0612899c210bde3ac0cfa59aefd78269deee5b
Reviewed-by: David Faure <david.faure@kdab.com>
2018-05-26 11:24:53 +00:00
Thiago Macieira
c359df5ca6 Add support for QSharedPointer<cv qualified>::create()
[ChangeLog][QtCore][QSharedPointer] Fixed a problem that made create()
on a type with const qualification fail to compile.

Task-number: QTBUG-68300
Change-Id: I0825ff5b5f6f4c85939ffffd152f3e55e5b9caae
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-17 15:08:04 +00:00
Kari Oikarinen
2fc274ddb5 Skip tst_QProcess::processesInMultipleThreads under QEMU
tst_QProcess hangs sometimes in QEMU. Based on my experiments in a debug VM the
offending test seems to be processesInMultipleThreads(), since that was were I
was able to reproduce the hanging in.

Since the whole test executable hangs, blacklisting is not enough, so skip the
test.

Task-number: QTBUG-67760
Change-Id: I34f8852be955a8612deac22b369f68d79a139d11
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2018-05-14 12:36:33 +00:00
Jüri Valdmann
8e47474baf QJsonDocument: Avoid overflow of string lengths
The added test case contains the binary JSON equivalent of

    ["ž"]

with the modification that the string's length has been set to INT_MAX. In
Value::usedStorage this length is used through the pointer d like so

    s = sizeof(int) + sizeof(ushort) * qFromLittleEndian(*(int *)d);

Because 2 * INT_MAX is UINT_MAX-1, the expression as a whole evaluates to 2,
which is considered a valid storage size. However, when converting this binary
JSON into ordinary JSON we will attempt to construct a QString of length
INT_MAX.

Fixed by using String::isValid instead of Value::usedStorage. This method
already takes care to avoid the overflow problem. Additionally, I've tried in
this patch to clarify the behavior of Value::isValid a bit by writing it in a
style that is hopefully more amenable to structural induction.

Finally, the test case added in my previous patch had the wrong file extension
and is renamed in this one.

Task-number: QTBUG-61969
Change-Id: I45d891f2467a71d8d105822ef7eb1a73c3efa67a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-14 10:52:47 +00:00
Oliver Wolff
da97dcec3e tst_qresourceengine: Fix test for static MSVC builds
The test relies on the existence of qt-project.org in resources. It
contains mimetype data and is automatically added. For static builds on
MSVC it is only added if it is actually needed though.

Change-Id: Icd1d74466607196f9b635205f7cb4d9b300ec4b8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2018-05-07 07:59:15 +00:00
Oliver Wolff
a27f888dec tst_qresourceengine: Fix test for configurations with builtin_testdata
If builtin_testdata is present additional data ends in inside of
resources so that tests can access this data when needed. The addiitonal
data has to be taken into account in the resource engine's test.

Change-Id: I10de6b9612ca49b314d77cfadd5b2360a5d90d53
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-05-07 07:59:37 +00:00
Oliver Wolff
4dada8068a tst_qiodevice: Skip broken winrt tests
Change-Id: I399cc1aed3ee4151cf6adfd8f8780d8975604d52
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
2018-05-07 07:37:51 +00:00
Jüri Valdmann
93e0ff037e QJsonDocument: Validate also zero-length objects
The added test case is the binary JSON equivalent of

    {"a":{"š":null}}

with two modifications. First, the length of the string "š" has been corrupted
to 0xFFFFFF00. Second and more import, the Base::size field of the inner object
has been reset to 0.

On its own the first modification would normally trigger a validation error.
However, due to the second modification the Value::usedStorage for the inner
object evaluates to 0, completely disabling all further validation of the
object's contents.

Attempting to convert this binary JSON into standard JSON will lead to the JSON
writer trying to construct a QString of length 0xFFFFFF00.

Fixed by validating also objects with usedStorage == 0.

Task-number: QTBUG-61969
Change-Id: I5e59383674dec9be89361759572c0d91d4e16e01
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-04 12:04:05 +00:00
Jüri Valdmann
3fc5500b4f QJsonDocument: Reject objects containing themselves in binary JSON
The added test case is a binary JSON file describing an array which contains
itself. This file passes validation even though attempting to convert it to
plain JSON leads to an infinite loop. Fixed by rejecting it in validation.

Task-number: QTBUG-61969
Change-Id: Ib4472e9777d09840c30c384b24294e4744b02045
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-05-04 12:03:57 +00:00
Jüri Valdmann
d3935cbd71 QJsonDocument::fromRawData: Fix out-of-bounds access
This method takes a pointer+size pair, but begins reading through the pointer
without first checking the size parameter. Fixed by checking the size parameter.

A new test case is added with an empty binary json file. Although the test does
not fail under normal conditions, the problem can be detected using valgrind or
AddressSanitizer.

Task-number: QTBUG-61969
Change-Id: Ie91cc9a56dbc3c676472c614d4e633d7721b8481
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-04 11:53:03 +00:00
Friedemann Kleint
7a1df39010 Tests: Fix clang warnings about unused variables and captures
tst_qline.cpp(170,12):  warning: unused variable 'baseB' [-Wunused-variable]           ^
tst_qline.cpp(169,12):  warning: unused variable 'baseA' [-Wunused-variable]
tst_qheaderview.cpp(3329,14):  warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
    waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });

qheaderview.cpp(3338,14):  warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
    waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });

Change-Id: I0245a7b66d15b896e864b488f7a58e8513fbdc6c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-02 09:36:00 +00:00
Daniel Teske
259648f876 QItemSelectionModel: More fixes for is(Column/Row)Selected
Replace the code for isRowSelected and isColumnSelected with
a much simpler algorithm for deciding if a row/column is selected.

In a model with a cross-hatch of unselectable indexes, the return values
of is(Column/Row)Selected would depend on the order in which the
selections were done.

Task-number: QTBUG-18001
Change-Id: I6aa4b1df7c07fae469a686041927fa8c42bc9b16
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2018-04-30 19:01:14 +00:00
Thiago Macieira
ff029a9ca8 tst_QString: remove old HP aCC workaround
Change-Id: I3840d727dee443318644fffd15291b1d77dca2fc
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2018-04-27 07:07:45 +00:00
Thiago Macieira
309dacedac Atomics: remove requirement for alignment equality with plain types
This was originally added so that you could replace a T with
QAtomicInteger<T> in the same class and still keep ABI. However, for
legacy reasons, on 32-bit x86, types larger than 4 bytes keep an old
1990s alignment of only 4 bytes, but modern std::atomic<T> for those 8-
byte types enforces an alignment of 8 bytes. Therefore, the requirement
to keep alignment is not possible to guarantee.

In other words: you may not replace T with QAtomicInteger<T> or
std::atomic<T> and assume no ABI breakages in all platforms.

This is a requirement to implement atomicity. An 8-byte type aligned to
only a 4-byte boundary could cross a 16-byte boundary or, worse, cross a
cacheline boundary. Crossing the 16-byte boundary could be bad on some
processors, but crossing the cacheline boundary (addresses ending in
0x3C, 0x7C, 0xCC and 0xFC, or 4 out of 64 possible addresses or 6.25%)
is always bad: the CPUs cannot guarantee an atomic load or store
operation.

See also <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71660>.

Task-number: QTBUG-67858
Change-Id: If90a92b041d3442fa0a4fffd15283e4615474582
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-04-24 17:36:42 +00:00
Kari Oikarinen
12559058b0 tst_QFile: Don't expect Windows HANDLE equality in nativeHandleLeaks()
That check is flaky on Windows. It doesn't seem to be testing Qt functionality.
I also don't see CreateFile2() documentation mentioning any guarantees that
opening the same file twice would give the same HANDLE each time.

Change-Id: Ica2e60571ae9fc39bf822803a2a9dd6add8323d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2018-04-23 12:45:32 +00:00
Oliver Wolff
215e0f35d0 tst_qdir: Fix absoluteFilePath for winrt
The drive has to be defined for every Windows configuration (also
including winrt).

Change-Id: I94a3131b8aec20cda97dc78f55b1d87aa10240e4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-04-16 05:23:17 +00:00
Kari Oikarinen
3e2c930242 tst_QEventLoop: Remove unconditional qWait()
Task-number: QTBUG-63992
Change-Id: I9d9e3966252f01cded489313561641e1c0292b91
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2018-04-10 08:32:21 +00:00
Edward Welbourne
28c9ad199c Revise dates of Pacific/Kiritimati's day-skip transition
The TZ database has recently revised its ccount of when they skipped a
day to cross the international date line, from skipping Jan 1st 1995
to skipping December 31st 1994.  So Move the before-days check to
December 30th; and correct the Feb 2nd that was meant to be Jan 2nd
(and does need to remain so, for compatibility with systems with out
of date data).

Task-number: QTBUG-67497
Change-Id: I5b9483c553205817f995f91793662a5a85e03192
Reviewed-by: Liang Qi <liang.qi@qt.io>
2018-04-06 18:05:04 +00:00
David Faure
a1b1dd3b84 QMimeDatabase: fix assert when fetching data for invalid mimetype
The Q_ASSERT(mimePrivate.fromCache) at qmimedatabase.cpp:218
which I added in commit 7a5644d648, was being triggered when calling comment()
for invalid mimetypes such as db.mimeTypeForName("").

Change-Id: I8037041a4b435d2a5ba24ec94b7858e38b2f0bf2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-04-06 07:19:01 +00:00
Kari Oikarinen
b32d16d468 tst_QLocale: Avoid manual deletes
Also use data-driven test to reduce duplication.

Change-Id: I9516e52267cb3c7b239030fd73dbbf23ac8f52f7
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-04-06 05:44:50 +00:00
Edward Welbourne
3c8181de70 Kludge QLocale test order to fix fall-out from setDefault()
This makes an irreversible global change: tests that do it will mess
with other tests.  So make sure they're all last.  This required
splitting up one test; and revealed another that secretly depended on
being run with C as default locale.

Task-number: QTBUG-67276
Change-Id: Ic24ef48b2c9bd5c37c1f11260b437628019624ca
Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
2018-04-05 19:56:47 +00:00
Kai Koehne
50d301cfdd Hide global qtlogging.ini from autotest
Do not let a global qtlogging.ini interfere with an autotest.
This works around an issue on Ubuntu 17.10

Task-number: QTBUG-67385
Change-Id: I0d02835eb7a561b43fe0b98f4383c170c6d51303
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joni Jäntti <joni.jantti@qt.io>
2018-04-05 05:40:07 +00:00
Kari Oikarinen
3e1ecdd74c tst_QStateMachine: Don't use unconditional waits
Instead use QSignalSpy to wait directly for the expected events.

Change-Id: I319302ea7177fe690b5d885347c505454904518e
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-04-04 07:07:40 +00:00
Kari Oikarinen
c7dac6469c tst_QThread: Use QTRY_VERIFY instead of qWaits
These two places were sort of manually implementing QTRY_VERIFY except that they
never time out.

Change-Id: I136e6c7400194327c0475c6acfc019825ccec1b5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
2018-04-03 10:20:36 +00:00
Kari Oikarinen
231ac1b878 tst_QFutureWatcher: Avoid unconditional qWait()s
Use QSignalSpy::wait or QTRY_VERIFY instead. This shaved off ~200 ms of the
running time of the test and is more reliable.

Some unconditional qWait()s still remain in this test. They are giving an
opportunity for the wrong thing to happen and thus are not waiting for any
specific condition to be fulfilled.

Task-number: QTBUG-63992
Change-Id: I25a4470fe8d6a5b8b5039b3ed77321d24faa1707
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-04-03 10:20:27 +00:00
Svenn-Arne Dragly
50cfbd6112 Animation: Fix case where QEasingCurve::valueForProgress returns nan
Previously, we would divide by zero in BezierEase::findTForX if factorT3
was zero when solving the cubic equation.

This change fixes the problem by adding solutions for the special cases
where the cubic equation can be reduced to a quadratic or linear
equation.

This change also adds tests that cover cases where the equation becomes
quadratic, linear or invalid.

Task-number: QTBUG-67061
Change-Id: I2b59f7e0392eb807663c3c8927509fd8b226ebc7
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
2018-03-26 15:53:10 +00:00
Eric Lemanissier
edf96b984d fixup oversight in rvalue overloads of operator+=() and operator<<()
ammends 4dee5446be

Change-Id: Ia0ca27644eb71815a93d6e76681b8a9e61a4e7ab
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2018-03-26 14:29:47 +00:00
Alex Trotsenko
927db42882 tst_QWinEventNotifier: fix flakiness
disableNotifiersInActivatedSlot(disable_signaled2) fails, if a signaled
state of the event #2 is detected prior to the event #1. In this case,
we get a timeout on waiting for event #1 which was disabled by the
first notification.

So, accept a disabled state of the notifier in condition for successful
exit from the loop.

Change-Id: I8a2fe76f8ec9362556d1ca1fe0be39a93ed58977
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2018-03-23 18:09:24 +00:00
Kari Oikarinen
8e93988cce Blacklist tst_QProcess::softExitInSlots on Windows
Task-number: QTBUG-66903
Task-number: QTBUG-66216
Change-Id: I4a36d6f4b980f016e11fd7a8840dbc60a2964e83
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2018-03-23 07:11:04 +00:00
Thiago Macieira
081c001deb QSemaphore: fix deadlock when the woken up thread wakes up another
When the thread that got woken up by release() is supposed to release()
to wake up another thread, we were deadlocking. This happened because we
cleared the bit indicating that there was contention when the first
release(). Instead of storing a single bit, we now store the number of
threads waiting.

Task-number: QTBUG-66875
Change-Id: I72f5230ad59948f784eafffd15193873502ecba4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-03-19 20:36:51 +00:00
Thiago Macieira
2fb706f9a8 QIpAddress: reject IPv6 addresses with more than 4 hex digits
Matches glibc commit 9a0cc8c1bd7645bf3c988890ffb59639c07a5812.

[ChangeLog][QtCore][QUrl] Fixed a bug in parsing IPv6 addresses with
more than 4 hex digits in a component.

[ChangeLog][QtNetwork][QHostAddress] Fixed a bug in parsing IPv6
addresses with more than 4 hex digits in a component.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=9a0cc8c1bd7645bf3c988890ffb59639c07a5812

Change-Id: I2701038131d91eb108aebb3bec16278e4efe3de2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-03-16 00:01:53 +00:00
Edward Welbourne
54190595ef Make sure QDir::absoluteFilePath("/dir") includes a drive on MS
QDir::isAbsolutePath(name) thinks any path starting with a slash is
absolute; however, to return a valid absolute path, we need to put a
drive prefix onto such a name. So use QFileSystemEntry::isAbsolute()
for that check (it believes in the need for a drive, or UNC prefix)
and handle the absolute-but-for-drive case when it arises.

Add a regression test and make related changes to existing tests.

Task-number: QTBUG-50839
Change-Id: Id5d2b2586bb1423fa2d9375a298a4bb5241cffe0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-03-12 18:11:33 +00:00
Eric Lemanissier
1e27219968 add missing tests of rvalue overloads for QVarLengthArray and QVector
they were missing in dd58ddd5d9

Change-Id: I52a2f855ead7716f8fe887524b27d4bd258f43d3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2018-03-10 06:15:31 +00:00
Nils Jeisecke
fee8944cbe Allow use of template class instances inheriting from a Q_GADGET in Qml
The Q_GADGET macro cannot be used in templates. It can however be useful
to derive a template class from a Q_GADGET enabled base class to benefit
from type safety features in C++ (e.g. the class could represent an id
or handle for some C++ type).

For proper wrapping of a QVariant with a gadget value in a QJSValue, the
QMetaType::IsGadget flag must be set for the registered template
instance type - which does not happen prior to the fix because
IsGadgetHelper requires qt_check_for_QGADGET_macro to be defined in the
registered class but not in an ancestor class - in other words: The
class must declare Q_GADGET.

To overcome this, IsGadgetHelper/IsPointerToGadgetHelper can now
differentiate between a Q_GADGET flagged class (allowing
automatic registration) and a derived class, e.g. a template class
(forcing Q_DECLARE_METATYPE to be used explicitly).

[ChangeLog][QtCore][QMetaObject] It is now possible to use template
class instances inheriting from a Q_GADGET in Qml

Task-number: QTBUG-66744
Change-Id: I7632ad45cff79fa422b3f852ca0b963f35fab155
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2018-03-10 06:12:24 +00:00
Albert Astals Cid
78e92997ed QLocale: Update the system private on QLocale default constructor if needed
When first starting an Android app we have invocation order issue, to
load the platform plugin we create the default QLocale (needed by the
resource locator code to see if :/qt/etc/qt.conf exists) so when the
android platform plugin loads and creates its own QSystemLocale, the
QLocale defaultLocalePrivate is already created and pointing to
globalLocaleData which means that systemData won't be called and thus
the code that triggers the call to QLocalePrivate::updateSystemPrivate
won't be called when calling QLocale().

I thought of two ways of fixing this, one was calling
QLocalePrivate::updateSystemPrivatea() from the QAndroidSystemLocale
constructor, but giving the responsibility to not break things to the
plugin seems a little fragile, so making the check on QLocale()
seems better.

Without this patch an Android app doing
  QApplication app(argc, argv);
  qDebug() << QLocale().name();
  qDebug() << QLocale().name();
  qDebug() << QLocale::system().name();
  qDebug() << QLocale().name();
would print
  ""
  ""
  "ca_ES"
  "ca_ES"
now it correctly prints "ca_ES" the four times.

Task-number: QTBUG-41385
Change-Id: I2cf419f59aa008fa3aca11295fe7d42c40bcc32e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-03-02 09:52:14 +00:00
Friedemann Kleint
d8b143d4b7 qstringapisymmetry: Fix XML parsing failing on invalid encodings
Evaluating testlib's XML output in COIN would fail with:
"XML syntax error on line 7520: invalid UTF-8"
for the toLatin1() tests due to some Latin1/UTF8 mixup.

Add a helper function to convert the data to plain ASCII.

Task-number: QTQAINFRA-1797
Change-Id: I1c64878d4c2a67b8c2689905b5ffe6707b5963c1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-03-02 07:59:12 +00:00
Kari Oikarinen
810bc3fb19 tst_QLibrary: Ensure installation order of testdata libs
This test executable was not flaky in the normal sense that when run, it
sometimes passes and sometimes fails. Instead, in some builds it would fail
consistently and in some builds it would pass consistently.

The first test to fail was version(ok00, default to last version) which gives
"mylib" as the library name and -1 as the library version. The description
implies that QLibrary selects the biggest or last used version when given -1.
However, versions less than 0 are not used at all. Instead the loading uses only
the name to select the library. Change the description to match.

So why did the test sometimes pass, sometimes fail? The test uses two library
projects lib and lib2 which install two different major versions of libmylib.
That includes the symbolic links:

  libmylib.so -> libmylib.so.1.0.0*
  libmylib.so.1 -> libmylib.so.1.0.0*
  libmylib.so.1.0 -> libmylib.so.1.0.0*
  libmylib.so.1.0.0*
  libmylib.so -> libmylib.so.2.0.0*
  libmylib.so.2 -> libmylib.so.2.0.0*
  libmylib.so.2.0 -> libmylib.so.2.0.0*
  libmylib.so.2.0.0*

The key thing being that both set the libmylib.so symbolic link. In a
multithreaded installation it's undefined which happens to set the link last.
The test code expected libmylib.so to point to libmylib.so.2.0.0. Ensure that by
building and installing lib2 after lib.

Task-number: QTBUG-66722
Task-number: QTBUG-66216
Change-Id: Ic513c772902273049c28e43fc1d83d550aafcd23
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-03-02 07:20:04 +00:00
Thiago Macieira
4e02c8d5b8 JSON: remove braces from UUID text representations
[ChangeLog][QtCore][QJsonValue] fromVariant() conversion now converts
from QUrl and QUuid using special encoding forms to ensure best JSON
compatibility.

Change-Id: I56b444f9d6274221a3b7fffd150cdc5ca1f87ff1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-03-02 04:06:33 +00:00
Thiago Macieira
a2ffb35ac2 QJsonValue: use the fully-encoded form of a URL in fromVariant()
For compatibility with other parsers that may expect it to be so.

Change-Id: I56b444f9d6274221a3b7fffd150cd66390f98fd5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-03-02 04:06:24 +00:00
David Faure
f2eb7b0204 QMimeDatabase: fix regression in alias resolving
The refactoring to support multiple providers broke alias resolving
(e.g. "text/directory" would be an invalid mimetype, instead of being
resolved to "text/vcard"). The unittest didn't catch it because most of
it was running with a single mime directory (and therefore a single provider,
in the new model). Fixed by re-running a number of test methods once we
have a second mime directory.

Change-Id: Ib5da89ba79c11ed41813b2aff4bc71c30afcde7d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-28 22:17:58 +00:00
Samuli Piippo
bcd5532fcb Fix thread_local test
If _Thread_local is used on a block-scope declaration, it must be
combined with either static or extern to decide linkage.

Change-Id: I228b3520767197c6cdf5134ff5a666ab2aca33ea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-23 13:23:01 +00:00
Thiago Macieira
bf87e1cfbd tst_QMimeDatabase: detect executables as shared libraries too
They can be, if compiled with -Wl,-pie. Example:

 $ file /usr/bin/ping
 /usr/bin/ping: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0

And you can't detect via the interpreter, since libraries can have
them too:

 $ file /lib64/libc-2.26.so libQt5Core.so.5.11.0
 /lib64/libc-2.26.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2
 libQt5Core.so.5.11.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.17.0

Change-Id: I940917d6763842499b18fffd15143bb80ce0e531
Reviewed-by: David Faure <david.faure@kdab.com>
2018-02-21 18:51:34 +00:00