void MyGlWidget::initializeGL() {
try {
throw std::exception();
} catch(...) {
QMessageBox::critical(this, tr("Exception"),
tr("Exception occured"));
}
}
des prises() messagebox est affiché et l'exécution va à nouveau dans initializeGL(), et affiche une deuxième boîte de messageQMessageBox en appelle initializeGL initializeGL une fois de plus
J'essaie d'éviter ce via un bool variable:
void MyGlWidget::initializeGL() {
if(in_initializeGL_)
return;
in_initializeGL_ = true;
try {
throw std::exception();
} catch(...) {
QMessageBox::critical(this, tr("Exception"),
tr("Exception occured"));
}
in_initializeGL_ = false;
}
Mais cela conduit à un plantage. J'ai donc décidé de montrer l'erreur dans paintGL() (il montre aussi 2 MessageBoxes):
void MyGlWidget::paintGL() {
if(in_paintGL_)
return;
in_paintGL_ = true;
if (!exception_msg_.isEmpty()) {
QMessageBox::critical(this, tr("Exception"),
exception_msg_);
exception_msg_.clear();
}
// rendering stuff
in_paintGL_ = false;
}
void MyGlWidget::initializeGL() {
try {
throw std::exception();
} catch(...) {
exception_msg_ = "Exception in initializeGL()";
}
}
Cela résout le problème, mais le code laid. Y a-t-il une meilleure solution de ce problème?
Qt4.7 VS2008