summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qobject.h')
-rw-r--r--src/corelib/kernel/qobject.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 27165cdcc3..3b8803c1a6 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -273,6 +273,33 @@ public:
{ return disconnect(this, 0, receiver, member); }
static bool disconnect(const QMetaObject::Connection &);
+ template <typename Func1, typename Func2>
+ static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
+ const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, Func2 slot)
+ {
+ typedef QtPrivate::FunctionPointer<Func1> SignalType;
+ typedef QtPrivate::FunctionPointer<Func2> SlotType;
+ reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
+
+ //compilation error if the arguments does not match.
+ typedef typename QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::IncompatibleSignalSlotArguments EnsureCompatibleArguments;
+ return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, reinterpret_cast<void **>(&slot),
+ &SignalType::Object::staticMetaObject);
+ }
+ template <typename Func1>
+ static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
+ const QObject *receiver, void **zero)
+ {
+ // This is the overload for when one wish to disconnect a signal from any slot. (slot=0)
+ // Since the function template parametter cannot be deduced from '0', we use a
+ // dummy void ** parametter that must be equal to 0
+ Q_ASSERT(!zero);
+ typedef QtPrivate::FunctionPointer<Func1> SignalType;
+ return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, zero,
+ &SignalType::Object::staticMetaObject);
+ }
+
+
void dumpObjectTree();
void dumpObjectInfo();
@@ -340,6 +367,7 @@ private:
QSlotObjectBase() : ref(1) {}
virtual ~QSlotObjectBase();
virtual void call(QObject *receiver, void **a) = 0;
+ virtual bool compare(void **);
};
// implementation of QSlotObjectBase for which the slot is a pointer to member function of a QObject
// Args and R are the List of arguments and the returntype of the signal to which the slot is connected.
@@ -351,6 +379,9 @@ private:
virtual void call(QObject *receiver, void **a) {
FuncType::template call<Args, R>(function, static_cast<typename FuncType::Object *>(receiver), a);
}
+ virtual bool compare(void **f) {
+ return *reinterpret_cast<Func *>(f) == function;
+ }
};
// implementation of QSlotObjectBase for which the slot is a static function
// Args and R are the List of arguments and the returntype of the signal to which the slot is connected.
@@ -378,6 +409,10 @@ private:
static QMetaObject::Connection connectImpl(const QObject *sender, void **signal, const QObject *receiver, QSlotObjectBase *slot,
Qt::ConnectionType type, const int *types, const QMetaObject *senderMetaObject);
+
+ static bool disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot,
+ const QMetaObject *senderMetaObject);
+
};
inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,