Skip to content

Commit

Permalink
Fix QPixmap and OpenGL threading warnings when painting
Browse files Browse the repository at this point in the history
If the QPA supports threaded pixmaps, don't print out a message warning
the user about painting a pixmap in the non-main thread.
Likewise, if the QPA supports threaded OpenGL, don't print out a warning
when the user is about to paint on OpenGL from a non-main thread.

Change-Id: I5b4928ee49b1d6c1b638b036fade12dc794258df
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
  • Loading branch information
aleixpol authored and The Qt Project committed Jan 18, 2014
1 parent b095479 commit 446f9f2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gui/painting/qpainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "qglyphrun.h"

#include <qpa/qplatformtheme.h>
#include <qpa/qplatformintegration.h>

#include <private/qfontengine_p.h>
#include <private/qpaintengine_p.h>
Expand Down Expand Up @@ -155,7 +156,9 @@ static bool qt_painter_thread_test(int devType, const char *what)
// can be drawn onto these devices safely from any thread
break;
default:
if (QThread::currentThread() != qApp->thread()) {
if (QThread::currentThread() != qApp->thread()
&& (devType!=QInternal::Pixmap || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps))
&& (devType!=QInternal::OpenGL || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL))) {
qWarning("QPainter: It is not safe to use %s outside the GUI thread", what);
return false;
}
Expand Down

0 comments on commit 446f9f2

Please sign in to comment.