From 6ce20b8d0fbee2f32c892943c80c3ed9aef2f866 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 2 Sep 2009 13:13:36 -0700 Subject: Make sure to release surface in ~DFBWindowSurface We don't want this surface to be released by QDirectFBScreen. It's always created without tracking. Also abstract the if (dfbSurface != primarySurface) things since we will use it from multiple functions. Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 20 ++++++++++++++++++++ .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index e288199..7abba81 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -100,6 +100,8 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect QDirectFBWindowSurface::~QDirectFBWindowSurface() { + releaseSurface(); + // these are not tracked by QDirectFBScreen so we don't want QDirectFBPaintDevice to release it } bool QDirectFBWindowSurface::isValid() const @@ -454,6 +456,24 @@ void QDirectFBWindowSurface::updateFormat() imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid; } +void QDirectFBWindowSurface::releaseSurface() +{ + if (dfbSurface) { +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (lockFlgs) + unlockSurface(); +#endif +#ifdef QT_NO_DIRECTFB_WM + Q_ASSERT(screen->primarySurface()); + if (dfbSurface != screen->primarySurface()) +#endif + + dfbSurface->Release(dfbSurface); + dfbSurface = 0; + } +} + + QT_END_NAMESPACE #endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index ca76613..edecb14 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -95,6 +95,7 @@ public: IDirectFBSurface *directFBSurface() const; private: void updateFormat(); + void releaseSurface(); QDirectFBWindowSurface *sibling; #ifdef QT_DIRECTFB_WM -- cgit v0.12