summaryrefslogtreecommitdiff
path: root/test/event.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-27 04:41:05 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-02 01:16:45 +0300
commit3f662ae3c0c6e6564f1abe09d7d297e34f77b4fb (patch)
tree6fa7a3f6bc35c1b2e723f6c50a25b554c86cf820 /test/event.cpp
parent58720e1dc98186e79ef4e758a851b58df562f7b4 (diff)
libcamera: Don't use emitter object pointer argument to slot
In many cases, the emitter object passed as a pointer from signals to slots is also available as a class member. Use the class member when this occurs, to prepare for removal of the emitter object pointer from signals. In test/event.cpp, this additionally requires moving the EventNotifier to a class member. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'test/event.cpp')
-rw-r--r--test/event.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/event.cpp b/test/event.cpp
index c2274344..e338335c 100644
--- a/test/event.cpp
+++ b/test/event.cpp
@@ -22,14 +22,16 @@ using namespace libcamera;
class EventTest : public Test
{
protected:
- void readReady(EventNotifier *notifier)
+ void readReady([[maybe_unused]] EventNotifier *notifier)
{
- size_ = read(notifier->fd(), data_, sizeof(data_));
+ size_ = read(notifier_->fd(), data_, sizeof(data_));
notified_ = true;
}
int init()
{
+ notifier_ = nullptr;
+
return pipe(pipefd_);
}
@@ -40,8 +42,8 @@ protected:
Timer timeout;
ssize_t ret;
- EventNotifier readNotifier(pipefd_[0], EventNotifier::Read);
- readNotifier.activated.connect(this, &EventTest::readReady);
+ notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read);
+ notifier_->activated.connect(this, &EventTest::readReady);
/* Test read notification with data. */
memset(data_, 0, sizeof(data_));
@@ -76,7 +78,7 @@ protected:
/* Test read notifier disabling. */
notified_ = false;
- readNotifier.setEnabled(false);
+ notifier_->setEnabled(false);
ret = write(pipefd_[1], data.data(), data.size());
if (ret < 0) {
@@ -95,7 +97,7 @@ protected:
/* Test read notifier enabling. */
notified_ = false;
- readNotifier.setEnabled(true);
+ notifier_->setEnabled(true);
timeout.start(100);
dispatcher->processEvents();
@@ -111,6 +113,8 @@ protected:
void cleanup()
{
+ delete notifier_;
+
close(pipefd_[0]);
close(pipefd_[1]);
}
@@ -118,6 +122,7 @@ protected:
private:
int pipefd_[2];
+ EventNotifier *notifier_;
bool notified_;
char data_[16];
ssize_t size_;