scenes/opengl: Properly destroy backend if initialization fails
SceneOpenGL takes the ownership of the backend. So, if the scene fails to initialize, the backend will be deleted twice.
This commit is contained in:
parent
2b1d709b04
commit
8b3e999fbf
1 changed files with 3 additions and 5 deletions
|
@ -444,7 +444,7 @@ void SceneOpenGL::initDebugOutput()
|
|||
|
||||
SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
|
||||
{
|
||||
OpenGLBackend *backend = kwinApp()->platform()->createOpenGLBackend();
|
||||
QScopedPointer<OpenGLBackend> backend(kwinApp()->platform()->createOpenGLBackend());
|
||||
if (!backend) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -452,13 +452,12 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
|
|||
backend->init();
|
||||
}
|
||||
if (backend->isFailed()) {
|
||||
delete backend;
|
||||
return nullptr;
|
||||
}
|
||||
SceneOpenGL *scene = nullptr;
|
||||
// first let's try an OpenGL 2 scene
|
||||
if (SceneOpenGL2::supported(backend)) {
|
||||
scene = new SceneOpenGL2(backend, parent);
|
||||
if (SceneOpenGL2::supported(backend.data())) {
|
||||
scene = new SceneOpenGL2(backend.take(), parent);
|
||||
if (scene->initFailed()) {
|
||||
delete scene;
|
||||
scene = nullptr;
|
||||
|
@ -472,7 +471,6 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
|
|||
qCCritical(KWIN_OPENGL) << "To overwrite the detection use the environment variable KWIN_COMPOSE";
|
||||
qCCritical(KWIN_OPENGL) << "For more information see https://community.kde.org/KWin/Environment_Variables#KWIN_COMPOSE";
|
||||
}
|
||||
delete backend;
|
||||
}
|
||||
|
||||
return scene;
|
||||
|
|
Loading…
Reference in a new issue