One of the good features of the new connection style is that
implicit conversion is performed for the connection arguments.
However, this is also a bad feature when it comes to the old
C remnants in the C++ language: for instance, doubles implicitly
convert to ints, possibly losing precision (and GCC/Clang do not
even warn about those under -Wall, only MSVC does) or even
triggering undefined behavior.
For this reason, when using braced initialization, C++11
disables narrowing conversions or floating/integral conversions.
Use this feature when checking the arguments of a PMF-style
signal/slot connection. Technically this makes the program
ill-formed, however GCC still accepts it (but at least
warns under -Wall).
Hence, add a way to disable these implicit conversions.
This is a opt-in and guarded by a macro, as it's a source
incompatible change.
[ChangeLog][QtCore][QObject] The
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT macro has been added.
When using the new connection syntax (PMF-based) this macro
makes it illegal to narrow the arguments carried by the signal,
and/or to perform floating point to integral implicit
conversions on them. When the macro is defined,
depending on your compiler a QObject::connect() statement
triggering such conversions will now fail to compile.
Change-Id: Ie17eb3e66ce0cd780138e60d8bb7da815a4ada83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In all other forms of disconnecting this is done. We also know the
signal index, so there is no reason not to do this.
Change-Id: Ic8b042cd8f45dbff74b42ee30c384a84bef78b20
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
[ChangeLog][QtCore][QTimer] Added support for std::chrono duration
objects for QTimer methods, like QTimer::singleShot and
QTimer::setInterval.
Change-Id: I87e17314d8b24ae983b1fffd14536e24d5b12424
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
It's really a kernel functionality, as it implements really low-level
functionality and it's used by the event dispatcher. It was in tools/
only because QTime is.
QDeadlineTimer is also coming to kernel/.
Change-Id: Ifea6e497f11a461db432ffff14491c6d9b839eb0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
...if a PMF connection had already happened. Since UniqueConnection
isn't implemented for non-PMFs (functors and lambdas aren't comparable,
even if static member functions or non-member functions are), we pass a
null pointer for comparison argument. The disconnect() code already
protected against a null pointer there, but not the connect code path
with Qt::UniqueConnection
Change-Id: I87e17314d8b24ae983b1fffd145324beced0494d
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Dario Freddi <dario.freddi@ispirata.com>
The stream in question is from prior to Qt 5.0 release, before
commit 718a2251be changed QDateTime
serialization format to store Qt::TimeSpec instead of the private
flag. The last byte was 0xff meaning LocalUnknown, but 0xff is
not valid in Qt 5.0.
It was just garbage that Qt up to now just accepted. With the upcoming
short QDateTime optimization, the results are worse.
Change-Id: I25d85d86649448d5b2b3fffd1450f57df17e7794
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Pass -xplatform macx-tvos-clang to configure to build.
Builds device and simulator by default.
Added ‘uikit’ platform with the common setup.
Also added QT_PLATFORM_UIKIT define (undocumented).
qmake config defines tvos (but not ios).
tvOS is 64bits only (QT_ARCH is arm64) and requires bitcode to be
embedded in the binary. A new ‘bitcode’ configuration was added.
For ReleaseDevice builds (which get archived and push to the store),
bitcode is actually embedded (-fembed-bitcode passed to clang). For all
other configurations, only using bitcode markers to keep file size
down (-fembed-bitcode-marker).
Build disables Widgets in qtbase, and qtscript (unsupported,
would require fixes to JavaScriptCore source code).
Qpa same as on iOS but disables device orientation, status bar, clipboard,
menus, dialogs which are not supported on tvOS.
Change-Id: I645804fd933be0befddeeb43095a74d2c178b2ba
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
QVariant::canConvert<Enum> was returning true for everything can can be converted
to integer, but not for integer itself. That's because in QVariant::canConvert
we set the targetType to Int of it's an enum, but the Int->Int case was not
on the conversion matrix. So this commits adds it to the conversion matrix
and now QVariant::canConvert<Enum> returns consistently true for int itself.
But even tough canConvert returned true, it did not actualy do any conversion
to the enum type itself. Fix that by handling the case properlt in 'convert'
[ChangeLog][QtCore][QVariant] Fixed QVariant::canConvert and conversion from
integer types to enumeration types.
Task-number: QTBUG-53384
Change-Id: I6ac066f3900e31bfcea7af77836ddfc7730bd60b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The behavior was different in the variadic template code and in the C++98
code. The code without variadic template support was not copying the functor
object (e.g. a lambda) before calling it.
However, in the variadic template section, QtPrivate::FunctorCall::call
took the functor by value instead of by reference resulting in a copy.
QtPrivate::FunctorCall::call is a helper function for
QtPrivate::FunctionPointer::call which is only needed for variadic template
expension.
[ChangeLog][QtCore][QObject] If the compiler supports variadic templates,
no longer copy functor connected to a signal each time the signal is
emitted. Restoring the C++98 behavior.
Task-number: QTBUG-52542
Change-Id: I3ca20ef6910893b8a288e70af7de4c7b69502173
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The flags here are passed to a private QVariant constructor, and they
really represent a boolean - IsPointer or not.
Because the flag for the key_type was incorrectly populated with the
flag for the value_type, memory would be corrupted when using a mapping
type whose value_type is a pointer, but whose key type was not, such as
QMap<QString, int*>
This typo has been there since the concept was introduced in commit
v5.2.0-alpha1~807 (Add container access functionality for associative
containers in QVariant., 2013-04-05).
Task-number: QTBUG-52246
Change-Id: I9ecb13c603015eed2dc2ca43947fa0ecd6be8b5a
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
People use this, so make sure there's a test for it.
I don't expect this test to fail, but static and
dynamic checkers should be presented with this
use-case, so they have a chance of warning, because
certain implementation strategies of QPointer may
make this code undefined.
Change-Id: I334bd73204ba4e186c4098fc6b7188917407e020
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Cleaning out the workarounds for the discontinued "Embedded Android"
platform of Boot2Qt.
Change-Id: I0ff9d770e82a43457fb7e5da0428f4597ead4038
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This is analogous to QObject::inherits() but only requires the
metaobjects rather than pointers to a QObject instances. This is needed
for type checking on the backend of Qt 3D where we do not have access
to QObject pointers.
Change-Id: I14d26c4cbb5cc3fbecb57725f2c14ee0ffda4a11
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This change partially reverts 1bfc7f68 about QT_HAS_BUILTIN define
and undef in src/corelib/tools/qsimd_p.h.
This change is also squashed with "Fall back to c++11 standard
compiler flag for host builds" which is done by Peter Seiderer.
Conflicts:
mkspecs/features/default_post.prf
src/3rdparty/sqlite/0001-Fixing-the-SQLite3-build-for-WEC2013-again.patch
src/3rdparty/sqlite/sqlite3.c
src/corelib/tools/qsimd_p.h
src/gui/kernel/qevent.cpp
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface_p.h
src/plugins/bearer/blackberry/blackberry.pro
src/plugins/platforms/cocoa/qcocoasystemsettings.mm
src/plugins/platformthemes/gtk2/gtk2.pro
src/plugins/styles/bb10style/bb10style.pro
src/sql/drivers/sqlite2/qsql_sqlite2.cpp
tools/configure/configureapp.cpp
Task-number: QTBUG-51644
Done-with: Peter Seiderer <ps.report@gmx.net>
Change-Id: I6100d6ace31b2e8d41a95f0b5d5ebf8f1fd88b44
As found by GCC 6:
tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp:1476:9: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
tn += ">";
^~
tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp:1474:5: note: ...this ‘if’ clause, but it is not
if (tn.endsWith('>'))
^~
Fix += argument from char[2] to char as a drive-by.
Change-Id: I814dc58830934cac7fcf81eb7fd7564b2abeb631
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This also reverts commit 018e670a26.
The change was introduced in 5.6. After the refactoring, 14960f52,
in 5.7 branch and a merge, it is not needed any more.
Conflicts:
.qmake.conf
src/corelib/io/qstandardpaths_mac.mm
src/corelib/tools/qsharedpointer_impl.h
tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
Change-Id: If4fdff0ebf2b9b5df9f9db93ea0022d5ee3da2a4
Some entries were not updated and tests failed to succeed on platforms
which need to deploy content/testdata.
Change-Id: Ieb2b44c375b04cbaaecc1fb2303cc2478b86a100
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
testdata needs to be deployed to temp and current directory
needs to be set to that directory for the test to succeed.
Change-Id: I2dd023af9073d90afbb4ad60fcfb50bb1af4e159
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
WinRT does not allow do connect to the localhost due to security
constraints and sandboxing. Hence we need to disable those
currently.
Change-Id: Idb8c71397a41e5fa5bad9d618dba1bb389e71b9c
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This patch makes sure that all events posted using Qt on top of the
GLib event loop have the loopLevel counter incremented.
This is done since Qt depends on the fact that all deleteLater() calls
are issued within the scope of some signal handler (in other words,
triggered by the chain sendEvent() -> notifyInternal2()).
There is a side effect though: in the conditions affected by this
patch, that is deleteLater()s issued within a glib event handler for
example, manually calling processEvents() or sendPostedEvents() with
or without the QEvent::DeferredDelete flag has the same effect, and
deferred deleted events are always processed.
While this is not a currently working feature which the patch breaks,
this side effect seems to be difficult to avoid without separating
sendPostedEvents() and processEvents() into a public and a private
method, in order to detect when they are manually called.
Such change could perhaps be done for Qt6.
An autotest for QTBUG-36434 is also included.
Autotesting for QTBUG-32859 seems to be more challenging in this
respect, due to its dependency on GLib.
Task-number: QTBUG-18434
Task-number: QTBUG-32859
Task-number: QTBUG-36434
Change-Id: Ib89175aa27c9e38bca68ae254d182b2cd21cf7e9
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
I wrote a script to help find the files, but I reviewed the
contributions manually to be sure I wasn't claiming copyright for search
& replace, adding Q_DECL_NOTHROW or adding "We mean it" headers.
Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)
Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Not just fuzzily equal. The fuzzy comparison fails for infinities, since
the expression p1 - p2 where p1 = p2 = infinity is NaN. And NaN
comparisons are always false.
As a nice side-effect, we don't do the more expensive computation of a
multiplication if the two numbers really are equal.
Task-number: QTBUG-50036
Change-Id: I11f559ef75544c50b3f8ffff1420cec7c7273295
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
If CountedStruct is passed a GetSenderObject object,
it will attempt to call a member on it from within
its own destructor.
That works usually quite well, but in this test case,
which tests for function object leaks when a connection
is torn down because the sender object is destroyed,
the destruction of the CountedStruct happens when all
connections are severed in ~QObject. At that point,
what used to be a GetSenderObject instance no longer
is one and the call into one of its member functions
invokes undefined behavior.
Fix by making QObject::sender() public by a using
declaration instead of a wrapper function.
Found by UBSan:
tests/auto/corelib/kernel/qobject/tst_qobject.cpp:6007:104: runtime error: member call on address 0x7ffc6e7538b0 which does not point to an object of type 'GetSenderObject'
0x7ffc6e7538b0: note: object is of type 'QObject'
Change-Id: Ia973140037b3c1b5a670a8a3949d09b956f40349
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
If QObjectPrivate::declarativeData is set, it is
in various places in Qt expected to point to a
QAbstractDeclarativeDataImpl, from which ownedByQml1
is unconditionally read.
In noDeclarativeParentChangedOnDestruction(), the
declarativeData pointer is, however, set to a local
QAbstractDeclarativeData instance, which, being an
empty class, has size 1 and alignment 1.
Depending on the compiler's idea of bit field order,
this code either read uninitialized data from the
dummy object, or else some random stack memory outside
any (valid) object.
What caught UBSan's attention, though, was the
difference in alignment between the two classes:
src/corelib/kernel/qobject.cpp:917:9: runtime error: member access within misaligned address 0x7fffc9cf706f for type 'struct QAbstractDeclarativeDataImpl', which requires 4 byte alignment
Fix by providing a properly initialized object of the
correct type.
Change-Id: Iae83a949ee5a7bc98df13e35ea614c063085fa13
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Don't pass around meta-type IDs in QMetaType::Type
variables. It leads to reading values from an enum
variable that are invalid.
Fix by passing the IDs around as int.
Found by UBSan:
tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp:408:5: runtime error: load of value 4028, which is not a valid value for type 'Type'
Change-Id: Idd106ee3d7960fe3d8fefc0fc5830fc22d38a513
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
TEST_HELPER_INSTALLS cannot be used on platforms with no
QProcess support.
Change-Id: I2a6a283d94ca4487fc628449c53fc37140dd291d
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Also use this for converting doubles with QVariant. We generally want
exact results there, rather than adding rounding errors whenever we
convert.
[ChangeLog][QtCore][QLocale] Added special value for double conversion
precision to get shortest accurate representation.
Change-Id: I905b8a103f39adf31d24b6ce2c8a283cf271b597
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Use QByteArray/QString addition instead in loops and for
test row names.
Change-Id: Ieffb429efdc14aa5932b3fcdef5a18e13a62d35f
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>