Gui: Fix crash in QuarterWidgetP::removeFromCacheContext

Fixes #https://github.com/FreeCAD/FreeCAD/issues/14988
This commit is contained in:
wmayer
2024-06-27 18:35:40 +02:00
committed by wwmayer
parent 68ae1efde1
commit 6ed23c2e7d

View File

@@ -169,13 +169,22 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co
for (int i = 0; i < cachecontext_list->getLength(); i++) {
if ((*cachecontext_list)[i] == context) {
// set the context while calling destructingContext() (might trigger OpenGL calls)
const_cast<QtGLWidget*> (widget)->makeCurrent();
// fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818
(void) cc_glglue_instance(context->id);
QtGLContext* glcontext = widget->context();
if (glcontext) {
// set the context while calling destructingContext() (might trigger OpenGL calls)
if (glcontext->isValid()) {
const_cast<QtGLWidget*> (widget)->makeCurrent();
}
// fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818
(void) cc_glglue_instance(context->id);
}
cachecontext_list->removeFast(i);
SoContextHandler::destructingContext(context->id);
const_cast<QtGLWidget*> (widget)->doneCurrent();
if (glcontext) {
if (glcontext->isValid()) {
const_cast<QtGLWidget*> (widget)->doneCurrent();
}
}
delete context;
return;
}