diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-01-28 13:30:38 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-01-28 13:31:50 (GMT) |
commit | 77dadcc0824ba4c4900f6f3e3290772800ec1719 (patch) | |
tree | c7c79e1979dc73a5d8683a285a8facd648c9426c /src/plugins/graphicssystems | |
parent | 8733fcea9b9d9d587733613ee116549af0b5f8b5 (diff) | |
download | Qt-77dadcc0824ba4c4900f6f3e3290772800ec1719.zip Qt-77dadcc0824ba4c4900f6f3e3290772800ec1719.tar.gz Qt-77dadcc0824ba4c4900f6f3e3290772800ec1719.tar.bz2 |
Minimaldfb: Making sure removing tlw doesn't cause crash
Diffstat (limited to 'src/plugins/graphicssystems')
6 files changed, 63 insertions, 66 deletions
diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 8809536..8e288ba 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -42,8 +42,17 @@ void InputSocketWaiter::run() m_cleanupMutex.unlock(); } -QDirectFbInput::QDirectFbInput(QObject *parent) - : QObject(parent) +QDirectFbInput *QDirectFbInput::instance() +{ + static QDirectFbInput *input = 0; + if (!input) { + input = new QDirectFbInput(); + } + return input; +} + +QDirectFbInput::QDirectFbInput() + : QObject() { dfbInterface = QDirectFbConvenience::dfbInterface(); @@ -68,6 +77,18 @@ void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) window->AttachEventBuffer(window,eventBuffer); } +void QDirectFbInput::removeWindow(QWidget *tlw) +{ + DFBWindowID id = tlwMap.key(tlw,0); + if (id) { + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); + + window->DetachEventBuffer(window,eventBuffer); + tlwMap.remove(id); + } +} + void QDirectFbInput::handleEvents() { DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 74ccee2..31aa082 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -33,15 +33,16 @@ class QDirectFbInput : public QObject { Q_OBJECT public: - QDirectFbInput(QObject *parent = 0); - + static QDirectFbInput *instance(); void addWindow(DFBWindowID id, QWidget *tlw); + void removeWindow(QWidget *tlw); public slots: void handleEvents(); void applicationEnd(); private: + QDirectFbInput(); void handleMouseEvents(const DFBEvent &event); void handleWheelEvent(const DFBEvent &event); diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 06ae800..4489e31 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) - :QGraphicsSystemScreen() , m_input(this) + :QGraphicsSystemScreen() { m_layer = QDirectFbConvenience::dfbDisplayLayer(display); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); @@ -64,56 +64,19 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) m_layer->GetConfiguration(m_layer, &config); m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); - qDebug() << QDirectFbConvenience::pixelFomatHasAlpha(config.pixelformat); - qDebug() << QDirectFbConvenience::colorDepthForSurface(config.pixelformat); - qDebug() << "GraphcisSystemScreen has format: " << m_format; m_geometry = QRect(0,0,config.width,config.height); const int dpi = 72; const qreal inch = 25.4; m_depth = 32; m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); + + cursor = new QDirectFBCursor(this); } QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() { } -IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, QWidget *tlw) -{ - IDirectFBWindow *window; - - DFBWindowDescription description; - memset(&description,0,sizeof(DFBWindowDescription)); - description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS -#if DIRECTFB_MINOR_VERSION >= 1 - |DWDESC_OPTIONS -#endif - |DWDESC_CAPS); - description.width = rect.width(); - description.height = rect.height(); - description.posx = rect.x(); - description.posy = rect.y(); -#if DIRECTFB_MINOR_VERSION >= 1 - description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); -#endif - description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); - description.surface_caps = DSCAPS_PREMULTIPLIED; - - DFBResult result = m_layer->CreateWindow(m_layer,&description,&window); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); - } - - DFBWindowID id; - window->GetID(window, &id); - m_input.addWindow(id,tlw); - - cursor = new QDirectFBCursor(this); - - return window; -} - - QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() { const QStringList args = QCoreApplication::arguments(); @@ -130,9 +93,6 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() } delete[] argv; - //init directfb - QDirectFbConvenience::dfbInterface(); - mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); mScreens.append(mPrimaryScreen); } @@ -147,7 +107,7 @@ QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType ty QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const { - return new QDirectFbWindowSurface (mPrimaryScreen, widget); + return new QDirectFbWindowSurface (widget); } QBlittable *QDirectFbGraphicsSystem::createBlittable(const QRect &rect) const diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index 892bc58..b16153d 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -63,16 +63,12 @@ public: QImage::Format format() const { return m_format; } QSize physicalSize() const { return m_physicalSize; } - IDirectFBWindow *createWindow(const QRect &,QWidget *tlw); - public: QRect m_geometry; int m_depth; QImage::Format m_format; QSize m_physicalSize; - QDirectFbInput m_input; - IDirectFBDisplayLayer *m_layer; private: diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 1cb33f7..9a424cd 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -49,23 +49,43 @@ QT_BEGIN_NAMESPACE -QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), m_screen(screen), m_pixmap(0), m_pmdata(0), +QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) + : QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbWindow(0), m_dfbSurface(0) { window->setWindowSurface(this); - m_dfbWindow = m_screen->createWindow(window->rect(),window); - m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - DFBSurfaceCapabilities caps; - m_dfbSurface->GetCapabilities(m_dfbSurface, &caps); - DFBSurfacePixelFormat format; - m_dfbSurface->GetPixelFormat(m_dfbSurface, &format); - qDebug() << QDirectFbConvenience::pixelFomatHasAlpha(format); - qDebug() << QDirectFbConvenience::colorDepthForSurface(format); - qDebug() << "WindowSurface format " << QDirectFbConvenience::imageFormatFromSurfaceFormat(format,caps); + DFBWindowDescription description; + memset(&description,0,sizeof(DFBWindowDescription)); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS +#if DIRECTFB_MINOR_VERSION >= 1 + |DWDESC_OPTIONS +#endif + |DWDESC_CAPS); + description.width = window->rect().width(); + description.height = window->rect().height(); + description.posx = window->rect().x(); + description.posy = window->rect().y(); +#if DIRECTFB_MINOR_VERSION >= 1 + description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); +#endif + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); + description.surface_caps = DSCAPS_PREMULTIPLIED; + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); + } + + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + QDirectFbInput::instance()->addWindow(id,window); + + m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); m_pmdata->setBlittable(blitter); @@ -76,6 +96,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc QDirectFbWindowSurface::~QDirectFbWindowSurface() { + QDirectFbInput::instance()->removeWindow(this->window()); } QPaintDevice *QDirectFbWindowSurface::paintDevice() diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index f74fb29..f6d48c6 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -54,8 +54,7 @@ class QDirectFbGraphicsSystemScreen; class QDirectFbWindowSurface : public QWindowSurface { public: - QDirectFbWindowSurface - (QDirectFbGraphicsSystemScreen *screen, QWidget *window); + QDirectFbWindowSurface(QWidget *window); ~QDirectFbWindowSurface(); QPaintDevice *paintDevice(); @@ -74,7 +73,6 @@ public: private: void lockSurfaceToImage(); - QDirectFbGraphicsSystemScreen *m_screen; QPixmap *m_pixmap; QBlittablePixmapData *m_pmdata; |