Skip to content

Crash when using QOpenGLWidget/QOpenGLWindow inside a dock together with QWebEngineView #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
martbelko opened this issue Apr 4, 2025 · 4 comments

Comments

@martbelko
Copy link

Issue Description

When using OpenGL (QOpenGLWidget or QOpenGLWindow) within the Qt Advanced Docking System alongside QWebEngineView, the application crashes under specific reordering conditions.

This happens when there is a stack of five widgets with an OpenGL-based widget in the middle and QWebEngineView at the bottom. If a widget below the OpenGL widget is dragged across the OpenGL widget and docked to the top, and then the OpenGL widget is docked above, the application crashes.

Steps to Reproduce

  1. Create a dock layout with a stack of five dock widgets.
  2. Insert a QOpenGLWidget or QOpenGLWindow in the middle of the stack.
  3. Add a QWebEngineView as the bottom-most widget.
  4. Drag the widget immediately below the OpenGL widget upward across it and dock it to the top.
  5. Then drag the OpenGL widget and dock it above the previous one.

Environment

  • Operating System: [Windows 11]
  • Qt Version: [6.5.3]
  • OpenGL Version: [4.6]
  • Qt-Advanced-Docking-System Version: [latest]

Demo

Image

Minimal Reproducible Example:

#include <QApplication>
#include <QOpenGLWidget>
#include <QMainWindow>
#include <QtWebEngineWidgets>

#include <DockManager.h>

class MainWindow : public QMainWindow
{
public:
	MainWindow()
	{
		m_DockManager = new ads::CDockManager(this);

		QWebEngineView* w1 = new QWebEngineView();
		QWebEngineView* w2 = new QWebEngineView();
		QOpenGLWidget* glWidget = new QOpenGLWidget();
		QWidget* w3 = new QWidget();
		QWidget* w4 = new QWidget();

		ads::CDockWidget* dw1 = new ads::CDockWidget("WebView 1");
		dw1->setWidget(w1);
		ads::CDockWidget* dw2 = new ads::CDockWidget("Widget 1");
		dw2->setWidget(w2);
		ads::CDockWidget* glDw = new ads::CDockWidget("OpenGL");
		glDw->setWidget(glWidget);
		ads::CDockWidget* dw3 = new ads::CDockWidget("Widget 2");
		dw3->setWidget(w3);
		ads::CDockWidget* dw4 = new ads::CDockWidget("Widget 3");
		dw4->setWidget(w4);

		m_DockManager->addDockWidget(ads::TopDockWidgetArea, dw1);
		m_DockManager->addDockWidget(ads::TopDockWidgetArea, dw2);
		m_DockManager->addDockWidget(ads::TopDockWidgetArea, glDw);
		m_DockManager->addDockWidget(ads::TopDockWidgetArea, dw3);
		m_DockManager->addDockWidget(ads::TopDockWidgetArea, dw4);
	}
private:
	ads::CDockManager* m_DockManager;
};

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);
	MainWindow window;

	window.show();

	return app.exec();
}
@githubuser0xFFFF
Copy link
Owner

Could you please check if the pull request #727 improves something for you?

@martbelko
Copy link
Author

No, it is still the same.

@zyrkiel
Copy link

zyrkiel commented Apr 15, 2025

You should inherit from QOpenGLWidget in order to manage with the OpenGL context.
See my GLWidget class in the mentionned PR.

First create a cleanup with at least these lines:


void GLWidget::cleanup()
{
    makeCurrent();
    doneCurrent();
    QObject::disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &GLWidget::cleanup);
}

Then you must override initializeGL in order to connect the cleanup to the QOpenGLContext::aboutToBeDestroyed signal:
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &GLWidget::cleanup, Qt::UniqueConnection);

Please try these modifications with the ADS version of my PR. Could you also try my OpenGL example to see if you can reproduce this issue with my example?

@martbelko
Copy link
Author

Unfortunately, the issue still persists. I was able to reproduce the crash using the GLWidget class exactly as you described. Additionally, in the OpenGL example, if you start docking the OpenGL widgets randomly, then close some of them and exit the application, an error appears indicating that the OpenGLChartWidget destructor was already called.

Furthermore, I tried adding two QWebEngineView instances into the OpenGL example, and by docking them around each other in various configurations, I encountered the same type of crash as before. It seems that the problem is triggered by dynamic docking behavior involving OpenGL or WebEngine components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants