I've cargo-culted some code to render text over a QOpenGLWidget from another project:
void MyWidget::paintEvent(QPaintEvent* event) { QOpenGLWidget::paintEvent(event); auto const& text = /* elided */; QPainter painter{this}; painter.setPen(Qt::white); painter.setFont(font()); painter.drawText(rect(), Qt::AlignCenter, text); painter.end(); } In the "donor" project, this works fine, but the "recipient" project is crashing on exit: ==12997== Invalid read of size 8 ==12997== at 0x5D204E4: QObject::thread() const (qobject.cpp:1420) ==12997== by 0x598A728: QOpenGLVertexArrayObjectPrivate::destroy() (qopenglvertexarrayobject.cpp:212) ==12997== by 0x598A9AA: QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() (qopenglvertexarrayobject.cpp:392) ==12997== by 0x5987286: QOpenGLTextureGlyphCache::~QOpenGLTextureGlyphCache() (qopengltextureglyphcache.cpp:87) ==12997== by 0x59872AC: QOpenGLTextureGlyphCache::~QOpenGLTextureGlyphCache() (qopengltextureglyphcache.cpp:93) ==12997== by 0x576ADAB: ~QLinkedListNode (qlinkedlist.h:69) ==12997== by 0x576ADAB: QLinkedList<QFontEngine::GlyphCacheEntry>::freeData(QLinkedListData*) [clone .isra.119] (qlinkedlist.h:345) ==12997== by 0x5BB10E8: QHashData::free_helper(void (*)(QHashData::Node*)) (qhash.cpp:572) ==12997== by 0x576A9BA: freeData (qhash.h:585) ==12997== by 0x576A9BA: ~QHash (qhash.h:254) ==12997== by 0x576A9BA: QFontEngine::~QFontEngine() (qfontengine.cpp:271) ==12997== by 0x18C155FC: QFontEngineFT::~QFontEngineFT() (qfontengine_ft.cpp:794) ==12997== by 0x576AAE4: QFontEngineMulti::~QFontEngineMulti() (qfontengine.cpp:1792) ==12997== by 0x18C1E41C: QFontEngineMultiFontConfig::~QFontEngineMultiFontConfig() (qfontenginemultifontconfig.cpp:57) ==12997== by 0x575F25E: QFontCache::clear() (qfont.cpp:2796) ==12997== Address 0x8 is not stack'd, malloc'd or (recently) free'd Any ideas why? Is this a reasonable approach to rendering text in a QOpenGLWidget, or is there a better way? (I am "fairly confident" that the problem is the text rendering, above, since the crash goes away if I comment out said code.) -- Matthew _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest