summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qgraphicssystem_runtime.cpp
diff options
context:
space:
mode:
authorJani Hautakangas <ext-jani.hautakangas@nokia.com>2010-08-09 09:47:31 +0300
committerJani Hautakangas <ext-jani.hautakangas@nokia.com>2010-08-09 14:18:31 +0300
commitd3ab1fccea2b1e011e7518269a29045a53f0a30b (patch)
treec943227221aa71748cb823b078cd29dbee67da4e /src/gui/painting/qgraphicssystem_runtime.cpp
parent54f87eae767f38d35829e8413ad99649c26b6324 (diff)
Pending surface might not get destroyed if no flush() happens
in between graphics system change. This patch ensures that all old surfaces are destroyed before new graphics system is activated. Reviewed-by: Jason Barron
Diffstat (limited to 'src/gui/painting/qgraphicssystem_runtime.cpp')
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index be04df6df6..e1e0ad0f1b 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -251,7 +251,7 @@ QPixmapData* QRuntimePixmapData::runtimeData() const
}
QRuntimeWindowSurface::QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, QWidget *window)
- : QWindowSurface(window), m_windowSurface(0), m_pendingWindowSurface(0), m_graphicsSystem(gs)
+ : QWindowSurface(window), m_graphicsSystem(gs)
{
}
@@ -259,7 +259,6 @@ QRuntimeWindowSurface::QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, Q
QRuntimeWindowSurface::~QRuntimeWindowSurface()
{
m_graphicsSystem->removeWindowSurface(this);
- delete m_windowSurface;
}
QPaintDevice *QRuntimeWindowSurface::paintDevice()
@@ -278,8 +277,7 @@ void QRuntimeWindowSurface::flush(QWidget *widget, const QRegion &region,
#ifdef QT_DEBUG
qDebug() << "QRuntimeWindowSurface::flush() - destroy pending window surface";
#endif
- delete m_pendingWindowSurface;
- m_pendingWindowSurface = 0;
+ m_pendingWindowSurface.reset();
}
}
@@ -355,7 +353,7 @@ QWindowSurface *QRuntimeGraphicsSystem::createWindowSurface(QWidget *widget) con
{
Q_ASSERT(m_graphicsSystem);
QRuntimeWindowSurface *rtSurface = new QRuntimeWindowSurface(this, widget);
- rtSurface->m_windowSurface = m_graphicsSystem->createWindowSurface(widget);
+ rtSurface->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
widget->setWindowSurface(rtSurface);
m_windowSurfaces << rtSurface;
return rtSurface;
@@ -379,7 +377,6 @@ void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
for (int i = 0; i < m_pixmapDatas.size(); ++i) {
QRuntimePixmapData *proxy = m_pixmapDatas.at(i);
QPixmapData *newData = m_graphicsSystem->createPixmapData(proxy->m_data);
- // ### TODO Optimize. Openvg and s60raster graphics systems could switch internal ARGB32_PRE QImage buffers.
newData->fromImage(proxy->m_data->toImage(), Qt::NoOpaqueDetection);
delete proxy->m_data;
proxy->m_data = newData;
@@ -390,14 +387,10 @@ void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
QRuntimeWindowSurface *proxy = m_windowSurfaces.at(i);
QWidget *widget = proxy->m_windowSurface->window();
- if(m_windowSurfaceDestroyPolicy == DestroyImmediately) {
- delete proxy->m_windowSurface;
- proxy->m_pendingWindowSurface = 0;
- } else {
- proxy->m_pendingWindowSurface = proxy->m_windowSurface;
- }
+ if(m_windowSurfaceDestroyPolicy == DestroyAfterFirstFlush)
+ proxy->m_pendingWindowSurface.reset(proxy->m_windowSurface.take());
- proxy->m_windowSurface = m_graphicsSystem->createWindowSurface(widget);
+ proxy->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
qt_widget_private(widget)->invalidateBuffer(widget->rect());
}
}