Fix the crash when closing a document

Closes #14189. This commit partially reverts
626e6a1a70aeca40a3773f617a2cef0093991a75 and
95748f8f5eac02007b6f3def89f65fc2181aba09.
This commit is contained in:
xtemp09
2024-06-01 13:51:46 +07:00
committed by Chris Hennes
parent 0740d9a006
commit 70d9fe38b0
3 changed files with 5 additions and 25 deletions

View File

@@ -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<QuarterWidget*>(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()
{

View File

@@ -193,7 +193,6 @@ Q_SIGNALS:
private Q_SLOTS:
void replaceViewport();
virtual void aboutToDestroyGLContext();
protected:
void paintEvent(QPaintEvent*) override;

View File

@@ -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: