Why are there two contexts instead of one?
-
I've been fighting a bug for some amount of time. I singled it out eventually, it was OpenGLContext related, but I still don't understand why this is happening.
I was going to load my OpenGL textures later with a QAction trigger, instead of during initGL, but there was a context change in the middle for a reason unknown to me. I suppose I can set current context manually, but there's only a single OpenGLWidget instance in the entire program and I don't know why this is happening.
Custom signal that fires at InitGL:
ui.textureWidget->view()->sig_Start.connect([&]() { cout << "start" << endl; cout << QOpenGLContext::currentContext() << endl; cout << ui.textureWidget->view()->context() << endl; });QAction that is triggered later (much after initGL) on a key press:
connect(action, &QAction::triggered, [&](bool) { cout << "trigger" << endl; cout << QOpenGLContext::currentContext() << endl; cout << ui.textureWidget->view()->context() << endl; });Output:
start 000002571DA62C00 000002571DA62C00 trigger 000002571EA88700 <- ?? 000002571DA62C00Why does this happen? The only OpenGLWidget I use is one wrapped in another widget added to a QMainWindow. Why is there a context change in the middle and what is that other context?