QWebEngineView->render() throws nullptr exception
-
Hello everyone, having a Qt 5.15.5 that was built for x86, Windows, QWebEngineView and QGraphicsScene (used for off-screen rendering)
Rendering a QWebEngineView by render() method, and everything works-as-designed.
But, in some undefined scenarios, it throws some nullpointer exception within QOpenGLFunctions::glReadPixels: a pixels is nullptr.
I think that's may be a some strange bug that should be fixed, passing some screenshots of exception points
Point first: calling QGraphicsScene render() method
And then the point where exception happens
88e528e7-c9b9-40bd-a6c5-4ad41d63236d-image.pngIf you need a full call stack then I can provide it, the only problem is that this exception happens not always, once in 35-40 minutes i guess
-
Hi @ANorton,
I could be wrong (not at all familiar with Qt's painters, graphics scenes, and OpenGL) but try removing the
this
from theQPainter
's constructor.Typically, Qt's
QObject
-derived classed accept otherQObject
-derived classes (such as yourmain_window
) to set a parent-child relationship for chained destruction, which is great! :) So its not at all surprising to see you using the common pattern of constructing a Qt class withthis
.However,
QPainter
is notQObject
-derived, and is not using this typical Qt "parent" pattern. According to the docs, the QPainter(QPaintDevice *device) constructor that you are using:Constructs a painter that begins painting the paint device immediately.
In other words, its a convenient overload that automatically invokes
QPainter::begin(this)
(on construction) andQPainter::end()
(on destruction).Since you're using the graphics scene to paint, I think that you're meant to use the QPainter() constructor, so that the graphics scene can handle the operation completely its own way.
Anyway, it's just a hunch, but worth a try :)
Cheers.