From 01590c3f780598572b3a18decefed55ae8e51059 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 22 Mar 2020 00:52:28 +0200 Subject: qcam: Remove custom event dispatcher The qcam application installs a custom event dispatcher based on the Qt event loop. As the camera manager now creates an internal thread, it doesn't use that event dispatcher of the application thread at all. Furthermore, the custom event dispatcher is buggy, as it doesn't dispatch messages posted to the main thread's event loop. This isn't an issue as no messages are posted there in the first place, but would cause incorrect behaviour if we were to use that feature (for instance to deliver signals from the camera manager thread to the application thread). Fixing the event dispatcher requires a change in the libcamera public API, as there's currently no way to dispatch messages using the public API (Thread::dispatchMessages() is not exposed). This isn't worth it at the moment, so just remove the custom event dispatcher. If qcam later needs the libcamera request and buffer completion signals to be delivered in the application thread, it will need to handle that internally, using Qt's cross-thread signal delivery. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/qcam/qt_event_dispatcher.h | 62 ------------------------------------------ 1 file changed, 62 deletions(-) delete mode 100644 src/qcam/qt_event_dispatcher.h (limited to 'src/qcam/qt_event_dispatcher.h') diff --git a/src/qcam/qt_event_dispatcher.h b/src/qcam/qt_event_dispatcher.h deleted file mode 100644 index b0f123e5..00000000 --- a/src/qcam/qt_event_dispatcher.h +++ /dev/null @@ -1,62 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * qt_event_dispatcher.h - qcam - Qt-based event dispatcher - */ -#ifndef __QCAM_QT_EVENT_DISPATCHER_H__ -#define __QCAM_QT_EVENT_DISPATCHER_H__ - -#include - -#include - -using namespace libcamera; - -class QSocketNotifier; - -class QtEventDispatcher final : public EventDispatcher, public QObject -{ -public: - QtEventDispatcher(); - ~QtEventDispatcher(); - - void registerEventNotifier(EventNotifier *notifier); - void unregisterEventNotifier(EventNotifier *notifier); - - void registerTimer(Timer *timer); - void unregisterTimer(Timer *timer); - - void processEvents(); - - void interrupt(); - -protected: - void timerEvent(QTimerEvent *event); - -private: - void readNotifierActivated(int socket); - void writeNotifierActivated(int socket); - void exceptionNotifierActivated(int socket); - - struct NotifierPair { - NotifierPair() - : notifier(nullptr), qnotifier(nullptr) - { - } - EventNotifier *notifier; - QSocketNotifier *qnotifier; - }; - - struct NotifierSet { - NotifierPair read; - NotifierPair write; - NotifierPair exception; - }; - - std::map notifiers_; - std::map timers_; - std::map timerIds_; -}; - -#endif /* __QCAM_QT_EVENT_DISPATCHER_H__ */ -- cgit v1.2.1