From 405894fc39cdab937c38b917adf4e8d390f80790 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 19 Sep 2011 00:11:24 +0200 Subject: [directfb] Make QDirectFBInput a QThread to allow proper exits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this patch the application will get stuck waiting for the IDFBEventBuffer to report an event. We will use the IDFBEventBuffer::WakeUp function to interrupt the waiting but this produces the below error on exit: QEventLoop: Cannot be used without QApplication QThread: Destroyed while thread is still running This is solved by making the QDirectFBInput a QThread, reimplement the run() method to handle the events. It should work as this is only posting events to the QApplication event loop. Change-Id: I24adf2b080f96c72ede6a5499f484ac33fdd44fc Reviewed-by: Jørgen Lind --- src/plugins/platforms/directfb/qdirectfbinput.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/plugins/platforms/directfb/qdirectfbinput.cpp') diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp index d05729b992..bedd3b8356 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.cpp +++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp @@ -50,35 +50,29 @@ #include -QDirectFbInput::QDirectFbInput(QObject *parent) - : QObject(parent), m_shouldStop(false) +QDirectFbInput::QDirectFbInput() + : m_dfbInterface(QDirectFbConvenience::dfbInterface()) + , m_shouldStop(false) { - m_dfbInterface = QDirectFbConvenience::dfbInterface(); - DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer); if (ok != DFB_OK) DirectFBError("Failed to initialise eventbuffer", ok); m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer); - } -void QDirectFbInput::runInputEventLoop() +void QDirectFbInput::run() { - while (true) { - m_eventBuffer->WaitForEvent(m_eventBuffer); - if (m_shouldStop) { - m_waitStop.release(); - break; - } - handleEvents(); + while (!m_shouldStop) { + if (m_eventBuffer->WaitForEvent(m_eventBuffer) == DFB_OK) + handleEvents(); } } void QDirectFbInput::stopInputEventLoop() { m_shouldStop = true; - m_waitStop.acquire(); + m_eventBuffer->WakeUp(m_eventBuffer); } void QDirectFbInput::addWindow(DFBWindowID id, QWindow *qt_window) -- cgit v1.2.3