Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click/drag off screen crashes app #6

Open
banesullivan opened this issue Feb 12, 2020 · 5 comments
Open

Click/drag off screen crashes app #6

banesullivan opened this issue Feb 12, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@banesullivan
Copy link
Member

2020-02-11 21 02 20

Click the camera and drag off screen then a crash happens:

(dev) ➜  pyvista_gui git:(feat/expand) python -m pyvista_gui
DEBUG:pyvista_gui.gui:GUI initialized
DEBUG:matplotlib.pyplot:Loaded backend macosx version unknown.
DEBUG:matplotlib.pyplot:Loaded backend qt5agg version unknown.
DEBUG:matplotlib.pyplot:Loaded backend Qt5Agg version unknown.
DEBUG:asyncio:Using selector: KqueueSelector
Traceback (most recent call last):
  File "/Users/bane/anaconda3/envs/dev/lib/python3.7/site-packages/vtkmodules/qt/QVTKRenderWindowInteractor.py", line 474, in mouseMoveEvent
    ctrl, shift, chr(0), 0, None)
  File "/Users/bane/anaconda3/envs/dev/lib/python3.7/site-packages/vtkmodules/qt/QVTKRenderWindowInteractor.py", line 420, in _setEventInformation
    scale = self._getPixelRatio()
  File "/Users/bane/anaconda3/envs/dev/lib/python3.7/site-packages/vtkmodules/qt/QVTKRenderWindowInteractor.py", line 412, in _getPixelRatio
    return QApplication.devicePixelRatio()
TypeError: devicePixelRatio(self): first argument of unbound method must have type 'QGuiApplication'
[1]    37123 abort      python -m pyvista_gui
@banesullivan banesullivan added the bug Something isn't working label Feb 12, 2020
@akaszynski
Copy link
Member

This seems to be an internal, vtk error. We can override it or protect it with a super and catch the error.

@ali-zakaria
Copy link

I faced the same issue when using QVTKRenderWindowInteractor on a remote desktop, I opened an issue on VTK gitlab repo: https://gitlab.kitware.com/vtk/vtk/-/issues/17854

If anyone needs an urgent fix for this issue, this dirty workaround can do the job:

_getPixelRatio_BUG = QVTKRenderWindowInteractor._getPixelRatio
def _getPixelRatio_WORKAROUND(self):
	try:
		return _getPixelRatio_BUG()
	except Exception as err:
		print("Exception QVTKRenderWindowInteractor._getPixelRatio: {0}".format(err))
		return Qt.QApplication.instance().devicePixelRatio()
setattr(QVTKRenderWindowInteractor, '_getPixelRatio_WORKAROUND', _getPixelRatio_WORKAROUND)
QVTKRenderWindowInteractor._getPixelRatio = _getPixelRatio_WORKAROUND

I added these lines to my main function, right before calling app = Qt.QApplication(sys.argv)

@akaszynski
Copy link
Member

Nice fix @Zakaria220

@banesullivan, should we consider incorporating this into pyvista? Perhaps in qt_plotting? We can then conditionally add it for unpatched versions of vtk.

@banesullivan
Copy link
Member Author

Ah, that's a nifty little hack of a solution! Thanks, @Zakaria220!

@akaszynski: I'm all for adding it directly into pyvista and just overriding the method on our class rather than monkey-patching

@ali-zakaria
Copy link

VTK 9.0.0 has been released with a fix https://github.com/Kitware/VTK/releases/tag/v9.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants