void MyGlWidget::initializeGL() {
try {
throw std::exception();
} catch(...) {
QMessageBox::critical(this, tr("Exception"),
tr("Exception occured"));
}
}
in catch() messagebox gezeigt, und die Ausführung geht in initializeGL() wieder, und zeigt ein zweites MeldungsfeldQMessageBox in initializeGL ruft initializeGL einen weiteres Mal
Ich versuche, dies über eine Bool zu vermeiden 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;
}
Aber das führt zum Absturz. Also beschloss ich, Fehler zu zeigen, in paintGL() (es zeigt auch 2 Message):
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()";
}
}
Dies löst das Problem aber den Code hässlich. Gibt es eine schönere Lösung für dieses Problem?
Qt4.7 VS2008