Commit 15bacdea authored by Alexander Stukowski's avatar Alexander Stukowski

Fixed program crash due to unhandled exception in case OpenGL initialization fails

parent 20549614
Pipeline #26484262 failed with stage
in 25 minutes and 43 seconds
......@@ -71,9 +71,15 @@ void ViewportsPanel::onViewportConfigurationReplaced(ViewportConfiguration* newV
if(newViewportConfiguration) {
// Create windows for the new viewports.
for(Viewport* vp : newViewportConfiguration->viewports()) {
OVITO_ASSERT(vp->window() == nullptr);
ViewportWindow* viewportWindow = new ViewportWindow(vp, this);
try {
for(Viewport* vp : newViewportConfiguration->viewports()) {
OVITO_ASSERT(vp->window() == nullptr);
ViewportWindow* viewportWindow = new ViewportWindow(vp, this);
}
}
catch(const Exception& ex) {
ex.reportError(true);
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
}
// Repaint the viewport borders when another viewport has been activated.
......@@ -175,7 +181,6 @@ void ViewportsPanel::layoutViewports()
if(!_viewportConfig) return;
const QVector<Viewport*>& viewports = _viewportConfig->viewports();
Viewport* maximizedViewport = _viewportConfig->maximizedViewport();
OVITO_ASSERT(viewports.size() == findChildren<QWidget*>().size());
// Count the number of visible windows.
int nvisible = 0;
......
......@@ -38,15 +38,17 @@ namespace Ovito { OVITO_BEGIN_INLINE_NAMESPACE(Gui) OVITO_BEGIN_INLINE_NAMESPACE
* Constructor.
******************************************************************************/
ViewportWindow::ViewportWindow(Viewport* owner, QWidget* parentWidget) : QOpenGLWidget(parentWidget),
_viewport(owner), _updateRequested(false),
_viewport(owner),
_updateRequested(false),
_mainWindow(MainWindow::fromDataset(owner->dataset())),
_renderDebugCounter(0), _cursorInContextMenuArea(false)
_renderDebugCounter(0),
_cursorInContextMenuArea(false)
{
setMouseTracking(true);
setFocusPolicy(Qt::ClickFocus);
// Determine OpenGL vendor string so other parts of the code can decide
// which OpenGL features are save to use.
// which OpenGL features are safe to use.
OpenGLSceneRenderer::determineOpenGLInfo();
// Associate the viewport with this window.
......
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