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
Fix crash when no GL context is available #11963
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b8e55a9
Fix use of m_openGlAvailable
daschuer 42ca663
Improve debug messages regarding the GL context
daschuer f720281
Remove unused and never initialized variable that may caused a crash …
daschuer 8e8c0f6
Initalize an uninitalized pointer.
daschuer 9d85061
Remove unused isContextSharing()
daschuer 851a6c4
Use QOpenGLContext to detect if OpenGL is available at all
daschuer 5544909
Introduce a new WaveformWidgetFactory::getSurfaceFormat() function to…
daschuer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
#include "mixxxmainwindow.h" | ||
|
||
#include <QDebug> | ||
#include <QDesktopServices> | ||
#include <QFileDialog> | ||
#include <QOpenGLContext> | ||
#include <QUrl> | ||
|
||
#include "widget/wglwidget.h" | ||
|
||
#ifdef MIXXX_USE_QOPENGL | ||
#include "widget/tooltipqopengl.h" | ||
#include "widget/winitialglwidget.h" | ||
#else | ||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
#include <QGLFormat> | ||
#endif | ||
|
||
#include <QUrl> | ||
#ifdef __LINUX__ | ||
#include <QtDBus> | ||
#endif | ||
#include <QtDebug> | ||
|
||
#include "widget/wglwidget.h" | ||
|
||
#ifdef MIXXX_USE_QOPENGL | ||
#include "widget/tooltipqopengl.h" | ||
#include "widget/winitialglwidget.h" | ||
#endif | ||
|
||
#include "dialog/dlgabout.h" | ||
#include "dialog/dlgdevelopertools.h" | ||
|
@@ -149,22 +152,36 @@ MixxxMainWindow::MixxxMainWindow(std::shared_ptr<mixxx::CoreServices> pCoreServi | |
|
||
#ifdef MIXXX_USE_QOPENGL | ||
void MixxxMainWindow::initializeQOpenGL() { | ||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
// Qt 6 will nno longer crash if no GL is available and | ||
// QGLFormat::hasOpenGL() has been removed. | ||
if (!CmdlineArgs::Instance().getSafeMode() && QGLFormat::hasOpenGL()) { | ||
#else | ||
if (!CmdlineArgs::Instance().getSafeMode()) { | ||
// This widget and its QOpenGLWindow will be used to query QOpenGL | ||
// information (version, driver, etc) in WaveformWidgetFactory. | ||
// The "SharedGLContext" terminology here doesn't really apply, | ||
// but allows us to take advantage of the existing classes. | ||
WInitialGLWidget* widget = new WInitialGLWidget(this); | ||
widget->setGeometry(QRect(0, 0, 3, 3)); | ||
SharedGLContext::setWidget(widget); | ||
// When the widget's QOpenGLWindow has been initialized, we continue | ||
// with the actual initialization | ||
connect(widget, &WInitialGLWidget::onInitialized, this, &MixxxMainWindow::initialize); | ||
widget->show(); | ||
// note: the format is set in the WGLWidget's OpenGLWindow constructor | ||
} else { | ||
initialize(); | ||
#endif | ||
QSurfaceFormat format; | ||
format.setVersion(2, 1); | ||
format.setProfile(QSurfaceFormat::CoreProfile); | ||
QOpenGLContext context; | ||
context.setFormat(format); | ||
if (context.create()) { | ||
// This widget and its QOpenGLWindow will be used to query QOpenGL | ||
// information (version, driver, etc) in WaveformWidgetFactory. | ||
// The "SharedGLContext" terminology here doesn't really apply, | ||
// but allows us to take advantage of the existing classes. | ||
WInitialGLWidget* widget = new WInitialGLWidget(this); | ||
widget->setGeometry(QRect(0, 0, 3, 3)); | ||
SharedGLContext::setWidget(widget); | ||
// When the widget's QOpenGLWindow has been initialized, we continue | ||
// with the actual initialization | ||
connect(widget, &WInitialGLWidget::onInitialized, this, &MixxxMainWindow::initialize); | ||
widget->show(); | ||
// note: the format is set in the WGLWidget's OpenGLWindow constructor | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment no longer applies since the context has been created earlier in the function |
||
} | ||
} | ||
// Initialize without OpenGL. | ||
initialize(); | ||
} | ||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, we had a single place where QSurfaceFormat was set (in OpenGLWindow constructor). Also, I liked going through an actual QOpenGLWindow creation to do the check. But I am okay with this change, especially because I agree with the eventual removal of the initial widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may consider to set the default format in a single place instead. But I was not sure about the implications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be easy enough to solve by just putting the QSurfaceFormat creation into a function that is called from both places, right?