diff options
author | Paul Olav Tvete <paul.tvete@gmail.com> | 2015-05-05 13:28:13 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@gmail.com> | 2015-05-05 13:29:26 +0200 |
commit | 87752f4b48b78b59e06c641b76959e69bce51c32 (patch) | |
tree | 50873b22ce17b6449d1bfff5598673f96ced85a6 /src/gui/painting | |
parent | c05a8757b095cb554ea3e50f202a0683ca7d5bf7 (diff) |
Friedemann's crash fix
Don't delete the paint device after painting has started.
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qbackingstore.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 65a108f7ee..7b0a4e2ed4 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -118,31 +118,8 @@ QPaintDevice *QBackingStore::paintDevice() { QPaintDevice *device = d_ptr->platformBackingStore->paintDevice(); - // When QtGui is applying a high-dpi scale factor the backing store - // creates a "large" backing store image. This image needs to be - // painted on as a high-dpi image, which is done by setting - // devicePixelRatio. Do this on a separate image instance that shares - // the image data to avoid having the new devicePxielRatio be propagated - // back to the platform plugin. - if (QHighDpiScaling::isActive() && device->devType() == QInternal::Image) { - QImage *source = reinterpret_cast<QImage *>(device); - const bool needsNewImage = d_ptr->highDpiBackingstore.isNull() - || source->data_ptr() != d_ptr->highDpiBackingstore->data_ptr() - || source->size() != d_ptr->highDpiBackingstore->size() - || source->devicePixelRatio() != d_ptr->highDpiBackingstore->devicePixelRatio(); - if (needsNewImage) { - qCDebug(lcScaling) << "QBackingStore::paintDevice new backingstore for" << d_ptr->window; - qCDebug(lcScaling) << " source size" << source->size() << "dpr" << source->devicePixelRatio(); - d_ptr->highDpiBackingstore.reset( - new QImage(source->bits(), source->width(), source->height(), source->format())); - qreal targetDevicePixelRatio = d_ptr->window->devicePixelRatio(); - d_ptr->highDpiBackingstore->setDevicePixelRatio(targetDevicePixelRatio); - qCDebug(lcScaling) <<" destinaion size" << d_ptr->highDpiBackingstore->size() - << "dpr" << targetDevicePixelRatio; - } - + if (QHighDpiScaling::isActive() && device->devType() == QInternal::Image) return d_ptr->highDpiBackingstore.data(); - } return device; } @@ -185,6 +162,31 @@ void QBackingStore::beginPaint(const QRegion ®ion) if (d_ptr->highDpiBackingstore && d_ptr->highDpiBackingstore->devicePixelRatio() != d_ptr->window->devicePixelRatio()) resize(size()); + + // When QtGui is applying a high-dpi scale factor the backing store + // creates a "large" backing store image. This image needs to be + // painted on as a high-dpi image, which is done by setting + // devicePixelRatio. Do this on a separate image instance that shares + // the image data to avoid having the new devicePxielRatio be propagated + // back to the platform plugin. + QPaintDevice *device = d_ptr->platformBackingStore->paintDevice(); + if (QHighDpiScaling::isActive() && device->devType() == QInternal::Image) { + QImage *source = reinterpret_cast<QImage *>(device); + const bool needsNewImage = d_ptr->highDpiBackingstore.isNull() + || source->data_ptr() != d_ptr->highDpiBackingstore->data_ptr() + || source->size() != d_ptr->highDpiBackingstore->size() + || source->devicePixelRatio() != d_ptr->highDpiBackingstore->devicePixelRatio(); + if (needsNewImage) { + qCDebug(lcScaling) << "QBackingStore::beginPaint new backingstore for" << d_ptr->window; + qCDebug(lcScaling) << " source size" << source->size() << "dpr" << source->devicePixelRatio(); + d_ptr->highDpiBackingstore.reset( + new QImage(source->bits(), source->width(), source->height(), source->format())); + qreal targetDevicePixelRatio = d_ptr->window->devicePixelRatio(); + d_ptr->highDpiBackingstore->setDevicePixelRatio(targetDevicePixelRatio); + qCDebug(lcScaling) <<" destination size" << d_ptr->highDpiBackingstore->size() + << "dpr" << targetDevicePixelRatio; + } + } d_ptr->platformBackingStore->beginPaint(QHighDpi::toNativeLocalRegion(region, d_ptr->window)); } |