summaryrefslogtreecommitdiff
path: root/include/libcamera/signal.h
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-12 02:59:19 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-17 18:32:28 +0300
commitf83820a5d18bfdfa9853ef3ef71abfb47f626ac8 (patch)
tree3baab0b5ae1aa3f84a4b84d9861766daa77d9800 /include/libcamera/signal.h
parent0e65ed81453ce0ae8534b3fbc3f44a846d816910 (diff)
libcamera: bound_method: Decouple from Signal implementation
To make the BoundMethod classes more generic, replace direct access to private member from Signal classes with accessors or helper functions. This allows removal of friend statements from the BoundMethod classes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'include/libcamera/signal.h')
-rw-r--r--include/libcamera/signal.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/include/libcamera/signal.h b/include/libcamera/signal.h
index 3b6de30f..b8a60281 100644
--- a/include/libcamera/signal.h
+++ b/include/libcamera/signal.h
@@ -46,7 +46,9 @@ public:
~Signal()
{
for (BoundMethodBase *slot : slots_) {
- slot->disconnect(this);
+ Object *object = slot->object();
+ if (object)
+ object->disconnect(this);
delete slot;
}
}
@@ -95,11 +97,11 @@ public:
/*
* If the object matches the slot, the slot is
* guaranteed to be a member slot, so we can safely
- * cast it to BoundMemberMethod<T, Args...> and access its
- * func_ member.
+ * cast it to BoundMemberMethod<T, Args...> to match
+ * func.
*/
if (slot->match(obj) &&
- static_cast<BoundMemberMethod<T, Args...> *>(slot)->func_ == func) {
+ static_cast<BoundMemberMethod<T, Args...> *>(slot)->match(func)) {
iter = slots_.erase(iter);
delete slot;
} else {
@@ -113,7 +115,7 @@ public:
for (auto iter = slots_.begin(); iter != slots_.end(); ) {
BoundMethodArgs<Args...> *slot = *iter;
if (slot->match(nullptr) &&
- static_cast<BoundStaticMethod<Args...> *>(slot)->func_ == func) {
+ static_cast<BoundStaticMethod<Args...> *>(slot)->match(func)) {
iter = slots_.erase(iter);
delete slot;
} else {