Skip to content

Commit

Permalink
talipot-gui/GlWidget: Fix segfault when not embeded in a graphics item
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert committed Nov 23, 2023
1 parent 647d8fb commit 0706a36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion library/talipot-gui/include/talipot/GlWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ class TLP_QT_SCOPE GlWidget : public QOpenGLWidget {
// devicePixelRatio() must be overridden because the inherited QWidget
// method always returns 1 when the widget is no attached to a window
qreal devicePixelRatio() const {
return _windows->devicePixelRatio();
if (_windows) {
return _windows->devicePixelRatio();
} else {
return QOpenGLWidget::devicePixelRatio();
}
}

private:
Expand Down
2 changes: 1 addition & 1 deletion library/talipot-gui/src/GlWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GlWidget::GlWidget(QWidget *parent, View *view)
// windows attached to it, making device pixel ratio value unreliable so we
// grab a pointer to the adequate main window to override the implementation
// of the devicePixelRatio method
_windows = window()->windowHandle() ? window() : getMainWindow();
_windows = window()->windowHandle() ? nullptr : getMainWindow();
}
//==================================================
GlWidget::~GlWidget() {
Expand Down

0 comments on commit 0706a36

Please sign in to comment.