diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-05-05 15:54:10 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-05 22:22:41 +0200 |
commit | 31091808814de383aeec453933d2b29ce4eefb6f (patch) | |
tree | 0e5bba075082036a08a64f5437347bb9b048efc7 /src/gui | |
parent | 9e2c4bc67f30eb1e8d776afe3a092d5994aaab38 (diff) |
Avoid showing warnings from drawPixmap when using a QGLWidget
QGLWidget has a paint device type of Widget, yet drawing on it
from outside the gui thread is fine as long as ThreadedOpenGL is
supported. It has probably been overlooked that the device type
OpenGL applies to QGLFramebufferObject and such but not QGLWidget.
This will fix the problem of flooding the output with warnings in
the tst_qglthreads autotest and potentially elsewhere too.
Task-number: QTBUG-38771
Change-Id: Ie014a2610a0db41b31c30c404e286d4997aecdc3
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index fe5fc051df..3f387d575b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -147,8 +147,9 @@ static inline uint line_emulation(uint emulation) } #ifndef QT_NO_DEBUG -static bool qt_painter_thread_test(int devType, const char *what) +static bool qt_painter_thread_test(int devType, int engineType, const char *what) { + const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); switch (devType) { case QInternal::Image: case QInternal::Printer: @@ -157,8 +158,13 @@ static bool qt_painter_thread_test(int devType, const char *what) break; default: if (QThread::currentThread() != qApp->thread() - && (devType!=QInternal::Pixmap || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) - && (devType!=QInternal::OpenGL || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL))) { + // pixmaps cannot be targets unless threaded pixmaps are supported + && (devType != QInternal::Pixmap || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedPixmaps)) + // framebuffer objects and such cannot be targets unless threaded GL is supported + && (devType != QInternal::OpenGL || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) + // widgets cannot be targets except for QGLWidget + && (devType != QInternal::Widget || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL) + || (engineType != QPaintEngine::OpenGL && engineType != QPaintEngine::OpenGL2))) { qWarning("QPainter: It is not safe to use %s outside the GUI thread", what); return false; } @@ -5054,7 +5060,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()"); #endif if (d->extended) { @@ -5125,7 +5131,7 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) if (!d->engine || pm.isNull()) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()"); #endif qreal x = r.x(); @@ -6610,7 +6616,7 @@ void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPo return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()"); + qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawTiledPixmap()"); #endif qreal sw = pixmap.width(); |