diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.co.uk> | 2010-12-24 20:57:25 +0200 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.co.uk> | 2010-12-25 11:41:53 +0200 |
commit | 6c56049ceba594fe8f0dbe59874c005ad8ecf403 (patch) | |
tree | 25c719eead2ebff16b5f5473886984a36862affd /tests/compilation | |
parent | 543f8667917e08e21a1ca696fede8dc232377c0e (diff) |
Implement a Qt-like signal connection/disconnection system.
Features:
* New QGlib::disconnect method that behaves more or less like QObject::disconnect.
* Automatic disconnection when either the sender or the receiver is destroyed
(this adds the limitation that the receiver must inherit QObject, for now)
* Future-proof. The exported methods are designed to be able to support
different forms of connection in the future (such as connecting an arbitrary
functor object instead of a member function). Support for different
types of receivers (i.e. ones that do not inherit QObject) is also there.
Other changes:
* Moved all the connect/disconnect related stuff in connect.{h,cpp}
* Removed the ugly SignalHandler class. QGlib::connect now returns bool.
Diffstat (limited to 'tests/compilation')
-rw-r--r-- | tests/compilation/CompilationTests.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/compilation/CompilationTests.cmake b/tests/compilation/CompilationTests.cmake index 0f0921e..b774af0 100644 --- a/tests/compilation/CompilationTests.cmake +++ b/tests/compilation/CompilationTests.cmake @@ -120,3 +120,47 @@ int main() ") ######### END RefPointer tests ######## +######### BEGIN disconnect tests ######## + +cxx_compilation_test(disconnect_full SHOULD_COMPILE " +#include <QGlib/Connect> + +int main() +{ + QGlib::disconnect(0, 0, 0, 0); + QGlib::disconnect(NULL, NULL, NULL, NULL); +} +") + +cxx_compilation_test(disconnect_default_args SHOULD_COMPILE " +#include <QGlib/Connect> + +int main() +{ + QGlib::disconnect(0, 0, 0); + QGlib::disconnect(0, 0); + QGlib::disconnect(0); +} +") + +cxx_compilation_test(disconnect_non_member_slot SHOULD_FAIL " +#include <QGlib/Connect> + +int foobar() {} + +int main() +{ + QGlib::disconnect(0, 0, 0, &foobar); +} +") + +cxx_compilation_test(disconnect_string_slot SHOULD_FAIL " +#include <QGlib/Connect> + +int main() +{ + QGlib::disconnect(0, 0, 0, \"hello world\"); +} +") + +######### END disconnect tests ######## |