Unsolved QQuickWidget grab() Exception
-
I'm struggling with an exception which is generated when I call the
grab()
function of aQQuickWidget
.The application in question may be running for an hour or so before this exception is raised.
I have a QML Map item which I'm rendering in a
QQuickWidget
. For reasons I won't go into here, I have tograb()
the contents of this widget and render it manually into anotherQWidget
, which is ultimately my main "map" display. This all runs perfectly for a good while until the exception kicks in.The code in question is this:
// Grab the map widget QPixmap map = m_map->grab(); //### exception raised here // Draw the map image painter->drawPixmap(0, 0, map);
The following bug report is actually pretty close to what I'm doing in my application, even though the exception generated is different:
https://bugreports.qt.io/browse/QTBUG-62887
Any clues how I could go about managing this exception or actually figuring out why it is generated in the first place? My assumption is that I'm trying to grab the framebuffer which is not yet ready for grabbing, so is there any way of performing a check in the first place which would allow me to determine if the framebuffer is ready?
For reference, the call stack at the time of exception looks like this...
1 DrvPresentBuffers atioglxx 0x5a333b13 2 DrvPresentBuffers atioglxx 0x5997ec6d 3 DrvPresentBuffers atioglxx 0x599dc478 4 DrvPresentBuffers atioglxx 0x599dbc2b 5 DrvPresentBuffers atioglxx 0x599dc7ad 6 DrvPresentBuffers atioglxx 0x5995e777 7 DrvPresentBuffers atioglxx 0x590b3fae 8 DrvPresentBuffers atioglxx 0x59455467 9 glReadPixels opengl32 0x5d2699e8 10 QOpenGLFunctions::glReadPixels qopenglfunctions.h 967 0x273036f 11 qt_gl_read_framebuffer_rgba8 qopenglframebufferobject.cpp 1282 0x2a82d0c 12 qt_gl_read_framebuffer qopenglframebufferobject.cpp 1312 0x2a82e9e 13 qt_gl_read_framebuffer qopenglframebufferobject.cpp 1329 0x2a82fe4 14 QQuickRenderControl::grab qquickrendercontrol.cpp 389 0x1f1d7d5 15 QQuickWidgetPrivate::grabFramebuffer qquickwidget.cpp 364 0x6cb969fb 16 QWidgetPrivate::drawWidget qwidget.cpp 5603 0x64ba32b5 17 QWidgetPrivate::render qwidget.cpp 5759 0x64ba2ad5 18 QWidget::grab qwidget.cpp 5251 0x64b95951 19 ChartWidget::drawMap ChartWidget.cpp 435 0x93cbcd 20 ChartWidget::paintEvent ChartWidget.cpp 380 0x93ca30 21 QWidget::event qwidget.cpp 9053 0x64b9c047 22 QApplicationPrivate::notify_helper qapplication.cpp 3732 0x64b59eab 23 QApplication::notify qapplication.cpp 3695 0x64b57ffe 24 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1050 0x666778cc 25 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 237 0x66799168 26 QWidgetPrivate::sendPaintEvent qwidget.cpp 5679 0x64ba36df 27 QWidgetPrivate::drawWidget qwidget.cpp 5623 0x64ba3363 28 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5815 0x64ba3a6a 29 QWidgetPrivate::drawWidget qwidget.cpp 5673 0x64ba368d 30 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5815 0x64ba3a6a 31 QWidgetPrivate::drawWidget qwidget.cpp 5673 0x64ba368d 32 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5815 0x64ba3a6a 33 QWidgetPrivate::drawWidget qwidget.cpp 5673 0x64ba368d 34 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5815 0x64ba3a6a 35 QWidgetPrivate::drawWidget qwidget.cpp 5673 0x64ba368d 36 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5815 0x64ba3a6a 37 QWidgetPrivate::drawWidget qwidget.cpp 5673 0x64ba368d 38 QWidgetBackingStore::doSync qwidgetbackingstore.cpp 1378 0x64b6cca9 39 QWidgetBackingStore::sync qwidgetbackingstore.cpp 1157 0x64b6aba7 40 QWidgetPrivate::syncBackingStore qwidget.cpp 1953 0x64ba53a1 41 QWidget::event qwidget.cpp 9217 0x64b9c515 42 QMainWindow::event qmainwindow.cpp 1343 0x64d33ee2 43 QApplicationPrivate::notify_helper qapplication.cpp 3732 0x64b59eab 44 QApplication::notify qapplication.cpp 3695 0x64b57ffe 45 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1050 0x666778cc 46 QCoreApplication::sendEvent qcoreapplication.h 234 0x66680b59 47 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1740 0x66678ca9 48 QEventDispatcherWin32::sendPostedEvents qeventdispatcher_win.cpp 1084 0x66711cf4 49 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 82 0x6a75af0 50 qt_internal_proc qeventdispatcher_win.cpp 239 0x66710313 51 AddClipboardFormatListener USER32 0x7670be6b 52 DispatchMessageW USER32 0x7670833a 53 DispatchMessageW USER32 0x76707bee 54 DispatchMessageW USER32 0x767079d0 55 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 630 0x66710ab9 56 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 74 0x6a75ac8 57 QEventLoop::processEvents qeventloop.cpp 135 0x66672d1c 58 QEventLoop::exec qeventloop.cpp 212 0x66672f27 59 QCoreApplication::exec qcoreapplication.cpp 1338 0x66675aa2 60 QGuiApplication::exec qguiapplication.cpp 1688 0x26c4878 61 QApplication::exec qapplication.cpp 2918 0x64b55e09 62 main main.cpp 54 0x8e321c 63 WinMain qtmain_win.cpp 104 0xb9279d 64 invoke_main exe_common.inl 99 0xb8fa7e 65 __scrt_common_main_seh exe_common.inl 253 0xb8f900 66 __scrt_common_main exe_common.inl 296 0xb8f79d 67 WinMainCRTStartup exe_winmain.cpp 17 0xb8fa98 68 BaseThreadInitThunk KERNEL32 0x752f8484 69 RtlValidSecurityDescriptor ntdll 0x770e2fea 70 RtlValidSecurityDescriptor ntdll 0x770e2fba
UPDATE
I've managed to get a mini crash dump from the computer running the application. When I open and debug the crash dump in Visual Studio, it gives slightly more useful call stack:ucrtbase.dll!_abort() Unknown user32.dll!SystemParametersInfoW() Unknown 090a4030() Unknown [Frames below may be incorrect and/or missing] [External Code] Qt5Gui.dll!QImageTextureGlyphCache::fillTexture(const QTextureGlyphCache::Coord & c, unsigned int g, QFixed subPixelPosition) Line 324 C++ Qt5Gui.dll!QTextureGlyphCache::fillInPendingGlyphs() Line 256 C++ Qt5Gui.dll!QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const unsigned int * glyphs, const QFixedPoint * positions, QFontEngine * fontEngine) Line 2830 C++ Qt5Gui.dll!QRasterPaintEngine::drawTextItem(const QPointF & p, const QTextItem & textItem) Line 3082 C++ Qt5Gui.dll!QPainterPrivate::drawTextItem(const QPointF & p, const QTextItem & _ti, QTextEngine * textEngine) Line 6517 C++ Qt5Gui.dll!QTextLine::draw(QPainter * p, const QPointF & pos, const QTextLayout::FormatRange * selection) Line 2618 C++ Qt5Gui.dll!qt_format_text(const QFont & fnt, const QRectF & _r, int tf, const QTextOption * option, const QString & str, QRectF * brect, int tabstops, int * ta, int tabarraylen, QPainter * painter) Line 7645 C++ Qt5Gui.dll!QPainter::drawText(const QRect & r, int flags, const QString & str, QRect * br) Line 5939 C++ Qt5Gui.dll!QPainter::drawText(int x, int y, int w, int h, int flags, const QString & str, QRect * br) Line 887 C++ Qt5Gui.dll!QPainter::setRenderHints(QFlags<enum QPainter::RenderHint> hints, bool on) Line 7116 C++
So from this, can I assume that the rogue function is the
drawText
function from the bottom of the call stack? ThesetRenderHints
looks like is a red-herring.