summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Hautakangas <ext-jani.hautakangas@nokia.com>2010-08-09 06:47:31 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-09-02 06:32:44 (GMT)
commitbcb164e6f87192af849eec6f89a870d98d67767b (patch)
treea5598f1d99fff04695d5cd67e0fd91d7b492d2b1
parent592106653272bae16d80accdf71db7def49a6615 (diff)
downloadQt-bcb164e6f87192af849eec6f89a870d98d67767b.zip
Qt-bcb164e6f87192af849eec6f89a870d98d67767b.tar.gz
Qt-bcb164e6f87192af849eec6f89a870d98d67767b.tar.bz2
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 (cherry picked from commit d3ab1fccea2b1e011e7518269a29045a53f0a30b)
-rw-r--r--src/gui/kernel/qapplication_s60.cpp2
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp19
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h4
3 files changed, 9 insertions, 16 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index a14b1a7..c3824f9 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1067,7 +1067,7 @@ void QSymbianControl::Draw(const TRect& controlRect) const
if (QApplicationPrivate::runtime_graphics_system) {
QRuntimeWindowSurface *rtSurface =
static_cast<QRuntimeWindowSurface*>(qwidget->windowSurface());
- s60Surface = static_cast<QS60WindowSurface *>(rtSurface->m_windowSurface);
+ s60Surface = static_cast<QS60WindowSurface *>(rtSurface->m_windowSurface.data());
} else
#endif
s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface());
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index f670702..6db8bc4 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();
}
}
@@ -352,7 +350,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;
@@ -376,7 +374,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;
@@ -387,14 +384,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());
}
}
diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h
index d4c9152..0232241 100644
--- a/src/gui/painting/qgraphicssystem_runtime_p.h
+++ b/src/gui/painting/qgraphicssystem_runtime_p.h
@@ -129,8 +129,8 @@ public:
virtual QPoint offset(const QWidget *widget) const;
- QWindowSurface *m_windowSurface;
- QWindowSurface *m_pendingWindowSurface;
+ QScopedPointer<QWindowSurface> m_windowSurface;
+ QScopedPointer<QWindowSurface> m_pendingWindowSurface;
private:
const QRuntimeGraphicsSystem *m_graphicsSystem;