diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2011-09-19 00:57:45 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-21 16:54:45 +0200 |
commit | 500dc2a6f888e283c6d40730bdf7c2998ee0437b (patch) | |
tree | eb1803d6ac87fb68f211fb2ffadd59cff805c0dc /src/plugins/platforms/directfb/qdirectfbinput.cpp | |
parent | 405894fc39cdab937c38b917adf4e8d390f80790 (diff) |
[directfb] Introduce the QDirectFBPointer from QWS/gfxdrivers
Introduce QDirectFBPointer and use it throughout the code to
fix various resource leaks in the DirectFB backend. Fix the surface
ownership of the IDirectFBSurface in the Blittable/BackingStore
code.
Change-Id: I0d4572eaab80b3558e644f26d76222461bf37bbb
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/platforms/directfb/qdirectfbinput.cpp')
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbinput.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp index bedd3b8356..1bc4b85233 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.cpp +++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp @@ -54,17 +54,17 @@ QDirectFbInput::QDirectFbInput() : m_dfbInterface(QDirectFbConvenience::dfbInterface()) , m_shouldStop(false) { - DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer); + DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface, m_eventBuffer.outPtr()); if (ok != DFB_OK) DirectFBError("Failed to initialise eventbuffer", ok); - m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer); + m_dfbInterface->GetDisplayLayer(m_dfbInterface, DLID_PRIMARY, m_dfbDisplayLayer.outPtr()); } void QDirectFbInput::run() { while (!m_shouldStop) { - if (m_eventBuffer->WaitForEvent(m_eventBuffer) == DFB_OK) + if (m_eventBuffer->WaitForEvent(m_eventBuffer.data()) == DFB_OK) handleEvents(); } } @@ -72,33 +72,33 @@ void QDirectFbInput::run() void QDirectFbInput::stopInputEventLoop() { m_shouldStop = true; - m_eventBuffer->WakeUp(m_eventBuffer); + m_eventBuffer->WakeUp(m_eventBuffer.data()); } void QDirectFbInput::addWindow(DFBWindowID id, QWindow *qt_window) { m_tlwMap.insert(id,qt_window); - IDirectFBWindow *window; - m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window); + QDirectFBPointer<IDirectFBWindow> window; + m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer.data(), id, window.outPtr()); - window->AttachEventBuffer(window,m_eventBuffer); + window->AttachEventBuffer(window.data(), m_eventBuffer.data()); } void QDirectFbInput::removeWindow(WId wId) { - IDirectFBWindow *window; - m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,wId, &window); + QDirectFBPointer<IDirectFBWindow> window; + m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer.data(), wId, window.outPtr()); - window->DetachEventBuffer(window,m_eventBuffer); + window->DetachEventBuffer(window.data(), m_eventBuffer.data()); m_tlwMap.remove(wId); } void QDirectFbInput::handleEvents() { - DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer); + DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer.data()); while(hasEvent == DFB_OK){ DFBEvent event; - DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer,&event); + DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer.data(), &event); if (ok != DFB_OK) DirectFBError("Failed to get event",ok); if (event.clazz == DFEC_WINDOW) { @@ -124,7 +124,7 @@ void QDirectFbInput::handleEvents() } - hasEvent = m_eventBuffer->HasEvent(m_eventBuffer); + hasEvent = m_eventBuffer->HasEvent(m_eventBuffer.data()); } } @@ -134,16 +134,16 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) QPoint globalPos = globalPoint(event); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - IDirectFBWindow *window; - layer->GetWindow(layer,event.window.window_id,&window); + QDirectFBPointer<IDirectFBDisplayLayer> layer(QDirectFbConvenience::dfbDisplayLayer()); + QDirectFBPointer<IDirectFBWindow> window; + layer->GetWindow(layer.data(), event.window.window_id, window.outPtr()); long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); if (event.window.type == DWET_BUTTONDOWN) { - window->GrabPointer(window); + window->GrabPointer(window.data()); } else if (event.window.type == DWET_BUTTONUP) { - window->UngrabPointer(window); + window->UngrabPointer(window.data()); } QWindow *tlw = m_tlwMap.value(event.window.window_id); QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); @@ -192,10 +192,10 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const { - IDirectFBWindow *window; - m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,event.window.window_id,&window); + QDirectFBPointer<IDirectFBWindow> window; + m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer.data() , event.window.window_id, window.outPtr()); int x,y; - window->GetPosition(window,&x,&y); + window->GetPosition(window.data(), &x, &y); return QPoint(event.window.cx +x, event.window.cy + y); } |