From 70d9fe38b0c377f750a2bec4f26e12225630d0e6 Mon Sep 17 00:00:00 2001 From: xtemp09 Date: Sat, 1 Jun 2024 13:51:46 +0700 Subject: [PATCH] Fix the crash when closing a document Closes #14189. This commit partially reverts 626e6a1a70aeca40a3773f617a2cef0093991a75 and 95748f8f5eac02007b6f3def89f65fc2181aba09. --- src/Gui/Quarter/QuarterWidget.cpp | 27 ++++----------------------- src/Gui/Quarter/QuarterWidget.h | 1 - src/Gui/View3DInventorViewer.h | 2 +- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index 7ad5a46ec5..1162a837e2 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -164,9 +164,8 @@ public: #endif setFormat(surfaceFormat); } - ~CustomGLWidget() override - { - } + ~CustomGLWidget() override = default; + void initializeGL() override { QOpenGLContext *context = QOpenGLContext::currentContext(); @@ -179,10 +178,7 @@ public: logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); } #endif - if (context) { - connect(context, &QOpenGLContext::aboutToBeDestroyed, - this, &CustomGLWidget::aboutToDestroyGLContext, Qt::DirectConnection); - } + connect(this, &CustomGLWidget::resized, this, &CustomGLWidget::slotResized); } // paintGL() is invoked when e.g. using the method grabFramebuffer of this class @@ -200,17 +196,7 @@ public: qw->redraw(); } } - void aboutToDestroyGLContext() - { - // With Qt 5.9 a signal is emitted while the QuarterWidget is being destroyed. - // At this state its type is a QWidget, not a QuarterWidget any more. - QuarterWidget* qw = qobject_cast(parent()); - if (!qw) - return; - QMetaObject::invokeMethod(parent(), "aboutToDestroyGLContext", - Qt::DirectConnection, - QGenericReturnArgument()); - } + bool event(QEvent *e) override { // If a debug logger is activated then Qt's default implementation @@ -334,11 +320,6 @@ QuarterWidget::replaceViewport() viewport()->setAutoFillBackground(false); } -void -QuarterWidget::aboutToDestroyGLContext() -{ -} - /*! destructor */ QuarterWidget::~QuarterWidget() { diff --git a/src/Gui/Quarter/QuarterWidget.h b/src/Gui/Quarter/QuarterWidget.h index 5b50cac0cf..fdce8b3ab7 100644 --- a/src/Gui/Quarter/QuarterWidget.h +++ b/src/Gui/Quarter/QuarterWidget.h @@ -193,7 +193,6 @@ Q_SIGNALS: private Q_SLOTS: void replaceViewport(); - virtual void aboutToDestroyGLContext(); protected: void paintEvent(QPaintEvent*) override; diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index d212525b96..5d0e2597ab 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -490,7 +490,7 @@ private: static void drawArrow(); static void drawSingleBackground(const QColor&); void setCursorRepresentation(int mode); - void aboutToDestroyGLContext() override; + void aboutToDestroyGLContext(); void createStandardCursors(double); private: