Commit f65c72b1 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Try to improve the opengl crash detection

A driver would likely crash either in the constructor or in the
paint code. Let's wrap both in a try/success block.
parent f43abe43
......@@ -762,18 +762,6 @@ bool KisDlgPreferences::editPreferences()
#endif
#ifdef HAVE_OPENGL
if (dialog->m_displaySettings->cbUseOpenGL->isChecked() && cfg.canvasState() == "OPENGL_NOT_TRIED") {
cfg.setCanvasState("TRY_OPENGL");
}
if (dialog->m_displaySettings->cbUseOpenGL->isChecked() && cfg.canvasState() == "OPENGL_FAILED") {
if (KMessageBox::warningYesNo(0, i18n("You are trying to enable OpenGL\n\n"
"But Krita might have had problems with the OpenGL canvas before,\n"
"either because of driver issues, or because of issues with window effects.\n\n"
"Are you sure you want to enable OpenGL?\n"), i18n("Krita")) == KMessageBox::Yes) {
cfg.setCanvasState("TRY_OPENGL");
}
}
cfg.setUseOpenGL(dialog->m_displaySettings->cbUseOpenGL->isChecked());
cfg.setUseOpenGLTextureBuffer(dialog->m_displaySettings->chkUseTextureBuffer->isChecked());
cfg.setOpenGLFilteringMode(dialog->m_displaySettings->cmbFilterMode->currentIndex());
......
......@@ -368,6 +368,7 @@ void KisConfig::setRenderIntent(qint32 renderIntent) const
bool KisConfig::useOpenGL() const
{
if (qApp->applicationName() == "krita" ) {
qDebug() << "use opengl" << m_cfg.readEntry("useOpenGL", true) << "success" << m_cfg.readEntry("canvasState", "OPENGL_SUCCESS");
QString canvasState = m_cfg.readEntry("canvasState", "OPENGL_SUCCESS");
return (m_cfg.readEntry("useOpenGL", true) && (canvasState == "OPENGL_SUCCESS"));
}
......
......@@ -70,13 +70,13 @@
#define PROGRAM_VERTEX_ATTRIBUTE 0
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
static bool OPENGL_SUCCESS = false;
namespace
{
const GLuint NO_PROGRAM = 0;
}
static int openGLFrames = 0;
struct KisOpenGLCanvas2::Private
{
public:
......@@ -170,6 +170,7 @@ KisOpenGLCanvas2::KisOpenGLCanvas2(KisCanvas2 *canvas, KisCoordinatesConverter *
d->openGLImageTextures->generateCheckerTexture(createCheckersImage(cfg.checkSize()));
cfg.writeEntry("canvasState", "OPENGL_SUCCESS");
}
KisOpenGLCanvas2::~KisOpenGLCanvas2()
......@@ -228,6 +229,11 @@ void KisOpenGLCanvas2::resizeGL(int width, int height)
void KisOpenGLCanvas2::paintGL()
{
if (!OPENGL_SUCCESS) {
KisConfig cfg;
cfg.writeEntry("canvasState", "OPENGL_PAINT_STARTED");
}
renderCanvasGL();
QPainter gc(this);
......@@ -240,12 +246,10 @@ void KisOpenGLCanvas2::paintGL()
d->glSyncObject = Sync::getSync();
if (openGLFrames == 5) {
if (!OPENGL_SUCCESS) {
KisConfig cfg;
cfg.writeEntry("canvasState", "OPENGL_SUCCESS");
}
else {
openGLFrames++;
OPENGL_SUCCESS = true;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment