/ src / lib /
/src/lib/qt_smoke.cpp
1 #include "cl_smoke_qt.h"
2
3 #include <qnamespace.h>
4 #include <QEvent>
5 #include <QtDebug>
6
7 /** @file
8 * @brief Qt support functions */
9
10 #include <exception>
11
12 static void
13 terminate()
14 {
15 qFatal("caught an exception.");
16 }
17
18 extern "C" {
19
20 /** Registers a callback to be invoked for every QEvent.
21 * @see QCoreApplication::notifyInternal
22 *
23 * @param callback the callback
24 *
25 * @return @c true on success and @c false otherwise
26 */
27 CL_SMOKE_QT_EXPORT int
28 cl_smoke_register_event_notify(void* callback)
29 {
30 Q_ASSERT(callback);
31 std::set_terminate(terminate);
32
33 return QInternal::registerCallback(QInternal::EventNotifyCallback,
34 reinterpret_cast<qInternalCallback>(callback));
35 }
36
37 /** Returns the most specific QMetaObject of the QObject instance @a object.
38 * Used to determine the actual class of an object. Smoke can not be used since it calls the
39 * metaObject() of the class the method was called for.
40 *
41 * @param object A QObject
42 *
43 * @return QMetaObject
44 */
45 CL_SMOKE_QT_EXPORT void*
46 cl_smoke_meta_object(void* object)
47 {
48 Q_ASSERT(object);
49 static_cast<QObject*>(object)->metaObject();
50 }
51
52
53 } // extern "C"