Commit Graph

167 Commits

Author SHA1 Message Date
Olivier Goffart
66b659c8a4 Add support for QueuedConnection when connecting using the new syntax
QMetaCallEvent now can handle a pointer to QSlotObjectBase

Change-Id: I94da1e68ce9bb1fd96a9ae013a389552eb625faa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-11-25 01:12:14 +01:00
Olivier Goffart
583c55b243 New QObject connection syntax
In addition to the old connection syntax, you can now connect using function pointers.

    connect(sender, &Sender::valueChanged,
            receiver, &Receiver::updateValue );

You can connect also to functor or C++11 lambdas

The connections are now type safe (no more problems with namespaces
or typedefs).  Implicit type conversion is also supported.

The new syntax forces us to change the meaning of signal form
protected to public, in order to be able to access the signal's
address everywhere

The way it works is by introducing new overload of QObject::connect
that take function pointer as parametter. Those new overload are template
function, that are implemented inline. The actual implementation is
in QObject::connectImpl which take a QObject::QSlotObject* as parametter
for the slot.  That slot object contains a virtual function which call
the slot which has to be implemented in the header as it depends on the
template parametter.  So the internals of QObjectPrivate::Connection
will store this QObjectSlot* in order to be able to make the call.

You can read a full description here:
http://developer.qt.nokia.com/wiki/New_Signal_Slot_Syntax

History of commits before it was imported on gerrit:
https://qt.gitorious.org/~ogoffart/qt/ogoffarts-qtbase/commits/qobject_connect_ptr

Thread on the mailing list:
http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000796.html
http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-September/001248.html
(The discussions on the mailing list were about trying to find a
solution that do not need making signals public, but no user friendly
solution was found)

Note: support for QueuedConnection, and the symetric QObject::disconnect is
added in another commit.
Qt::UniqueConnection is not supported yet in the new overload.

Change-Id: I67d08436b0720e7f2992be9f7e34770960fa58fa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-11-25 01:12:14 +01:00
Olivier Goffart
79f675a1e0 Change the return value of QObject::connect
From a bool to a handle to to connection.

Also added a new overload of disconnect that disconnect a handle

This is required because with the new syntax taking lambda or functors,
it is the only way to disconnect a connection (as it is impossible to
compare functors)

The new return value is QMetaObject::Connection, it is a wrapper around
the internal QObjectPrivate::Connection.
QObjectPrivate::Connection is now reference counted.

tst_qglobal.cpp:
   This test set up an internal callback, and the callback do not set any
   proper connection handle (and tbh,  it would be hard for it to do so).
   So the returned QMetaObject::Connection is invalid, and ok is false
   (Internal callbacks are only used for jambi and should probably be removed)

Change-Id: I111626fb4f47efc4db5e2ea5bff9da15f08fea7b
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-11-25 01:12:14 +01:00
Stephen Kelly
8f1868e7c3 Add a parents parameter to layoutChange signals.
This allows for more focussed notification of what part of the
model has changed layout.

The slots in the proxy models can be more optimized later.

Change-Id: I1bd17465b4be6f8efdc107036db897c557fcb519
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2011-11-24 16:46:15 +01:00
Jason McDonald
170b9a82ba Improve QVector autotest
Ensure that data row names are unique.

Change-Id: Ia6cf6e440d631928ae3352d7305c6cf2ee5b2a0c
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-24 10:38:15 +01:00
Jason McDonald
d34c8b55f3 Only use QVERIFY in test functions.
The modified test was using QVERIFY in the destructor of a local class,
but QVERIFY should only be used directly in a test function.  This
commit changes the local class to record the result of the test and
verifies that result in the test function.

Change-Id: Ie68ac6aa880368c961ebfa67cd452f0fbf26db89
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-24 05:56:48 +01:00
Jason McDonald
f32452e948 Add missing indentation to QFuture test.
Change-Id: Iaceaa79237d5ef6e81d1d16dc5e3fd3d97631f3a
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-24 05:56:42 +01:00
Jason McDonald
d1e7294cd2 Remove misleading comment.
In the QProcess test, QHostInfo is used as a quick and easy way to
create a background thread, and so is not (entirely) unnecessary.

Change-Id: I7204f113e7bc8a4b312d5a20f0a6ee076c56b35d
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-23 07:06:24 +01:00
Holger Hans Peter Freyther
01c795bcd1 uclibc: fenv.h does not define the necessary things.
libstdc++ provides the fenv.h found and for uclibc default toolchains
the bits/c++config.h has _GLIBCXX_HAVE_FENV_H undefined leading to
no import of the uclibc fenv.h

Change-Id: I53173b099f3d8791f527f1ccb60991de57cd19db
Filed: https://bugs.busybox.net/show_bug.cgi?id=4484
Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
2011-11-22 15:17:08 +01:00
Toby Tomkins
ece8f9cd51 Revert 3a0f5d04fc
The removal of plugin cache in qt5 (8ed47d961d)
means that only the original loading error (from QElfParser) is reported.
In Qt4 this was previously two different strings depending on if the library
had been previously cached.

Task-number: QTBUG-22834

Change-Id: I15a4adc7d0f8f23f16bb2aa8ba8b968db770f074
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-22 08:57:08 +01:00
Jason McDonald
bd3477eebc Remove reset test from QTimeLine.
QTimeLine::reset() never made it into the public API. Instead
QTimeLine::start() always starts from the beginning.

Remove the commented-out test for reset() and related remnants in other
tests.  Restarting a timeline using QTimeLine::start() is already tested
by the restart() test function.

Change-Id: Ia5c767ddae0781d645a407fbea76e80672895aab
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-22 00:33:53 +01:00
Jason McDonald
36ee00c9f5 Add test for QTimeLine::toggleDirection()
Before QTimeLine made it into the public API, the toggle() function
became toggleDirection() and isReversed() became the more generic
direction().  This commit uncomments the old toggle() test and uses the
final function names.

Change-Id: Ie3379f32ff0c78436f33c2733232d795ca88152b
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-22 00:33:44 +01:00
Jason McDonald
cf1de2f072 Restore commented-out data in QString test.
The restored test data was commented-out before the tests were imported
into the Qt repository in 2006, but appears to be valid and passes on
Linux.

Change-Id: I75795bf2b0b45fc2331bca6ac8d89f57cf12ed3d
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-22 00:33:38 +01:00
Jason McDonald
e026cbefc6 Remove obsolete data from QStringRef test.
The removed data was copied from the QString test (from which it has
since been removed) and wasn't valid, as comments indicated.

Change-Id: I44f066e41d28333326ad97f652c0a6813a173f15
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-22 00:33:27 +01:00
Jason McDonald
f9111355f2 Remove obsolete code from QRegExp test.
The removed test functions were all empty and have been commented-out
since the tests were imported into the Qt repository in 2006.

Change-Id: I4ce86440aed355352a26ebefeafc95eeda1efbdd
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-22 00:33:12 +01:00
Jason McDonald
0097d2daba Removed commented test data from QUrl test.
The removed test data is invalid for the toString() test function --
QUrl::toString() won't eliminate relative paths from URL's, you need to
call QUrl::resolved() to do that.  Add this test data to the test for
QUrl::resolved(), as the existing tests don't seem to cover the case of
a complete URL containing a relative path.

Change-Id: Idb0f4eac9cc75258a8e17f10fa95ddb75f01d470
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-11-21 18:47:58 +01:00
Stephen Kelly
100908e400 Add a roles argument to the dataChanged signal.
This allows more granular reporting of what has changed.

This change is binary incompatible and source compatible.

Change-Id: I7c5beaee651a24780cc94e41383f7a80210bc603
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2011-11-21 14:24:36 +01:00
Bradley T. Hughes
84f0add9b3 Re-enable the corelib autotests on Mac OS X
This is the first change to re-enable the autotests for the individual
qtbase modules. This means adding subdir.CONFIG=no_check_target for each
module (except corelib) in tests/auto/auto.pro instead of in
tests/tests.pro

QFileSystemWatcher, QIODeice, QSettings, QTextStream, QSocketNotifier,
QVariant, QPluginLoader, QLocale: These tests currently fail, which
will block any changes that attempt to re-enable the autotests. Ignore
the failures for now by marking them as insignificant.

QAbstractItemModel: This test currently crashes, which can
destabilize the CI system when attempting to re-enable the autotests.
Skip this test for now by disabling the check target for it.

Change-Id: Ie5147d5c5cfae5e7d0a495d5c4788ce92fe2e6d8
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
2011-11-21 11:31:35 +01:00
Friedemann Kleint
e8b4c49efd qtbase tests: Fix some warnings
- Fix warnings about QAtomicPointer/Int usage
- Fix some gcc 4.6 warnings about assigned/unused variables

Change-Id: Ib4dbf9110f0dad93ad48e97278310f05fad3a82a
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 09:58:23 +01:00
Jason McDonald
ed5583048e Remove obsolete code from QRect test.
The removed code has been commented-out since Qt 4.0 and relates to
QCOORD, which was part of Qt3Support and has thus been removed from Qt5.

Change-Id: I4651738d505234abe9b79ef5045c55cbf132a88e
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 08:30:30 +01:00
Jason McDonald
ddefed547a Remove empty functions from QLocale test.
These functions have been commented-out and empty for more than five
years.

Change-Id: I52d6dc0366cd8eae8701b05e4c66e9911bf7e8f7
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 08:30:26 +01:00
Jason McDonald
d8ac62c6ec Restore commented-out code in QHash test.
The restored code verifies the following statement in the documentation
of QHash::find():

"If the hash contains no item with the key, the function returns end()."

It is not clear why the code was commented-out in the first place, as
this occurred before the tests were imported into the Qt repository in
2006.

Change-Id: I745393a8e3e728fc60009da07abd038a3d56e99c
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 08:30:22 +01:00
Jason McDonald
72c36332c1 Restore commented-out code in QByteArray test.
The restored code was inexplicably commented-out by commit d57aec33
(non-public history), which was only supposed to be changing upper-case
booleans to lower-case.

Change-Id: I1581fc89511f600c614871e1aec6bc030cddf40e
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 08:30:17 +01:00
Jason McDonald
25ff7e41dd Remove obsolete code from QStateMachine test.
The removed code was already disabled because it tested API that never
made it into an official Qt release -- see commit f7d69d75 in the Qt 4.x
history.

Change-Id: I4f7eb20f937bdabfcac92842c5804233dca26a23
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 04:55:02 +01:00
Jason McDonald
e153d0da3d Remove obsolete code from QStateMachine test.
The removed code was already disabled because it tested API that never
made into an official Qt release -- see commit ad1441fc in the Qt 4.x
history.

Change-Id: I7dbfb83c82bdb79e8d3f7f6c7043d76913dea589
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-21 04:55:02 +01:00
Jason McDonald
572ca43637 Improve diagnostics of QPluginLoader test.
Use QVERIFY2 so that the test output shows the full error string when it
does not contain the expected sub-string.

Change-Id: I31f91bd5c47c082aacabd2333bc12137bc4d24a6
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:56 +01:00
Jason McDonald
d1e2e2ffbe Fix indentation of QPluginLoader test.
Change-Id: I4c6957d2a67ac387232226098b4490e3d5a86d51
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:50 +01:00
Jason McDonald
105ca907fd Improve QPluginLoader autotest diagnostics.
Previously, the user had to recompile the test with an additional define
to see the plugin loader error string.  By re-ordering the verification
statements, we can ensure that the error string is visible in the test
results whenever its value is not the expected value, thus eliminating
the need for conditional diagnostics.

Change-Id: Iae9ef0b7cbad551fd56f0e0439eaad034f2420e3
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:45 +01:00
Jason McDonald
7a65dd3108 Remove disabled code from QLibrary autotest
The removed code was already commented-out when it was first added in
2007, and would not form a useful test as it was not followed by any
verification steps.  QLibrary::setLoadHints() is tested elsewhere, so
this code can vanish.

Change-Id: I1c4dcaacaf31b0f38136336414cfbe3de1a406f3
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:34 +01:00
Jason McDonald
1ce050cd5d Remove disabled test data from QVariant test.
The removed data duplicated the first row of test data in the same
function.

Change-Id: I5d55b970d072d58c170b3ed3004c1661c6d0d13c
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:30 +01:00
Jason McDonald
4d73b7bbcd Remove obsolete code from QVariant test.
Change-Id: If609ddbef7002cb48f4459efd8f2c6edb02c8677
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:25 +01:00
Jason McDonald
30266d8015 Remove obsolete code from QTimer test.
The removed code was for Windows versions <= 2000, which are not
supported by Qt5.

Change-Id: I779ffb8427035b7eb97d8d0af403d03065bc779c
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:18 +01:00
Jason McDonald
b28a690c8f Change confusing test function name.
Naming a test function "_data" is potentially confusing as that string
is a suffix reserved for functions that create data tables for
data-driven tests.  Presumably this function was accidentally caught in
a search and replace at some point before the tests were imported into
the Qt repository in 2006.

Change-Id: I451c0400a1580233ee90b75dd5ad489ee3d3788e
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:13 +01:00
Jason McDonald
397fd4735a Fix typo in QUrl autotest.
Change-Id: Id85ad5c16e3a5b7a1614affa041d19f5062073fd
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 08:58:09 +01:00
Jason McDonald
1a6f2a3d3b Remove obsolete test data from QFile test.
The removed data relied on the test's own source file having no write
permissions, but that is not a valid assumption -- in a source package
the file wouldn't have had write permissions, in Perforce it would have
depended on whether the file had been checked-out for editing and in git
the file would always have write permission.

Change-Id: I3b6100429120137095a210189961c8b97f06e50a
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 07:27:53 +01:00
Jason McDonald
d125e84d6a Remove obsolete test data from QFileInfo test.
The removed data relied on the test's own source file having no write
permissions, but that is not a valid assumption -- in a source package
the file wouldn't have had write permissions, in Perforce it would have
depended on whether the file had been checked-out for editing and in git
the file would always have write permission.

Change-Id: I000596f122f2765f97a09a08074938c90e2e9f95
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 07:27:48 +01:00
Jason McDonald
97cd812d65 Remove obsolete comment from QDataStream test.
The removed comment was introduced before the tests were imported into
the Qt repository in 2006 and seems to relate to a test failure that no
longer occurs.

Change-Id: I01f372f6a4f48110711f4f2a86e73acfb7134e24
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 04:51:09 +01:00
Jason McDonald
40b5b34d0b Remove obsolete comment from QDataStream test.
The removed comment was introduced before the tests were imported into
the Qt repository in 2006 and seems to relate to code that no longer
exists.

Change-Id: Ic21e46fe0157adf5be9dc62de098517b7b27c310
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 04:51:09 +01:00
Jason McDonald
93d2519d99 Improve QBuffer autotest.
This commit fixes several issues found in the readLineBoundaries() test
function.

First, the test performed some test actions but did not perform any
verification steps to check that the outcome of those actions was
acceptable.

Second, the test didn't need to write the buffered data to a file to
verify line-by-line reading.

Third, the get/unget action was unrelated to the readLineBoundaries()
test and has been moved to a separate test function.  That test function
now tests that get/unget works at every position in a buffer, not just
at position 0.

Change-Id: Icad52ed598e94b6e05a194b9ab301d099bfc094c
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 04:51:09 +01:00
Jason McDonald
a8fd0c3654 Don't depend on moc to disable test functions.
The moc tool is not aware of all defines (particularly those that are
compiler builtins) and does not correctly evaluate others that depend
on compiler builtins, such as Q_OS_FOO.

This commit reverts parts of the following commits, but is not a
complete fix as there were many instances of this problem in the tests
prior to those commits:
    924d810dbd
    8aaff67510
    338d3f1197
    a55034062b
    253497b744
    7cfad460c5
    9d2ff58f36
    0cf6baa2d6

Change-Id: I947d797fe3ec76139ba1b55561cea569895662c5
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-18 01:51:57 +01:00
Rohan McGovern
70d91b5c46 Fixed compile of autotests with -qtnamespace.
Make sure to use the Qt namespace for qGlobalPostedEventsCount.

Change-Id: I558a0b0fba1e22a2edd96f9499a2bab82046c4a4
Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
2011-11-18 00:07:51 +01:00
Jason McDonald
6382d27abd Remove commented code from QBuffer autotest.
The removed code was commented-out before the tests were imported into
the Qt repository in June 2006.  This code is no longer valid as the
warning messages it relates to are not produced by any code in qtbase.

Change-Id: Iac63b27387b51a71c567386ca61faf5fb00c3364
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-17 07:21:11 +01:00
Jason McDonald
2b883dc9bb Improve Q_FUNC_INFO autotest.
The availableWithoutDebug() test was trying to force QT_NO_DEBUG to be
defined, but was actually doing the opposite.  While I'm not satisfied
with the way this test works (it would be better to test with
QT_NO_DEBUG already defined when Q_FUNC_INFO is included). at least this
test now does what it says it does.

Additionally, the test has been improved by checking that Q_FUNC_INFO
returns a non-empty string, as opposed to just compiling.

Change-Id: I9175e3a7406152b6250b507a61b5062e3cfabeb8
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-17 07:21:03 +01:00
Bradley T. Hughes
6fcfae99d3 Remove warnings from deprecated atomic operators in autotests
Use QAtomic*::load() and ::store() instead of the deprecated
cast, assignment, and comparison operators. These will be removed
in the near future.

The tests for these particular operators have not been changed,
though, as the change to remove the operators will also remove
the respective tests.

Change-Id: I2f24d18992af0c6e0f487d707218e4e84f4bdd12
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
2011-11-16 10:32:10 +01:00
Sven Anderson
2b7d98ef8f Allow to create a custom event dispatcher for specific QThreads.
QAbstractEventDispatcher() does no longer install itself into the current
thread.  Instead the new methods QThread::setEventDispatcher() and
QCoreApplication::setEventDispatcher() allow to install a custom event
dispatcher into any QThread as long as there is no default event dispatcher
created yet.  That is, before the thread has been started with
QThread::start() or, in case of the main thread, before QCoreApplication has
been instantiated.

Change-Id: I7367e13d8d8aebed5a5651260bb69b8818eb1b90
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2011-11-15 10:16:12 +01:00
Olivier Goffart
49bd825a96 moc: support mapping pointers to member functions to indexes
This change adds QMetaObject::IndexOfMethod as a parameter to
the qt_static_metacall function.
It lets the moc generated code return the index of a signal or slot
given its pointer to member function

This is required to support the new connection syntax

Change-Id: I39198c6699b5aa3599d3d282f7ac79b1e3684d33
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-11-14 15:52:26 +01:00
Jason McDonald
578e6d6834 Cleanup corelib autotests
Remove various disabled and/or non-helpful debugging code.

Any test diagnostics that are useful should be part of the regular test
output, as the CI system cannot switch on commented-out code when there
is a test failure.  Diagnostics should also be informative -- simply
printing the value of a variable with no other information about what is
being printed (or why it is being printed) is not informative.

Change-Id: I21a6c2121be86001bb57e80f426507b6e619ee9e
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-14 07:33:57 +01:00
Jason McDonald
3e0dece151 Remove commented code from qfuture test.
The removed code was already commented out when first added in November
2007 and is nowhere near compiling.  If there was anything of value
here, anyone who is able to find it is free to re-add a version that
actually works.

Change-Id: I4a7127a272254224f6a1e65fbd2a01000a4d2be9
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-11-14 05:15:04 +01:00
Jo Asplin
9563367af2 Re-enabled tst_qpluginloader
This test is passing in CI.

Task-number: QTBUG-21402
Change-Id: I356476e458cac1cd434959fdf801011a607c9233
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
2011-11-11 18:28:49 +01:00
Olivier Goffart
fd9ebabe14 Fix warning in tst_qobject
signal4 is not used in that function

Change-Id: I69f39a4639bfae067c411fd1166fc36ca3febbc5
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
2011-11-11 16:47:23 +01:00