Skip to content

Commit

Permalink
GUI apps: fix issues with progressbar with Qt >= 5.4
Browse files Browse the repository at this point in the history
This is likely to be a recurring problem. Basically, Qt 5.4's
OpenGLWidget now shares its context with the rest of the GUI. What this
means is that updating the progressbar (i.e. a different window
altogether, with a different context) during a screen update changes the
current context, and subsequent operations in the screen update happen
in the wrong context. This tries to catch that situation and handle it
appropriately.

Note that there is also the issue that updating the progressbar
inherently causes Qt to process all events, which I think causes it to
issue a new update for the main OpenGL window, which is itself already
in the middle of an update. This causes this message to appear:

    QWidget::repaint: Recursive repaint detected

It doesn't seem to harm actual operation, but we may need to refactor
things to avoid this type of problem.
  • Loading branch information
jdtournier committed Jul 2, 2015
1 parent 4e01024 commit fddc9a1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gui/dialog/progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,30 @@ namespace MR

void display (ProgressInfo& p)
{
QOpenGLContext* context = QOpenGLContext::currentContext();
QSurface* surface = context->surface();

if (!p.data) {
INFO (App::NAME + ": " + p.text);
p.data = new QProgressDialog (p.text.c_str(), "Cancel", 0, p.multiplier ? 100 : 0);
reinterpret_cast<QProgressDialog*> (p.data)->setWindowModality (Qt::WindowModal);
}
reinterpret_cast<QProgressDialog*> (p.data)->setValue (p.value);

context->makeCurrent (surface);
}


void done (ProgressInfo& p)
{
QOpenGLContext* context = QOpenGLContext::currentContext();
QSurface* surface = context->surface();

INFO (App::NAME + ": " + p.text + " [done]");
delete reinterpret_cast<QProgressDialog*> (p.data);
p.data = NULL;
p.data = nullptr;

context->makeCurrent (surface);
}

}
Expand Down

0 comments on commit fddc9a1

Please sign in to comment.