Skip to content

Commit

Permalink
CubeWidget: Fixed crash caused by not being in the correct context.
Browse files Browse the repository at this point in the history
  • Loading branch information
johanokl committed Mar 14, 2018
1 parent bd745cf commit f252b71
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gui/cubewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ CubeWidget::~CubeWidget()
{
// Make sure the context is current when deleting the texture
makeCurrent();
delete texture;
if (texture) {
delete texture;
}
arrayBuf.destroy();
indexBuf.destroy();
doneCurrent();
Expand Down Expand Up @@ -176,11 +178,16 @@ void CubeWidget::setTexture(const QPixmap &pixmap)
makeCurrent();
texture->release();
delete texture;
texture = 0;
textureUpdated = true;
}
if (!pixmap.isNull() && !pixmap.size().isEmpty()) {
makeCurrent();
texture = new QOpenGLTexture(pixmap.toImage().mirrored());
texture->setMinificationFilter(QOpenGLTexture::Nearest);
texture->setMagnificationFilter(QOpenGLTexture::Linear);
textureUpdated = true;
}
texture = new QOpenGLTexture(pixmap.toImage().mirrored());
texture->setMinificationFilter(QOpenGLTexture::Nearest);
texture->setMagnificationFilter(QOpenGLTexture::Linear);
textureUpdated = true;
}

/**
Expand Down

0 comments on commit f252b71

Please sign in to comment.