summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r--src/gui/image/qpixmap.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 474cd2e..21216f8 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -635,17 +635,21 @@ void QPixmap::resize_helper(const QSize &s)
if (size() == s)
return;
+ // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
+ // the actual underlaying runtime pixmap data.
+ QPixmapData *pd = pixmapData();
+
// Create new pixmap
- QPixmap pm(QSize(w, h), data ? data->type : QPixmapData::PixmapType);
+ QPixmap pm(QSize(w, h), pd ? pd->type : QPixmapData::PixmapType);
bool uninit = false;
#if defined(Q_WS_X11)
- QX11PixmapData *x11Data = data && data->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(data.data()) : 0;
+ QX11PixmapData *x11Data = pd && pd->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(pd) : 0;
if (x11Data) {
pm.x11SetScreen(x11Data->xinfo.screen());
uninit = x11Data->flags & QX11PixmapData::Uninitialized;
}
#elif defined(Q_WS_MAC)
- QMacPixmapData *macData = data && data->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data.data()) : 0;
+ QMacPixmapData *macData = pd && pd->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
if (macData)
uninit = macData->uninit;
#endif
@@ -659,7 +663,7 @@ void QPixmap::resize_helper(const QSize &s)
#if defined(Q_WS_X11)
if (x11Data && x11Data->x11_mask) {
- QX11PixmapData *pmData = static_cast<QX11PixmapData*>(pm.data.data());
+ QX11PixmapData *pmData = static_cast<QX11PixmapData*>(pd);
pmData->x11_mask = (Qt::HANDLE)XCreatePixmap(X11->display,
RootWindow(x11Data->xinfo.display(),
x11Data->xinfo.screen()),
@@ -1163,8 +1167,9 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
Qt::HANDLE QPixmap::handle() const
{
#if defined(Q_WS_X11)
- if (data && data->classId() == QPixmapData::X11Class)
- return static_cast<const QX11PixmapData*>(data.constData())->handle();
+ const QPixmapData *pd = pixmapData();
+ if (pd && pd->classId() == QPixmapData::X11Class)
+ return static_cast<const QX11PixmapData*>(pd)->handle();
#endif
return 0;
}
@@ -1944,17 +1949,20 @@ void QPixmap::detach()
if (!data)
return;
- QPixmapData::ClassId id = data->classId();
+ // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
+ // the actual underlaying runtime pixmap data.
+ QPixmapData *pd = pixmapData();
+ QPixmapData::ClassId id = pd->classId();
if (id == QPixmapData::RasterClass) {
- QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data.data());
+ QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(pd);
rasterData->image.detach();
}
if (data->is_cached && data->ref == 1)
- QImagePixmapCleanupHooks::executePixmapDataModificationHooks(data.data());
+ QImagePixmapCleanupHooks::executePixmapDataModificationHooks(pd);
#if defined(Q_WS_MAC)
- QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data.data()) : 0;
+ QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
if (macData) {
if (macData->cg_mask) {
CGImageRelease(macData->cg_mask);
@@ -1969,8 +1977,8 @@ void QPixmap::detach()
++data->detach_no;
#if defined(Q_WS_X11)
- if (data->classId() == QPixmapData::X11Class) {
- QX11PixmapData *d = static_cast<QX11PixmapData*>(data.data());
+ if (pd->classId() == QPixmapData::X11Class) {
+ QX11PixmapData *d = static_cast<QX11PixmapData*>(pd);
d->flags &= ~QX11PixmapData::Uninitialized;
// reset the cache data
@@ -2060,9 +2068,15 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
*/
QPixmapData* QPixmap::pixmapData() const
{
- return data.data();
+ if (data) {
+ QPixmapData* pm = data.data();
+ return pm->runtimeData() ? pm->runtimeData() : pm;
+ }
+
+ return 0;
}
+
/*!
\enum QPixmap::HBitmapFormat