Commit Graph

11713 Commits

Author SHA1 Message Date
Lars Knoll
79e0374143 Remove the SAX parser from QtXml
It has been deprecated and will live in qt5compat from now on.

Fixes: QTBUG-86480
Change-Id: I3744c7cee058d51d0fce633a174ab1a0f9235d2c
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-09-15 08:12:20 +02:00
Edward Welbourne
0aaebc3378 Trim trailing 0s from QTime construction, where neither use nor ornament
The seconds and milliseconds default to 0; so omit them when they're
zero, unless there's nearby code that contrasts nicely with them.

Change-Id: Iea049015e976f5a5209fe87a2cbfdae9de49a559
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-15 02:47:28 +02:00
Mitch Curtis
fb65b32d76 Add qHash implementation for QPoint
[ChangeLog][QtCore][QPoint] Added qHash() implementation.

Change-Id: I65332e7aafab53af40a6e11457b9b457196d584c
Fixes: QTBUG-86457
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-15 02:46:40 +02:00
Allan Sandfeld Jensen
9815ebf24b Switch QSurfaceFormat::colorSpace to a QColorSpace
Allows more flexibility in the future.

Change-Id: Idcf2d8ddaee268a7b5d55379ccb42dd9b3c33abf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-15 01:41:13 +02:00
Mårten Nordheim
2253d5eca6 Schannel: Properly handle request for certificate
Certain servers, like smtp.live.com, will send a request for a
certificate even though they don't require one. In Schannel this
manifests as a warning/info status (SEC_I_INCOMPLETE_CREDENTIALS).
In the cases where it's not needed we should suppress the warning and
try to connect anyway, which is done by calling
InitializeSecurityContext again when we get the status.

Pick-to: 5.15
Change-Id: I3c48140f2949d8557251a49a2b66946da9395736
Reviewed-by: Joshua GPBeta <studiocghibli@gmail.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-09-14 17:14:00 +02:00
Edward Welbourne
533df067e9 Purge Q_{STDLIB,COMPILER}_UNICODE_STRINGS
These were now always defined, hence redundant.
Leave the #define in place so that we can verify we actually do always
define it, in a #else of an existing #if check on it.

Change-Id: Iea4c3dbc8f9982268bcf81da5ef17fe2ebf5c462
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-14 09:47:51 +02:00
Edward Welbourne
e926e68f50 Don't use default-constructed QTime() where QTime(0, 0) is intended
QTime() is invalid. Only the seconds and milliseconds are optional,
for valid times. Use startOfDay() for zoned times, QTime(0, 0) for
fixed-offset ones.

Change-Id: I3b65d5c3733ac83dc3a6c214859c3f56a480bb94
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-14 09:47:50 +02:00
Edward Welbourne
184e385aa2 Remove some unused private methods and replace another
Nothing used defDateTime(), nothing but it used defTime().  The only
other use of defDate() were from one test, which might as well make it
a local variable.

QDateTime's default is invalid, making invalidDateTime() redundant,
and the invalidDate() and invalidTime() it called had no other users.

Change-Id: I0e07ee58478bfe8ba680eafb52e2f73a962edd33
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-14 09:47:50 +02:00
Lars Knoll
2c698a6d07 Fix compiler warnings about missing overrides
Change-Id: I52bf9fe45607f4a99cafa441bd78dfe5f7adb0e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-13 21:03:31 +02:00
Andy Shaw
65afcef217 Interbase: Handle EXECUTE BLOCK statements correctly
Since an EXECUTE BLOCK statement can have a mix of ? and :var syntax
then a special case for this needs to be added so that it does not try
to convert the :var parts into positional placeholders as they need to
kept as-is when preparing such a statement.

Pick-to: 5.15
Fixes: QTBUG-83152
Change-Id: Iff891207ad6dea1681a1b3a335acbbbb668b465d
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-09-13 16:39:06 +02:00
Lars Knoll
557623cc4f Rename QLibraryInfo::location() to path()
As per ### Qt6 comment. Also rename the LibraryLocation enum
to LibraryPath.

Change-Id: I556025a19c5bcdf2ff52598eaba32269522d4128
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-12 23:35:56 +02:00
Lars Knoll
14dece57e9 Remap QMetaType ids to create more space for builtin types
We were starting to run out of space for builtin core types.
Remap the type id's to create lots of additional space.
We now reserve the first 64k id's for Qt, and have 16k id's for
Qt Core. That should hopfully be enough for a while ;-)

Fixes: QTBUG-85914
Change-Id: I0dab6bf23652e46a9557d9b38af7990b68c572b6
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-09-12 23:35:29 +02:00
Tor Arne Vestbø
55687924e3 cmake: Re-enable qcoreapplication and qtimer tests
They were disabled in ad0e3e26fa,
but that was probably accidental.

Change-Id: Ia9cbccfbeecfe84768c3465f5699ed44b7f932a5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-12 15:11:52 +02:00
Ulf Hermann
ef93fdeb09 Provide methods for adding values to a sequential iterable
Provide functionality to add and remove values, so that you can use a
sequential iterable as stack or queue if the underlying container
supports this. To this end, provide a way to specify whether the
value should be added or removed at the beginning or the end of the
iterable.

Change-Id: If63d302f3ca085e56d601116ce4dfaa6b94a0c4f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-09-12 09:12:26 +02:00
Ulf Hermann
73fe229eb4 QMetaContainer: Add an "input" iterator capability
For completeness' sake we should expose this. The iterators provided by
QIterable and friends will check the category at runtime, and should give
sensible feedback.

Change-Id: I778894f340c862f79a18c6c5607bcbba98dd7598
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-12 09:12:18 +02:00
Timur Pocheptsov
605d2163f1 QSsl: workaround a 'very secure' OpenSSL version (CentOS 8.x et al)
CentOS it seems not only backported some OpenSSL 3 functions,
but also raised the default security level to 2, making some of
our keys (and MDs?) 'too weak' and failing auto-tests here and
there as a result. For our auto-test we lower the level to 1,
as it is expected to be.

Fixes: QTBUG-86336
Pick-to: 5.15
Change-Id: I7062a1b292e8b60eb9c2b2e82bd002f09f9da603
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-12 05:36:08 +02:00
Allan Sandfeld Jensen
5bb4baae03 Replace qreal with float in QColor
There is no reason to use double precision for colors. We at most have
16 significant bits anyway.

Change-Id: I8b402cd978675b8ba7248176976d934363212ff1
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-09-11 20:41:15 +02:00
Andreas Buhr
ac7e518a64 [QtCore] Fix QDateTime unit test: time zone of system was used
Test data for QDateTime unit tests was constructed in system's local
time, which made unit test outcome dependent on the time zone of the
system running the tests.
This led to failing unit tests on systems with libc6 version
2.31 or newer. A QDateTime in a timezone, which has daylight saving
time, was created and then used in Hawaii's time zone,which has no
daylight saving time. Newer glibc checks this and returns errors.
This patch changes the behavior to create the test data in a
specified time zone setting.

Task-number: QTBUG-80441
Change-Id: I0330b647fa011be99141dde09001ff2d58bd3a5f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-09-11 19:34:25 +02:00
Lars Knoll
0078391c18 Fix warnings coming from using the deprecated overload of qCheckSum
Change-Id: I719c2d56a690fd245d3917045de4005f118c688b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-11 19:32:34 +02:00
Lars Knoll
7544c242cb Revert "Remove timeStep parameter from QAnimationDrive::advanceAnimation"
This reverts commit f51b690e91.

The commit made all animation tests in qtdeclarative on macOS
flaky.

Change-Id: I4ccaa879df7e2ba7e253657de01cbabc9b2c655f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-11 17:11:02 +02:00
Mårten Nordheim
e0918af700 QAuthenticator: condition using GSSAPI on credentials availability
AFAICT with GSSAPI the normal workflow is to run kinit or similar and
authenticate before running programs relying on it. Therefore
we can try to get the credentials before we choose whether or not
to use Negotiate.

Pick-to: 5.15
Task-number: QTBUG-85123
Change-Id: If0478fdd45389b2939ad87c2f582776fe56959bb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-09-11 13:37:48 +02:00
Ulf Hermann
549b7053a2 Rename QMetaSequence's "elements" to "values"
This is so that they are in line with the "value_type" usually found in
containers. Associative containers have "key_type" and "mapped_type" and
we will use those names for access to elements in QMetaAssociation.
Using "value" as name for sequential containers improves consistency.

Change-Id: I628b7e1446bb2d56843b843bca72d279a6b247e6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-11 11:30:58 +02:00
Mårten Nordheim
5a47939d5c tst_QNetworkReply: Avoid race in ioGetFromHttpWithAuth
Our authentication code is race-y by design:
1. When two requests are fired off and queued at the same time in the
same QHttpNetworkConnection then if one of them encounters
"authentication required" then it will copy whatever credentials it got
to all the other channels in the connection. This is likely what the
first part of the test is testing.
2. If a later request is fired off and it includes credentials in the
url then the newly included credentials should be used instead of the
cached ones.

The race here can occurr when one socket either takes too long to
connect or the connected signal is not received early enough. Then the
first socket is used for both requests and then we can hit case #2 when
the url contains credentials.

Pick-to: 5.15
Change-Id: I646a5378d8c1256b2de98b51912953df29f68cb2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-09-11 11:30:57 +02:00
Andy Shaw
37e7c3c116 Interbase: Add support for the boolean type
This is added to Interbase in v7 and Firebird in v3 which has been
available for sometime now. This means the minimum supported for
Interbase is now v7.

[ChangeLog][QtSQL][Interbase] The minimum required version for Interbase
is now v7.

Fixes: QTBUG-83401
Change-Id: I9927fd962f25c935be8ed5d2b7c76c00fb88cd8c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-09-11 07:32:42 +02:00
Richard Moe Gustavsen
b028fb60e3 macos: Rename macos style to macOS
This change shouldn't matter much to widgets, since style names
there are case insensitive. But for controls style names are
case sensitive, and in that case, "macOS" looks more correct.

Change-Id: Ia1d442bce465692ff58fecba1cc68ecbb2e52549
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-11 06:23:39 +02:00
Andreas Buhr
3a1dad83ed [QtCore] QDateTime: switch from newRow to addRow in unit tests
Instead of doing string formating first and then using QTest::newRow,
we can do both at the same time using QTest::addRow

Change-Id: Ia5c90eb705a806e37b96a1fa174a6557f91bee6d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-09-11 06:12:13 +02:00
Andreas Buhr
1ab2d8f5eb [QtCore] Adapt QDateTime unit tests to use QByteArray
To not have to bother with encodings, a few QStrings are changed
to QByteArrays. This way, a few calls to QString::fromLatin1 and
to QString::toLocal8Bit can be removed

Change-Id: Ia0cf27fc2a86f9842ed0f3ebe47b050bb8a3f4e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-09-11 06:12:04 +02:00
Lars Knoll
6ae7a02104 Remove most compiler warnings about missing overrides
Remove around 1000 compiler warnings about missing overrides
in our auto tests.

This significantly reduce the compiler warning noise in our auto
tests, so that one can actually better see the real problems
inbetween.

Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-11 00:20:47 +02:00
Jarek Kobus
e15153a738 tst_QTimer::remainingTime(): get rid of QTest::currentTestFailed()
Looks this is redundant in fact and unneeded. The check can never be
evaluated to true, since if so, it would mean it had failed in the
previous iteration, in which we already handled the exit from the loop.

Fixed also some comments.

Task-number: QTBUG-83419
Change-Id: I4fe56bfac39cd58b1166967f3ccb80cdff882748
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-10 20:08:12 +02:00
Mårten Nordheim
8a3847aab9 QNAM: Enable HTTP/2 by default
It has been in Qt for some years now and 6.0 marks a good point to
enable it by default. The exception is connectToHostEncrypted where we
still require the users to enable it explicitly since there's no logical
way to disable it.

[ChangeLog][QtNetwork][QNetworkAccessManager] HTTP/2 is now enabled by
default.

Fixes: QTBUG-85902
Change-Id: Ia029a045727cc593d77df9eb3a5888522ad19199
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-09-10 18:28:43 +02:00
Joerg Bornemann
b5234817f1 Introduce QProcess::startCommand(QString, OpenMode)
The removal of the QProcess::start(QString, OpenMode) leads to more
porting work than anticipated. A call like

    QProcess p;
    p.start(cmdline);

must be transformed in the following cumbersome way:

    QProcess p;
    QStringList args = QProcess::splitCommand(cmdline);
    QString program = args.takeFirst();
    p.start(program, args);

This patch revives QProcess::start(QString, OpenMode) and renames it to
QProcess::startCommand. This is still source-incompatible, but the
transformation is much simpler:

    QProcess p;
    p.startCommand(cmdline);

[ChangeLog][QtCore][QProcess] Added QProcess::startCommand(QString,
OpenMode) as replacement for the removed QProcess::start(QString,
OpenMode).

Change-Id: I5499bbb39a025e115042c43a4cc63affddae585c
Reviewed-by: hjk <hjk@qt.io>
2020-09-10 18:05:28 +02:00
Timur Pocheptsov
4f658d04da Fix a rather sloppy test case in tst_QSslKey
It's not guaranteed that all curves we want to use are supported
by a specific build of OpenSSL library we have to link with. Filter
out files that contain EC, which is not among the curves, reported
by QSslConfiguration::supportedEllipticCurves.

Fixes: QTBUG-46203
Pick-to: 5.15
Change-Id: I70d7e6fcacb3d81f8c771e4a8d6cca06295e7474
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-09-10 17:32:09 +02:00
Andrei Golubev
ec7e680c50 Remove '\0' space reservation logic in QString
Changed QString to use implicit element reserved by QArrayData

Task-number: QTBUG-84320
Change-Id: If517500b3f0e71bb8d2989c64815a634aa8dd554
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-10 17:31:23 +02:00
Volker Hilsheimer
8186bd628f Remove obsolete APIs and comments from QAbstractPrintDialog
Merging QAbstractPrintDialog with QPrintDialog, as proposed in the
removed comment, seems to have little value, given that the platform
specific implementations rely on the current abstraction.

Adjust examples and tests; with the QAbstractPrintDialog test now
testing the QPrintDialog::options API, the corresponding test function
can be removed from the QPrinter test.

Change-Id: Ia8906627898332e8590ea9b27e3d71dfcc6e8d71
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-10 17:29:52 +02:00
Andreas Buhr
1b02cfd38d Adapt QDate unit tests to not take into account system locale
QDate was changed to consistently use the C local in
serialization and parsing in git commit
5ba66c5622.
This commit reflects this change in the unit tests.

Task-number: QTBUG-80441
Change-Id: Ib21a215ef0e36c9eaa2c161b92c6877a50ae6f06
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-09-10 17:29:38 +02:00
Morten Johan Sørvig
b3c991ae8f Port from devicePixelRatioF() to devicePixelRatio()
This ports all of QtBase.

Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-10 17:28:11 +02:00
Andrei Golubev
7a15d71def Fix possible corner cases in qarraydataops.h
Updated moveNonPod function to behave correctly under
exceptions being thrown. This is the version that was implemented
at some point but then got changed prior to merge. Added tests for
moveInGrowthDirection (which uses moveNonPod in general case) to
verify that range movements are correctly done

Updated QCommonArrayOps access modifier from private to protected
to allow testing of internal stuff by subclassing

Task-number: QTBUG-84320
Change-Id: Idb994a72ee601762e32248670cdc7819aaca0088
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-10 14:21:47 +02:00
Andrei Golubev
6e8985e357 Make Q*ArrayOps erase aligned with std::vector::erase
Scoped GrowsBackwards-optimized erase to only be applied
when erase starts at the beginning of the element range.
In other cases, old "left-shifting" erase is used to align
with std::vector::erase invalidation policy

Task-number: QTBUG-84320
Change-Id: I2e7f3b96b056bc371119eb2d36cc7c74af52c394
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-10 11:24:19 +02:00
Allan Sandfeld Jensen
030962b01c Cleanup QAction::visible property
Gives it its own changed signal, and simplifies setting from group,
while fixing an inconsistency in propagation.

Change-Id: I22b243210260a8878144fa4b60204df46f847f37
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-10 09:24:18 +00:00
Shawn Rutledge
ae7442a4e9 Give QEventPoint a d-pointer after all
I still have doubts that QEventPoint can't be made small enough that
copying would be cheaper than reference-counting and all the indirections
in now-noninline accessors, but this gives us the usual freedom to
change the data members later on.

Change-Id: I792f7fc85ac3a9538589da9d7618b647edf0e70c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-10 03:15:49 +02:00
Jarek Kobus
db3d5a3097 Fix flaky QTimer::remainingTime() test
Before, we used not so accurate QTest::qWait(50)
to measure the accuracy of more precise timer's interval.
In addition, the checked range for remainingTime (50, 200)
was probably wrong, since by definition it couldn't be more than 150,
as we started the timer with interval of 200 and waited at least 50.

In this fix we have additional "tester" timer to measure remainingTime
of "tested" timer. The "tester" is a singleShot timer with interval of
50, and is started together with "tested" timer. Whenever the "tested"
timer timeouts, it restarts the "tester" timer - this is done desired
number of times (2 by default, like in the original test).

The test itself lies now inside tester's lambda. We fix the tested
range (at least 1, no more than 150). The minimum value could in
theory be greater, but it's enough to test that it's not overdue.

Finally, we wait for expected number of test runs. We give it twice
as much time as is in theory needed.

Task-number: QTBUG-83419
Task-number: QTBUG-58519
Change-Id: I43836d787d804f22bb66515ebb215d040189c4f3
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-09-10 02:49:59 +02:00
Ulf Hermann
7a2f129748 Blacklist tst_qcolumnview::scrollTo on macOS
It flaky fails for both normal and reverse cases.

Pick-to: 5.15
Task-number: QTBUG-41341
Change-Id: If6ecd6dc58f131bb67d46a5d508f59b6bb0fd962
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-09 18:52:11 +02:00
Thiago Macieira
7e93870401 QProcess/Unix: introduce setChildProcessModifier()
[ChangeLog][Source-Incompatible Changes] QProcess::setupChildProcess()
was removed. To execute code in a child process, use
QProcess::setChildProcessModifier()

[ChangeLog][QtCore][QProcess] Added setChildProcessModifier() function
with which one can provide code to be run in the Unix child process
between fork() and execve(). With this function, it is no longer
necessary to derive from QProcess in order to execute actions in the
child process.

Another reason is that we can tell whether the std::function carries a
valid target much more easily than we can tell whether QProcess was
overridden.

The setupChildProcess() virtual function does not need to be marked
final, since no overrider could ever return an inaccessible private
class. This also makes sure the error presented to the user is about the
return type, not about attempting to override a final.

Clang:
 error: virtual function 'f' has a different return type ('void') than the function it overrides (which has return type 'QProcess::Use_setChildProcessModifier_Instead')

GCC:
 error: conflicting return type specified for 'virtual void MyProcess::setupChildProcess()'
 note: overridden function is 'virtual QProcess::Use_setChildProcessModifier_Instead QProcess::setupChildProcess()'

ICC:
 error: return type is neither identical to nor covariant with return type "QProcess::Use_setChildProcessModifier_Instead" of overridden virtual function "QProcess::setupChildProcess"

MSVC is not relevant since it doesn't compile to Unix.

Change-Id: Ia8b65350cd5d49debca9fffd15f801161363aea7
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-09-08 21:00:29 -07:00
Marcel Krems
348b86d976 Fix failures in tst_qdatetime under non-english locales
QDateTime::toString uses the C locale since 5ba66c5622
So don't expect locale specific day- and month-names.

Task-number: QTBUG-80441
Change-Id: I08f53b6b33ed9e7eaaa58df4ca6a966c4ba9ef24
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-09-09 06:00:28 +02:00
Allan Sandfeld Jensen
d263ab6af5 Create consistent sets of QImage methods
Adds consistently named inplace and imperative methods.

Change-Id: I8739c1c4585d2ba4aa181bb9a681255d76c120d7
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-09 00:14:49 +01:00
Shawn Rutledge
0e475eeea6 Refactor testlib touch functions into qtestsupport_gui and _widgets
Because we removed public setters from QTouchEvent and QEventPoint in
4e400369c0 and now it's proposed to give
QEventPoint a d-pointer again, the implementation of QTouchEventSequence
needs to start using QMutableEventPoint: being a friend will no longer
be enough, because the member variables won't be accessible in the future.
But because we have separate test libs for Gui and Widgets, it needs to
be further refactored into two classes.

Change-Id: I0bfc0978fc4187348ac872e1330d95259d557b69
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-08 08:02:15 +02:00
Andy Shaw
13fe0ab5de Interbase: Correctly read/write arrays to the database
The fix ensures that it can find the column for the array correctly
when reading/writing and also handles the integer typed arrays correctly
too.

Pick-to: 5.15
Fixes: QTBUG-83409
Change-Id: I92d982bdf0927e6ebc6dce84fec9ad6c44c26c25
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-09-08 08:02:14 +02:00
Giuseppe D'Angelo
cf482d702b tst_qmenubar: stop doing math on an enum
Cast to the right datatypes.

Change-Id: Ia1ba9be1b0530263e810b50408f432dca485744c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-07 15:50:02 +02:00
Giuseppe D'Angelo
fec51be209 tst_qshortcut (x2): use op | instead of op + to combine keys
Following the introduction of QKeyCombination, reduce the number
of warnings raised by the test. Drive-by, remove some pointless
math like Qt::SHIFT+0, which does not make any sense and would
actually fail to compile (shortly).

Refactoring the test to fully use QKeyCombination (instead of
ints) is left as a future exercise; some QKeyCombination->int
warnings are still around.

Change-Id: If825bc4c369986623447927bb11493c4f58b544f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-07 15:50:02 +02:00
Tor Arne Vestbø
89f7a2759c Deliver Quit event when calling QCoreApplication::quit()
Instead of QCoreApplication::quit() directly calling exit(0), which would
leave QGuiApplication and client code out of the loop, we now send the
Quit event, and let it pass through event delivery, before finally ending
up in QCoreApplication::event(), where we call exit(0).

This has the advantage that QGuiApplication can ensure all windows are
closed before quitting, and if any of those windows ignore the close
event the quit will be aborted. This aligns the behavior of synthetic
quits via QCoreApplication::quit() with spontaneous quits from the
platform via QGuiApplicationPrivate::processApplicationTermination.

Clients who wish to exit the application without any event delivery or
potential user interaction can call the lower level exit() function
directly.

[ChangeLog][QtGui] Application termination via qApp->quit() will now
deliver Quit events to the application, which in turn will result in
application windows being closed as part of the application quit,
with an option to cancel the application quit by ignoring the close
event. Clients who explicitly want to exit the application without
any user interaction should call QCoreApplication::exit() explicitly.

Task-number: QTBUG-45262
Task-number: QTBUG-33235
Task-number: QTBUG-72013
Task-number: QTBUG-59782
Change-Id: Id4b3907e329b9ecfd936fe9a5f8a70cb66b76bb7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-07 14:41:16 +02:00
Lars Knoll
0ae5b8af9c Clean up QTextBoundaryFinder and qunicodetools
Make QTBF ready for Qt6 by using qsizetype in the API and use
QStringView where it makes sense.

Change the exported API of qunicodetools to use QStringView as
well and use char16_t internally.

Change-Id: I853537bcabf40546a8e60fdf2ee7d751bc371761
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-07 09:09:55 +02:00
Marcel Krems
c93b91c766 Remove deprecated method QQuaternion::conjugate
Change-Id: If539e47618357ef329925033842f266447632e6f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-07 04:36:16 +02:00
Christian Ehrlicher
4e2656a6d2 QStyleOptionGraphicsItem: remove deprecated member matrix/levelOfDetail
QStyleOptionGraphicsItem::matrix and levelOfDetail are deprecated and
not used anywhere anymore.

Change-Id: Id4b0fa8ac3ac53d771e858ecda5524a5e690342d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-06 18:31:43 +02:00
Allan Sandfeld Jensen
68198de4db Use C++17 [[maybe_unused]]
In some places needs to be ordered before const/constexpr though.

Change-Id: I57a521ac0ad22b5a018761c4d52befbef69d64c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-06 18:31:43 +02:00
Allan Sandfeld Jensen
d3ff95dcb8 Round float->qfloat16 to even
Calibrated to match F16C and ARM-FP16 hardware conversions.

Change-Id: I3bdd4d3db3046fee4aeb24e4ce8b9bc9a06e0397
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-06 12:35:12 +02:00
Lars Knoll
75d1d2a913 Get rid of hasPendingEvents() and flush()
They are unused.

Change-Id: I77383f2be45551401ed9c2f88285511134cc8b0d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-06 00:17:12 +02:00
Giuseppe D'Angelo
2ab91dd68e tst_qdbuscpp2xml: stop doing math on enumerations
Cast it to int to do math.

Change-Id: Ia553cccb7e160df50e77fba63d66d0ed45c246c2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-05 17:12:50 +02:00
Lars Knoll
bbc19bd979 Make test pass on machines with many cores
Just starting 20 threads to test this won't cut it if
the machine you're testing on has an ideal thread count
of 16 or larger.

Change-Id: Icba8f00aa836fec6da41c71b318e9e17bdd47c0e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-05 02:08:49 +02:00
Volker Hilsheimer
0f39cfae93 Change QWidget::enterEvent signature to take a QEnterEvent
This is a source incompatible change for widget implementors.
Leaving the old enterEvent as a virtual overload is problematic due to
shadowing. Best to make a clean cut, widget reimplementors will get a compile
time warning if they mark their override as such, or if they try to call the
parent class implementation.

Addresses ### Qt 6 comment.

[ChangeLog][QtWidgets][QWidget] The virtual enterEvent handler now receives
a QEnterEvent, which contains information about mouse position and button
states, rather than a plain QEvent.

Change-Id: I233f594fd79c0c090983b3db8532913d00132fde
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-05 02:06:26 +02:00
Liang Qi
c91d1fdc10 xcb: drop Xinerama support
[ChangeLog][Important Behavior Changes][X11] Xinerama is no longer
supported.

Fixes: QTBUG-86082
Change-Id: Ieb57d9035e1659fc22bf8333247fc3573fb62992
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2020-09-04 17:28:49 +00:00
Volker Hilsheimer
00a5629d8d Remove deprecated QPrinter and QPagedPaintDevice APIs
Adjusting the QPrinter test case - some use cases no longer exist, or are
already tested in QPageSize and QPageLayout tests.

Adjust examples and manual tests.

Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-04 08:37:59 +02:00
Jarek Kobus
225cc60954 Fix flaky QFutureWatcher::startFinish() test
Since waiting for a spy employs polling, it may happen
that while waiting for a startedSpy we had received already
a signal for finishedSpy. This explains current flakiness.

The fix is to connect to lambdas instead and update
the hit count accordingly. Inside lambdas we also
ensure the correct order for started / finised signals.

After waitForFinished() unblocks we ensure that possible
pending asynchronous signals (started / finished) are processed
and check the final state.

Task-number: QTBUG-83076
Change-Id: I16963ef9c011cb613d7b409d3e3032303a942336
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-03 20:45:00 +02:00
Volker Hilsheimer
f51b690e91 Remove timeStep parameter from QAnimationDrive::advanceAnimation
Addresses ### Qt 6 comment, and documentation pointing out that the parameter
value is ignored. It wasn't ignored in the code, but that's the kind of change
we can make now.

With this change, QUnifiedTimer::updateAnimationTimers is only called with -1
as the currentTick input parameter, also from Qt Declarative. Make it default,
so that leaf modules can be fixed. Once that it done, the parameter can be
removed completely.

Change-Id: I80c57ff92f3b615b932dd73d711cf6397347efd8
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-09-03 18:43:22 +02:00
Tor Arne Vestbø
f4c58b79a7 Extend test blacklisting from Ubuntu 18.04 to 20.04
Task-number: QTBUG-86187
Change-Id: I3ac3233f7355d1c16bc9bf6e052fdf4bd9ea90de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-03 14:30:04 +02:00
Ulf Hermann
53fde3c573 Reimplement QSequentialIterable using QMetaSequence
Change-Id: Ie721a5f0caa697c4bf15a81f3762cf79d3c54f5a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-03 08:27:44 +02:00
Eskil Abrahamsen Blomfeldt
0e0149c64d Ignore weight in .ui files instead of converting it
In 3558704ed5, we added code to
support old .ui files which used the old integer scale for font
weights by checking for a special attribute which would help
separate new and old files.

Since then, it has become apparent that the weight element in
.ui is not actually used for anything, since it is only emitted
when the bold flag is set and always has to match QFont::Bold
in these cases.

So instead of converting, we simply ignore it now, and respect
the bold flag instead.

This also reverts the changes to ui4.* in uic, since the
scale attribute is no longer needed.

Task-number: QTBUG-42248
Change-Id: I1898868b58004099590f4eaf01f24c57bd34d779
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-03 07:31:45 +02:00
Giuseppe D'Angelo
25351dcc54 Long live QKeyCombination!
C++20 via P1120 is deprecating arithmetic operations between
unrelated enumeration types, and GCC 10 is already complaining.
Hence, these operations might become illegal in C++23 or C++26 at
the latest.

A case of this that affects Qt is in key combinations: a
QKeySequence can be constructed by summing / ORing modifiers and a
key, for instance:

  Qt::CTRL + Qt::Key_A
  Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below)

The problem is that the modifiers and the key belong to different
enumerations (and there's 2 enumerations for the modifier, and one
for the key).

To solve this: add a dedicated class to represent a combination of
keys, and operators between those enumerations to build instances
of this class.

I would've simply defined operator|, but again docs and pre-existing
code use operator+ as well, so added both to at least tackle simple
cases (modifier + key).

Multiple modifiers create a problem: operator+ between them yields
int, not the corresponding flags type (because operator+ is not
overloaded for this use case):

  Qt::CTRL + Qt::SHIFT + Qt::Key_A
  \__________________/      /
          int              /
           \______________/
                  int

Not only this loses track of the datatypes involved, but it would
also then "add" the key (with NO warnings, now its int + enum, so
it's not mixing enums!) and yielding int again.

I don't want to special-case this; the point of the class is
that int is the wrong datatype. Everything works just fine when
using operator| instead:

  Qt::CTRL | Qt::SHIFT | Qt::Key_A
  \__________________/      /
      Qt::Modifiers        /
           \______________/
            QKeyCombination

So I'm defining operator+ so that the simple cases still work,
but also deprecating it.

Port some code around Qt to the new class. In certain cases,
it's a huge win for clarity. In some others, I've just added
the necessary casts to make it still compile without warnings,
without attempting refactorings.

[ChangeLog][QtCore][QKeyCombination] New class to represent
a combination of a key and zero or more modifiers, to be used
when defining shortcuts or similar.

[ChangeLog][Potentially Source-Incompatible Changes] A keyboard
modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be
combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using
operator|, not operator+.  The result is now an object of type
QKeyCombination, that stores the key and the modifiers.

Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-03 07:00:31 +02:00
Joerg Bornemann
067fb7915a pro2cmake: Fix qmake parser's line continuation handling
The qmake parser of pro2cmake handles completely commented lines to make
assignments like this work:

    SUBDIRS = \
       foo \
    #  bar \
       bar

However, assignments like

    SUBDIRS = \
       foo \
       #bar \
       bar

were cut off at the commented line.

Fix this by allowing leading whitespace for "fully commented lines".

Change-Id: Ib5de850a02fd9b9ebb7c056c2f64f9d684334b08
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-02 23:44:15 +02:00
Mårten Nordheim
b98b7de0da QByteArray: Disregard space at front during ::reserve(...)
Traditionally when calling reserve it's because you expect to append
up to X amount of bytes. We should keep that behavior the same.

With another patch still in the works current behavior caused an issue
with QStringBuilder in QNAM, as mirrored in the testcase attached.

Change-Id: I9792a8f158fc9235e3de48ac8b06ac2c10e7f3dc
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-02 23:10:21 +02:00
Giuseppe D'Angelo
39e07ebf64 Long live QAIM::multiData!
Views / delegates absolutely *adore* hammering data(). A simple
QListView showing a couple of dozens entries can call data()
a hundred of times on the first show.

Back of the hand calculation,

* 2 times per visible item (sizeHint() + paint()),
* times 9 roles used by the default delegate,
* times 20 visible items

= 360 as a bare minimum, assuming the view doesn't redraw twice
accidentally. Move the mouse over the view, and that'll cause
a full update with certain styles: 360 calls to data() per update.

This has an overhead visible in profilers. The model's data()
has to re-fetch the index from its data structure and extract
the requested field every time.

Also, QVariant is used for the data interexchange,
meaning anything that won't fit in one is also a memory allocation.
This problem will likely be gone in Qt6Variant as that
will store sizeof(void*) * 3, meaning QImage/QPixmap and similar
polymorphic classes will fit in a QVariant now...

So I'm trying to to remove part of that overhead by allowing
views to request all the data they need in one go. For now,
one index a a time.

A view might also store the data returned. The idea is that
the same role on different indexes will _very likely_
return variants of the same type. So a model could move-assign
the data into the variant, avoiding the memory allocation
/deallocation for the variant's private.

This patch:

1) Introduces QModelRoleData as a holder for role+data.

2) Introduces QModelRoleDataSpan as a span over QModelRoleData.
The idea of a span type is twofold. First and foremost, we are
in no position to choose which kind of container a view should
use to store the QModelRoleData objects for a multiData() call;
a span abstracts any contiguous sequence, leaving the view free
to do whatever it wants (statically allocate, use a vector, etc.).
It also solves the problem of efficient passing the roles and
gathering the returned variants from multiData().

3) Add multiData(), which populates a span of roles for a given
model index. The main advantage here is that a model can fetch
all the needed information for a given index just once, then
iterate on the span and provide data for each requested role.
Cf. this with data(), where every call has to re-fetch
the information for the index.

A couple of models have been ported to multiData(), as well as
QStyledItemDelegate.

[ChangeLog][QtCore][QModelRoleData] New class.

[ChangeLog][QtCore][QModelRoleDataSpan] New class.

[ChangeLog][QtCore][QAbstractItemModel] Added the multiData()
function.

Change-Id: Icce0d108ad4e156c9fb05c83ce6df5f58f99f118
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:51:42 +02:00
Fabian Kosmale
19874d6a63 QVariant: Fix conversion code
Fixes: QTBUG-86330
Change-Id: Ib89dcf1195e0081b4c4e2845f90c52c612e5911a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:50:50 +02:00
Christian Ehrlicher
3ddffd2d8b QTable/TreeView: fix sortByColumn() when view is already sorted
When the view was already sorted by the column and order given to
sortByColumn(), a resort was not triggered which is a regression since
d0f909f8db.
Therefore don't rely on sortIndicatorChanged() in this case and trigger
an explicit sort as it's done when no user-triggered sorting is enabled

Fixes: QTBUG-86268
Change-Id: I3ec30ab81f304d5a19cef6d67b8a81c21b4a112d
Pick-to: 5.15
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-09-02 22:44:30 +02:00
Lars Knoll
927647cd03 Fix QPropertyAlias to work with all kinds of properties
So far QPropertyAlias was limited to working with QProperty<T>.
Change the implementation, so it can be constructed from any
property or even a QBindable<T>.

Change-Id: I175cffe94a9ef332367d39faa976eb065b0e6ffe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:29 +02:00
Lars Knoll
ad32ac5b4f Make bindings introspectable through moc
Add a new BINDABLE declaration to the Q_PROPERTY() macro that tells moc
where to find the QBindable for the property.

Add a QUntypedBindable base class to QBindable<T> that gives access to
generic functionality and checks argument compatibility at runtime.
QBindable<T> will still do static checking at compile time.

Add QMetaProperty::isBindable() and QMetaProperty::bindable()
to be able to dynamically access the binding functionality.

Change-Id: Ic7b08ae2cde83fd43e627d813a886e1de01fa3dc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:29 +02:00
Lars Knoll
5b81c80b46 Add QObjectCompatProperty
Add a compatibility property class that makes porting to the new
property system as simple as possible.

Binding evaluation for those compat properties is eager, as we
do not control possible side effects of the code in the existing
setters.

Change-Id: Ic56347abb49e40631ec73e88c6d40d4bdb05ca29
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:29 +02:00
Lars Knoll
918c61f275 Add support for computed properties
Add a QObjectComputedProperty. This class doesn't store the data
itself, instead relies on a getter method to compute it's value.
As the property is read-only, one can not bind to it, but it can
be used in other property bindings.

Change-Id: I0f6bffdd9f80f1d0829826f93a47257f2b3127af
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:29 +02:00
Lars Knoll
3b3b190eef Add support for bindable properties to QObject
Add Q_OBJECT_BINDABLE_PROPERTY() macro that can be used to define
a bindable property inside QObject.

The macro and the class behind it creates storage for a property
that is bindable inside a QObject or QObjectPrivate. The property
only uses as much space as the data contained, ie. it has no
storage overhead, as long as no bindings are being used.

Bindings are being stored and looked up in the QBindingStorage
associated with the owning object.

Change-Id: I1dadd7bddbad6fbf10cfa791d6461574b9db82dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-02 22:44:28 +02:00
Lars Knoll
6778b247a8 Add a QBindingStorage class
QBindingStorage is a class that can store a set of binding objects
for the properties of a QObject. This will get used to reduce the
memory overhead of the property system when adding bindable properties
to QObject based classes.

The binding storage has a pointer to the TLS entry containing the
currently evaluating binding. Like that we avoid repeated TLS
lookups and reduce the overhead of the property system to one
pointer lookup and one compare for the case that properties
aren't being used.

Each QObject now owns one binding storage object, that can be used to
store binding data for properties that members of the QObject.

Change-Id: I27427c03c2ba281f072e074be96147bdbcaac246
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:28 +02:00
Lars Knoll
9b6df7deb3 Ground work for bindable properties in QObject
Add a private QBindableInterface and a public QBindable<T>
class, that will be the API interface for accessing bindings
for properties in QObject.

The QBindable class gives access to all aspects of
the property related to bindings. This includes setting
and retrieving bindings, installing observers and creating
a direct binding on this property.

Change-Id: Iaead54d2bd6947bd2cda5052142b2a47dd8bf7c4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:28 +02:00
Lars Knoll
638df6138e Remove operators allowing assignment of a binding to a property
These look rather weird, an explicit property.setBinding() call
is simply better in this case, and also more aligned with the API
we can offer in QObject.

Change-Id: Ifb00fd47a75e6b3bc94e34bf49e4f13249565bfe
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:28 +02:00
Lars Knoll
e6988d4d0b Remove QNotifiedProperty and Q_PRIVATE_QPROPERTY
And all related functionality. This is being replaced by
Q_BINDABLE_PROPERTY and Q_OBJECT_BINDABLE_PROPERTY in the
next few commits. The new infrastructure coming will play
nicer along with the existing property system.

Commented out some autotests, that will get reimplemented
with the updated infrastructure.

Change-Id: I50c30bd4d5c6c6b6471f8eb93870e27d86f5a009
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:27 +02:00
Lars Knoll
e638e8a28d Cleanups: Rename some classes
Rename QPropertyBase to QPropertyBindingData, as it contains the
data related to bindings. The new name fits better, as the data
can now also live somewhere else than the data strored in the
property.

Change-Id: I489efb86ad2e0bad2740c9d1aa74506fe103d343
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:27 +02:00
Lars Knoll
331c106bdb Remove the special handling of QProperty<bool>
Since we will be storing property data differently in most cases,
having this special case would create too many additional complications.

Change-Id: I27042b0730559bb375d8e3c07324398403a9885d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-02 22:44:27 +02:00
Fabian Kosmale
733d890430 Add operator-> and operator*() to QProperty
Enable the arrow operator for all types that could have members, so
that one can e.g. write myStringProperty->size() instead of having to
use the less convenient myStringProperty.value().size().

Also cleaned up the rvalue ref overloads to be
disabled for basic types. For those we now also
return by value, for more complex types we
return a const reference.

Change-Id: If6a75898dc0a097f57052488f0af0cd7166b3393
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-02 22:44:27 +02:00
Giuseppe D'Angelo
11b8c46d2a QObject: add a single shot connection flag
If one needed to listen to a signal just once, one had to
store the QMetaObject::Connection object returned by connect()
and use it to disconnect the slot after the first signal
activation.

This has led to a proliferation of using wrappers (and enough
TMP); they usually look like this:

1) create a shared_ptr<QMO::Connection>, allocating its payload;
2) create a lambda, capturing the shared_ptr by value;
3) in the lambda, disconnect the connection (through the shared_ptr),
   and call the actual slot;
4) connect the signal to the lambda, storing the returned
   QMO::Connection into the shared_ptr.

This is expensive, error prone for newcomers, and tricky to
support as a general facility inside one's projects.
We can do better, just support single shot connections right
in QObject.

[ChangeLog][QtCore][QObject] Added the Qt::SingleShotConnection
flag. When a connection is established with this flag set,
the slot is going to be activated at most once; when the signal
is emitted, the connection gets automatically broken by Qt.

Change-Id: I5f5feeae7f76c9c3d6323d841efba81c8f98ce7e
Fixes: QTBUG-44219
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-09-01 17:59:36 +02:00
Andreas Hartmetz
7406949858 Doc fix: disconnect with receiver also works for context objects
One could guess it by assuming that disconnecting for a destroyed
receiver and disconnect() with given receiver use the same
implementation, but without closely knowing the implementation a
reader of the documentation can't know for sure.

Also add a test to prove that what the new documentation says is
really true.

Also remove an unnecessary negation in the preceding sentence.

Change-Id: I9d24442bb1a4646b89f969bad1a4d0e1eafa7534
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 13:35:39 +02:00
Ulf Hermann
4fbb2f66d6 Add a QMetaSequence interface
This is in line with QMetaType and will be used to implement a mutable
QSequentialIterable. Later on, a QMetaAssociation will be added as
well, to implement a mutable QAssociativeIterable.

The code here represents the minimal set of functionality needed to have
a practical sequential container. The functionality is not completely
orthogonal. In particular, the index based operations could be
implemented in terms of iterator-based operations.

Task-number: QTBUG-81716
Change-Id: Ibd41eb7db248a774673c701549d9a03cbf2e48b6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 13:35:39 +02:00
Giuseppe D'Angelo
c1454d07cf Take the right lock before using a connection's receiver
When a signal/slot connection is activated, a lock on the receiver
object is taken (to be sure it doesn't get destroyed).
The path for blocking queued connections however took the lock on
the sender by accident, fix that.

Pick-to: 5.15 5.12
Change-Id: I8cd938a50eca2bf71e7bfb86768ee0c8431afdfa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 02:48:40 +02:00
Marc Mutz
2c9529e158 Long live Q{Any,Utf8}StringView!
We need to add these two classes at the same time, because
QAnyStringView makes all QUtf8StringView relational operators moot. We
might want to add some later, esp. for UTF-8/UTf-8 comparisons, to
avoid the pessimization that we can't early-out on size() mismatch in
QAnyStringView equality operators, but that's an optimization, not a
correctness issue, and can be fixed in a source-compatible way even
after Qt 6 is released.

To deal with the char8_t problem in C++20, make QUtf8StringView a
class template out of which two UTF-8 views can be instantiated: the
Qt 7 version, which depends on C++20 char8_t as value_type, and the Qt
6 version where value_type is a char. Use inline namespaces to map the
QUtf8StringView identifier to one or the other, depending on the C++
version used to compile the user code. The inline namespace names must
needs be a bit ugly, as their inline'ness depends on __cpp_char8_t. If
we simply used q_v1/q_v2 we'd be blocking these names for Qt inline
namespaces forever, because it's likely that inline'ness of other
users of inline namespaces in Qt depends on things other than
__cpp_char8_t. While inline'ness of namespaces is, theoretically
speaking, a compile-time-only property, at least Clang warns about
mixed use of inline on a given namespace, so we need to bite the
bullet here. This is also the reason for the QT_BEGIN_..._NAMESPACE
macros: GCC is ok with the first declaration making a namespace
inline, while Clang warns upon re-opening an inline namespace as a
non-inline one.

[ChangeLog][QtCore][QUtf8StringView] New class.

[ChangeLog][QtCore][QAnyStringView] New class.

Change-Id: Ia7179760fca0e0b67d52f5accb0a62e389b17913
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-31 22:57:49 +02:00
Peng Wenhao
f0ae973244 Qpagedpaintdevice: Use marginsF instead of internal struct margins
resolve remaining Qt6 TODOs

Change-Id: Iad659a09ddfe136bdc545bc0635b4c695540c58b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-01 04:57:48 +08:00
Tor Arne Vestbø
90358f6042 Deprecate and remove uses of AA_DisableHighDpiScaling
Change-Id: Ibadce68775858c524b998aacad310905ba2c2e8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-31 19:14:55 +02:00
Tor Arne Vestbø
2dc46c0902 Deprecate and remove all uses of AA_UseHighDpiPixmaps
High-DPI pixmaps are always enabled, and cannot be disabled.

Change-Id: I01a006b404e5431582b64ef812974c1c022b39ae
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-31 14:29:01 +02:00
Edward Welbourne
e40320c552 QWeakPointer: purge deprecated API
Since 5.0: assignment/construction from QObject pointer
Since 5.14: data() to recover the packaged pointer

Change-Id: I5d6ab561ce39bc0d9d3e5035eb2ca38139cd76b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-31 10:32:39 +02:00
Laszlo Agocs
9390edb119 rhi: Work around qsizetype fallout in manual tests
Change-Id: I9f0e210caacc6eefe5ed1ee6fa97574ad5e9edcc
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-08-30 17:45:01 +02:00
Edward Welbourne
78cf89c07d Use checked string iteration in case conversions
The Unicode table code can only be safely called on valid code-points.
So code that calls it must only pass it valid Unicode data. The string
iterator's Unchecked Unchecked methods only provide this guarantee
when the string being iterated is guaranteed to be valid UTF-16; while
client code should only use QString, QStringView and friends on valid
UTF-16 data, we have no way to be sure they have respected that.

So take the few extra cycles to actually check validity in the course
of iterating strings, when the resulting code-points are to be passed
to the Unicode table look-ups. Add tests that case mapping doesn't
access Unicode tables out of range (it'll trigger the new assertion).
Added some comments to qchar.h that helped me understand surrogates.

Change-Id: Iec2c3106bf1a875bdaa1d622f6cf94d7007e281e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-29 18:15:27 +02:00
Marcel Krems
ab5e444c8f Remove remaining traces of deprecated QtMsgHandler
Change-Id: I28aecb444eb9bc9e26e6ff8998904dbf28419f25
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-29 16:24:21 +02:00
Andrei Golubev
a2b1b0292d Prepend optimize QString
Added prepend optimization to QString

Task-number: QTBUG-84320
Change-Id: Iaa8df790a10c56ecceb06f7143718fb94874ce76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-29 14:20:06 +02:00
Morten Johan Sørvig
319462559f Port tst_qiconhighdpi to the new QIcon::pixmap() API
Port the high-dpi icon test to use the new pixmap()
API which takes the target devicePixelRatio as an argument.

This means we can run the fromTheme test at dpr = {1,2,3},
instead of at the current global devicePixelRatio only.

Task-number: QTBUG-85885
Change-Id: Iec7b21e04ed760e48964307d2048eaec1976ffe2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-29 10:02:47 +02:00
Tor Arne Vestbø
9d2b43de19 Use build-system to declare tests that are low-DPI
Change-Id: I6da7204683b3c46232cfc542ed5e28131a82e87d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-28 22:16:53 +02:00
Edward Welbourne
86ebe46f59 Make QTranslator::load() insist that its return value be checked
Add Q_REQUIRED_RESULT to force callers to check the return; the
QTranslator object is unusable if load() fails.
Check the result in QTranslator's own test.

Task-number: QTBUG-85700
Change-Id: I07509c76470cc87626190670665cd3162bfb17e7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-28 21:26:21 +02:00
Edward Welbourne
26547c296b Purge qalgorithm.h of deprecated API
A large slice of it has been deprecated since 5.2.

Reflowed a doc paragraph pointed out, in the deprecation commit, as
having been left ragged by its edits.

Note: qSwap() is documented as \deprecated but not marked, where it's
defined, as deprecated.

Change-Id: Iaff10ac0c4c38e5b85f10eca4eedeab861f09959
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 21:22:32 +02:00
Tor Arne Vestbø
dce106c77c High-DPI: Remove usage of Qt::AA_EnableHighDpiScaling
This attribute is now on by default.

Change-Id: I7c9d2e3445d204d3450758673048d514bc9c850c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-28 20:08:43 +02:00
Tor Arne Vestbø
92a32e050f Remove QMacNativeWidget and QMacCocoaViewContainer
The functionality should be available via QWidget::winId(),
and QWidget::createWindowContainer() + QWindow::fromWinId().

Any bugs in this area should be fixed by improving the general
wrapping APIs.

Fixes: QTBUG-83254
Change-Id: I86584a4a8138d17d65a50da39efd58039f10da91
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-28 14:16:52 +02:00
Tor Arne Vestbø
756d7facf6 Fix tst_QHighDpiScaling::scale
Without an override for logicalDpi() the base class implementation
would use the geometry of the screen to figure out the DPI, and end
up with ~100, which combined with a 96DPI base logical DPI would
give a wrong scale factor.

Change-Id: I68aecce44d2ee672c7b707dfe5444af8f551e961
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-28 13:00:05 +02:00
Tor Arne Vestbø
70def4341a Avoid inifinite recursion call in tst_Compiler::cxx11_noexcept
warning: all paths through this function will call itself [-Winfinite-recursion]

Change-Id: I70008710a7448ffd532bb6c3acb488fe439cb807
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 09:43:14 +00:00
Tor Arne Vestbø
6ab6571f24 Remove tst_QGL
It was left out of the build in f08038fca7
but not removed. It doesn't make sense to keep it, as the classes it
tests have been removed.

Change-Id: Ic36a066eb092d8b9b40c645de649af9dcaab4ff2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-08-28 11:43:11 +02:00
Jonas Karlsson
3558704ed5 Use OpenType font weights
Task-number: QTBUG-42248
Change-Id: Icdb301b27d6699c2b842c4563fbef9df73c23cbc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-08-28 07:26:54 +02:00
Marcel Krems
257285553f Use qsizetype in QRegularExpression
PCRE2 already uses size_t which we can now make full use of.

Change-Id: Icb5efd5c6ef27f2e31a9780bf62f5671ddc603cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 02:22:10 +02:00
Fabian Kosmale
4d5a048d96 Improve connect: Use existing metatypes if possible
As there is now a chance that a QMetaMethod already contains the
metatypes for its arguments, we can just query it directly (and use the
fallback to name lookup logic that already exists there).
This also allows us to avoid creating a QList of names, and only
requires us to do a name lookup in case the connection actually fails.

Change-Id: Idda30bc4b538a94476ae6c533776c22340f0030d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-28 00:41:00 +02:00
Mårten Nordheim
f7f79483e7 Remove QFtp sources etc. in favor of alternate distribution
While we initially wanted to just disable the functionality the way it
is currently built forces people to do a full build of Qt just to enable
it. Instead of doing this half-measure let's just remove the code
completely from QtBase and rather prepare QtNetwork to handle being a
plugin that can be compiled at any time.

Task-number: QTBUG-80340
Change-Id: I19155c8c167cf932088f01b2a9706d0e7ab792d1
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-08-27 18:58:21 +02:00
Lars Knoll
84f3690947 Make QUUid constructors from string like types explicit
I don't think we want to have implicit conversion
from a const char * or a QByteArray to a QUuid.

Change-Id: Idfe7450ce15b89e295aa7af7ccf1fc94f5acd4f9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-27 18:58:21 +02:00
Lars Knoll
50661a9558 Change QByteArray to handle large arrays
Use qsizetype throughout.

Change-Id: I787af7fcfa17e1be87decb64c41c609cc24be117
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-27 18:58:20 +02:00
Andrei Golubev
4a56a5f6cf Support GrowsBackwards prepend in QList
Restored previously deleted logic of setting GrowsBackwards flag for
prepend-like cases. This should be sufficient to fully enable prepend
optimization

Fixed QList::emplace to not use implementation detail logic. Updated
tests to cover changed behavior and its correctness

Task-number: QTBUG-84320
Change-Id: I4aadab0647fe436140b7bb5cf71309f6887e36ab
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-27 18:58:20 +02:00
Andrei Golubev
f9bb3aa5ce Add prepend optimization to QCommonArrayOps
Introduced prepend optimization logic to QCommonArrayOps.
Trying to rely on original QList behavior

Task-number: QTBUG-84320
Change-Id: I46e6797b4edad804a3e3edb58307c9e96990fe01
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-27 18:58:20 +02:00
Andrei Golubev
e35d0ae0cc Support GrowsBackwards flag in QArrayDataPointer
Introduced allocation function in QArrayDataPointer with
interface similar to QArrayData::allocate that supports growing
strategies. This func is used instead of the original in cases
when prepend-aware storage is needed. Tried to follow Qt5 QList
policy in terms of space reservation

Updated QPodArrayOps::reallocate to be aware of growing
shenanigans. It doesn't look like a perfect solution but it is
rather close and similar to what Qt6 QList is doing when not
growing (e.g. reserve/squeeze)

Added initial QCommonArrayOps with helper function that tells
when reallocation is preferable over just using the insert-like
operation. This comes up later on when GrowsBackwards policy is
properly supported in operations

Essentially, 2/3 main data management blocks for prepend optimization
are introduced here. The last one being a generalized data move that
is done instead of reallocation when existing free space is not enough

Task-number: QTBUG-84320
Change-Id: I9a2bac62ad600613a6d7c5348325e0e54aadb73d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-27 18:58:20 +02:00
Edward Welbourne
7883bf7304 Mark some Qt namespace enum members properly as deprecated
A comment is not good enough, Some of the enum members were even still
in use, or mentioned in documentation.

WA_ContentsPropagated, WA_WState_DND and WA_ForceAcceptDrops have been
deprecated since 4.5.1; and at least the last has been an \omitvalue
in the docs for even longer.  (WA_ShowModal and WA_GroupLeader have
been similarly marked, but are in use, see QTBUG-85816.)

Push back to 5.15.1 in order to be able to remove these at Qt 6.

Pick-to: 5.15.1
Change-Id: I6ea3839767e5f5158b0fed508f65798470191908
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-27 13:05:42 +00:00
Morten Johan Sørvig
ffde7e8995 QIcon: Add pixmap() overload which take devicePixelRatio
Add new QIcon::pixmap() overload:

  QPixmap pixmap(const QSize &size, qreal devicePixelRatio, ...)

This function replaces the existing pixmap() function which
take a QWindow pointer, and should be more convenient in use.

Task-number: QTBUG-85885
Change-Id: Ie4ca96a266d9278864678dc61bdfc2836cabdb93
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-08-27 12:13:08 +02:00
Volker Hilsheimer
c501e09efa Replace QAbstractItemView::viewOptions with initViewItemOption
viewOptions returned a QStyleOptionViewItem object. Such a method
can never support newer versions of the option structure.

Most styleable QWidget classes provide a virtual method
initStyleOption that initializes the option object passed in as a
pointer, e.g QFrame, QAbstractSpinBox, or QComboBox.

Follow that API convention, but name it initViewItemOption, as the
QStyleOptionViewItem struct contains information about the item as
well as the widget itelf.

This is a source incompatible change that will go unnoticed unless
existing subclasses mark their overrides as 'override', or call
the removed QAbstractItemView::viewOption virtual function.

[ChangeLog][QtWidgets][QAbstractItemView] The virtual viewOptions
method that previously returned a QStyleOptionViewItem object has
been renamed to initViewItemOption, and initializes a
QStyleOptionViewItem object that's passed in through a pointer.

Change-Id: Ie058702aed42d77274fa3c4abb43ba302e57e348
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-08-26 18:02:58 +02:00
Tor Arne Vestbø
b5f972361a Introduce QWindow::paintEvent with QPA plumbing
The explicit paint event on QtGui and QPA level allows us to untangle
the expose event, which today has at least 3 different meanings.

It also allows us to follow the platform more closely in its semantics
of when painting can happen. On some platforms a paint can come in
before a window is exposed, e.g. to prepare the first frame. On others
a paint can come in after a window has been de-exposed, to save a
snapshot of the window for use in an application switcher or similar.

The expose keeps its semantics of being a barrier signaling that the
application can now render at will, for example in a threaded render
loop.

There are two compatibility code paths in this patch:

  1. For platform plugins that do not yet report the PaintEvents
     capability, QtGui will synthesize paint events on the platform's
     behalf, based on the existing expose events coming from the platform.

  2. For applications that do not yet implement paintEvent, QtGui will
     send expose events instead, ensuring the same behavior as before.

For now none of the platform plugins deliver paint events natively,
so the first compatibility code path is always active.

Task-numnber: QTBUG-82676
Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 16:44:53 +02:00
Richard Moe Gustavsen
ed813c19fa macOS: rename 'macintosh' style to 'macos'
Change the name/key of the style to 'macos'. Besides the
name 'macintosh' being archaic, we also need this
change to avoid creating 'macintosh' style folders
in QtQuickControls, now that we plan to use QPlatformTheme
also there to resolve the style.

[ChangeLog][Widgets][QStyle] The 'macintosh' style
has been renamed to 'macos'.

Change-Id: I14b8a8b4dbd369e7a7d16b94e4ad27e501e7e8d0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-26 16:37:43 +02:00
Sona Kurazyan
9efe2a8603 Fix QFuture::waitForFinished to wait until QFuture is started
Currently QFuture::waitForFinished() exits as soon as the future is not
in the running state. If the user calls it before
QPromise::reportStarted() is called, it will exit immediately, because
nothing is running yet. Fix the behavior to wait for the finished state.

[ChangeLog][Important Behavior Changes][QtCore] Fixed the behavior of
QFuture::waitForFinished() to wait until the future is actually in the
finished state, instead of exiting as soon as it is not in the running
state. This prevents waitForFinished() from exiting immediately, if at
the moment of calling it the future is not started yet.

Task-number: QTBUG-84867
Change-Id: I12f5e95d8200cfffa5653b6aa566a625f8320ca8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-08-26 16:37:43 +02:00
Sona Kurazyan
7d35e31efb Add back QByteArray's relational operators taking QString
QString still has the overloads of relational operators taking
QByteArray. Add back QByteArray's relational operators taking
QString for symmetry. See also the comments of
d7ccd8cb45 for more details.

[ChangeLog][EDITORIAL] Remove the changelog about QString/QByteArray
operators being removed. They're back.

Change-Id: I22c95e727285cf8a5ef79b3a4f9d45cb66319252
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 14:37:43 +00:00
Alex Trotsenko
fe4b246446 Synchronize QEventDispatcherWin32::processEvents() with QCoreApplication
QCoreApplication has a special internal mechanism to control whether
the event dispatcher should block after delivering the posted events.

To handle queued connections in nested loops properly, we should use
that functionality.

Pick-to: 5.15
Fixes: QTBUG-85981
Change-Id: I124179a23b26a995cf95ed379e97bfa62c95f42a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-26 11:08:15 +03:00
Volker Hilsheimer
fab8933d5b Don't skip QFileDialog retranslatability test on macOS
The test explicitly asks for a non-native file dialog, which works on
macOS as well.

Change-Id: I964c6d98501b4207c2b6c2ce1df39f654c801a43
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-26 03:45:30 +02:00
Marcel Krems
8dd50ef206 Remove deprecated qGenericMatrix{To,From}Matrix4x4 functions
Change-Id: I3b43d48f5324f3a1f2fff8e22bb4f9563d3ea997
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 01:49:24 +02:00
Thiago Macieira
ad5a65b6a2 QStandardPaths/Unix: improve the XDG_RUNTIME_DIR creation/detection
First, use QT_MKDIR instead of QFileSystemEngine::createDirectory(), as
the latter can't create a directory with the right permissions. That
would allow an attacker to briefly obtain access to the runtime dir
between the mkdir() and chmod() system calls.

Second, make sure that if the target already exists that it is a
directory and not a symlink (even to a directory). If it is a symlink
that belongs to another user, it can be changed to point to another
place, which we won't like.

And as a bonus, we're printing more information to the user in case
something went wrong. Sample outputs:

 QStandardPaths: runtime directory '/root' is not owned by UID 1000, but a directory permissions 0700 owned by UID 0 GID 0

 QStandardPaths: runtime directory '/dev/null' is not a directory, but a character device, socket or FIFO permissions 0666 owned by UID 0 GID 0

 QStandardPaths: runtime directory '/etc/passwd' is not a directory, but a regular file permissions 0644 owned by UID 0 GID 0

 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-tjmaciei'
 QStandardPaths: runtime directory '/tmp/runtime-tjmaciei' is not a directory, but a symbolic link to a directory permissions 0755 owned by UID 1000 GID 100

Pick-to: 5.15 5.12 5.9
Change-Id: Iea47e0f8fc8b40378df7fffd16248b663794c613
Reviewed-by: David Faure <david.faure@kdab.com>
2020-08-25 16:13:44 -07:00
Volker Hilsheimer
872e37b2ff Implement QAbstractFileIconProvider to use theme and mime databases
This doesn't give useful defaults on all platforms; icon themes are not
provided on platforms other than Linux, and the mime database doesn't
always return user-friendly names based on file names.

However, both icon themes and the mime database can be customized by
application developers by shipping a data file side-by-side with the
application, without the need for reimplementing the provider class.

Change-Id: Ie4b18ac1b861e2da64f01d1f209986b27fbe6bd5
Task-number: QTBUG-66177
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-26 01:13:19 +02:00
Andrei Golubev
afd34d74b8 Fix QPromise snippets: use QScopePointer instead of QPointer
Change-Id: I2b863e43eb227a80ded3422ca57bd5f5d4209858
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-08-26 01:12:50 +02:00
Giuseppe D'Angelo
049d8892ea QRegularExpression: do not assume QStringViews are NUL terminated
The convenience API used to look up the index of a named capturing
group expects NUL terminated strings. Therefore, we can't just
use it together with QStringViews, which may be not. Use the
non-convenience API instead.

Pick-to: 5.15
Change-Id: I25ca14de49b13ee1764525f8b19f2550c30c1afa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-25 23:09:09 +00:00
Lars Knoll
acbf9a858b Cleanup QTypeInfo
Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6.
Also remove sizeOf, it's unused, and we have QMetaType for that if
required.
Remove all typeinfo declaractions for trivial types, as the default
template covers them correctly nowadays.

Finally set up a better default for isPointer, and do some smaller
cleanups all over the place.

Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 01:03:22 +02:00
Volker Hilsheimer
b77a3f47c9 Rename confusingly named QFont/QPalette::resolve overloads
Having three methods with the same name doing different things is
unnecessarily confusing, so follow the standard naming convention in
Qt and call the getter of the resolve mask resolveMask, and the setter
setResolveMask. These methods were all documented as internal.

The publicly documented resolve() method that merges two fonts and
palettes based on the respective masks remains as it is, even though
'merge' would perhaps be a better name.

Change-Id: If90b1ad800834baccd1dbc38fc6b861540d6df6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-25 17:59:10 +02:00
Robert Loehning
c0d0949448 QLineF: Don't try calculating a unit vector when length is null
It's undefined and causes a division by zero.

Fixes: oss-fuzz-24561
Pick-to: 5.12 5.15
Change-Id: Idebaba4b286e3ab0ecb74825d203244958ce6aec
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-25 17:59:10 +02:00
Fabian Kosmale
f325bac02e tst_qobject: Enable build with CMake
Change-Id: Ia2b324d0e5aa88ea9a71bb040a740f359e11f2ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-25 09:13:46 +02:00
Mårten Nordheim
0871a7b5a2 tst_QNetworkDiskCache: fix setCookieHeader
It wouldn't grab the cached entry since it was not deemed
"fresh" (and would never be fresh because we didn't know when it
originated from or when it expired). But the test still passed because
the reply produced a "finished" signal which ended the loop, but the
"finished" signal was due to an error which was unchecked.

Change-Id: I6ad271aa621bdb4a48b74bc8fd64c7e2caa8f179
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-08-25 09:09:42 +02:00
Marcel Krems
fcc25b11bb QPrinterInfo: Remove deprecated methods
Change-Id: I5089bc23308a4348dc21122dfa000d5ca6e3938d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-25 06:48:28 +02:00
Shawn Rutledge
c7f7279969 Introduce QEvent::isPointerEvent()
This makes high-level event dispatching easier: for example in Qt Quick,
all pointer events should eventually be delivered to items in a similar way.

Implemented in a similar way as d1111632e2.

Change-Id: I2f0c4914bab228162f3b932dda8a88051ec2a4d7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-25 06:34:01 +02:00
Volker Hilsheimer
fb9ec8ad44 Move QFileSystemModel into QtGui
This requires a QAbstractFileIconProvider in QtGui, as the standard
QFileIconProvider depends on QStyle, and cannot be moved out of
QtWidgets.

QAbstractFileIconProvider returns strings for file types, but returns
no icons yet. Support for a default icon set might be added in a
follow-up commit.

Change-Id: Ib9d095cd612fdcf04db62f2e40709fcffe3dc2b7
Fixes: QTBUG-66177
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-25 06:33:44 +02:00
Karsten Heimrich
a735038376 Move QStateMachine from QtCore to QtScxml
Task-number: QTBUG-80316
Change-Id: I2ee74110fd55e94d86321d3b3dc5bb8297424ed4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-08-24 20:10:25 +02:00
Mårten Nordheim
43f01ec2e5 QByteDataBuffer: add readPointer functionality using QByteArrayView
While it could be done before it's nice to not have a custom "local"
struct or the size in an out-parameter.

Change-Id: Ie910f7060b1dadf037312d45e922f8e2deafe3ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 17:44:08 +02:00
Mårten Nordheim
467d215b32 Disable cipherstring-setting test for schannel
And put a note about it in the documentation

Change-Id: I29126e4a80f83c256190e03b8fe01f3c869fd46d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-24 17:43:39 +02:00
Mårten Nordheim
5283be1f73 tst_qnetworkreply: Extend httpConnectionCount to test HTTP/2 and TLS
HTTP/2 is only used initially before it transitions to using HTTP/1.1,
and in this case the amount of connections established should also
reach 6.

Change-Id: I300e171e46c846df1730c07469ea85a51cecfb63
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-24 17:43:30 +02:00
Alex Trotsenko
556a7e7318 QIODevicePrivate: rearrange class members
As this class is a subject of the library hook data, there must be a
solid understanding of the member's alignment and padding across
different architectures. By reordering the layout, this patch provides
a clearer way of adding new members to the class.

Bump the TypeInformationVersion field in qtHookData, to notify the
Qt Creator developers that the offset of QFilePrivate::fileName was
changed and dumpers should be adapted.

Change-Id: Ied8b69bdeb9da50ff05aba2107bc75509674b18e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 14:50:56 +03:00
Alex Trotsenko
b3310426b6 tst_QLocalSocket: fix wrong slot name
Suppress the warning:

QObject::connect: No such slot LocalSocket::slotError(QLocalSocket ...

Pick-to: 5.15
Change-Id: Ia08505ebc85d4070582c7ddaae8b581d394dbb80
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-08-24 14:50:56 +03:00
Marcel Krems
41a716ebbf QSqlite: Don't crash after binding too many placeholders
When you bind more values than the query has placeholders,
indexes will be empty which causes an out-of-bounds access in indexes.first.

We can't check the parameter count because of multiple placeholders with the same name,
so we check if the name is null.

Tested with SQLite and PostgreSQL

Pick-to: 5.15
Change-Id: Id5d4bd15d7ed16603f47b87d6e0bf811a20157d8
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-08-24 13:50:55 +02:00
Shawn Rutledge
38806273e5 Remove QEventPoint::event() in favor of device()
event()->device() was the most common use case anyway.

The idea that the "parent" of a QEventPoint is the QPointerEvent
interferes with the ability to copy and move event objects: the parent
pointers are dangling unless we use the QPointerEvent subclass
destructors to set the points' parents to null.  Since there is no move
constructor, even returning a QEventPoint from a function by value
results in destroying the temporary instance and copying it to the
caller's space.  So the parent pointer is often useless, unless we do
even more work to maintain it when the event moves.

If we optimize to avoid copying QEventPoints too much (and perhaps
enable exposing _mutable_ points to QML) by storing reusable instances in
QPointingDevice (which is the current plan), then the actual parent will
no longer be the event.  Events are usually stack-allocated, thus
temporary and intended to be movable.

Change-Id: I24b648dcc046fc79d2401c781f1fda6cb00f47b0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-24 13:50:55 +02:00
Lars Knoll
e7e7540aec Deprecate int based convert/canConvert
Better to provide the correct meta type to convert to.

Change-Id: I8e0d46e4ba482186201c157e302c03874bd38e7b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:19:18 +02:00
Lars Knoll
1697fbdf05 Deprecate the static int based API in QMetaType
And remove one of the type id to name mapping that still
existed in QMetaType. QMetaTypeInterface can provide that,
so there's no need to have a second copy of the data.

qMetaTypeTypeInternal() can still map all the names of all
builtin types to ids. That functionality is for now still
required by moc and can't be removed yet.

Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-24 00:19:05 +02:00
Lars Knoll
92b3767632 Remove refcounting of QMetaTypeInterface
It's only used for dynamic types in DBUS and QML, where we control
things good enough to be able to handle the lifetime of those
interfaces there.

Change-Id: Ia7f8970d17a85b195db85fcdc2d8f1febd8753f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:18:58 +02:00
Lars Knoll
9c501b0670 Remove an unused enum value and document another one
Change-Id: If9fed4f20242d789c1251b8798d7378d2d6911a6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-24 00:18:45 +02:00
Lars Knoll
c7ce1bc05c Move conversions to and from *Iterables into QMetaType
Those were not yet supported by QMetaType.

Change-Id: I9f85476049f200e35939ac58ef7e8b4e7cbe0b77
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-24 00:18:31 +02:00