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

TypeError after right mouse click #19

Open
mariansam opened this issue Dec 31, 2020 · 2 comments
Open

TypeError after right mouse click #19

mariansam opened this issue Dec 31, 2020 · 2 comments

Comments

@mariansam
Copy link

The program crashes after a right mouse click with the traceback

Traceback (most recent call last):
  File "/home/marian/.local/lib/python3.9/site-packages/grafatko/__init__.py", line 291, in mouseReleaseEvent
    pressed_vertices = self.graph.vertices_at_position(self.mouse.get_position())
  File "/home/marian/.local/lib/python3.9/site-packages/grafatko/graph.py", line 937, in vertices_at_position
    if vertex._get_weight_box(self.is_directed()).contains(*position):
  File "/home/marian/.local/lib/python3.9/site-packages/grafatko/graph.py", line 654, in _get_weight_box
    metrics = QFontMetrics(self.font)
TypeError: arguments did not match any overloaded call:
  QFontMetrics(QFont): argument 1 has unexpected type 'NoneType'
  QFontMetrics(QFont, QPaintDevice): argument 1 has unexpected type 'NoneType'
  QFontMetrics(QFontMetrics): argument 1 has unexpected type 'NoneType'

This happens with graphs of any size, I was able to make something like this before the crash:
pic-full-201231-1450-43

But it also crashed after right-clicking with something like this:
pic-full-201231-1443-14

The program was installed using pip3 install grafatko, defaulting to the user installation directory. Some info about the versions:

Version output

marian@thiccpad  ~$ pip show grafatko
Name: grafatko
Version: 0.2.5
Summary: An app for creating and visualizing graphs and graph-related algorithms.
Home-page: https://github.com/xiaoxiae/Grafatko
Author: Tomáš Sláma
Author-email: tomas@slama.dev
License: UNKNOWN
Location: /home/marian/.local/lib/python3.9/site-packages
Requires: pyqt5, qtmodern
Required-by:
marian@thiccpad  ~$ pip show pyqt5
Name: PyQt5
Version: 5.15.2
Summary: Python bindings for the Qt cross platform application toolkit
Home-page: https://www.riverbankcomputing.com/software/pyqt/
Author: Riverbank Computing Limited
Author-email: info@riverbankcomputing.com
License: GPL v3
Location: /home/marian/.local/lib/python3.9/site-packages
Requires: PyQt5-sip
Required-by: grafatko
marian@thiccpad  ~$ pip show PyQt5-sip
Name: PyQt5-sip
Version: 12.8.1
Summary: The sip module support for PyQt5
Home-page: https://www.riverbankcomputing.com/software/sip/
Author: Riverbank Computing Limited
Author-email: info@riverbankcomputing.com
License: SIP
Location: /home/marian/.local/lib/python3.9/site-packages
Requires:
Required-by: PyQt5
marian@thiccpad  ~$ pip show qtmodern
Name: qtmodern
Version: 0.2.0
Summary: Qt Widgets Modern User Interface
Home-page: https://www.github.com/gmarull/qtmodern
Author: Gerard Marull-Paretas
Author-email: gerardmarull@gmail.com
License: MIT
Location: /home/marian/.local/lib/python3.9/site-packages
Requires: qtpy
Required-by: grafatko
marian@thiccpad  ~$ pip show qtpy
Name: QtPy
Version: 1.9.0
Summary: Provides an abstraction layer on top of the various Qt bindings (PyQt5, PyQt4 and PySide) and additional custom QWidgets.
Home-page: https://github.com/spyder-ide/qtpy
Author: Colin Duquesnoy, The Spyder Development Team
Author-email: goanpeca@gmail.com
License: MIT
Location: /home/marian/.local/lib/python3.9/site-packages
Requires:
Required-by: qtmodern
marian@thiccpad  ~$ pip3 --version
pip 20.2.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)
marian@thiccpad  ~$ python3 --version
Python 3.9.0
marian@thiccpad  ~$

@xiaoxiae
Copy link
Owner

It seems that I'm not able to reproduce this on my machine. All of the versions check out, though.

Does this happen randomly, or every time you right click?

@mariansam
Copy link
Author

Yes, this happens pretty much randomly. Sometimes I can make a very long graph, but sometimes it crashes after few nodes. The weird thing is that I fount no evidence of self.font in graph.py:656 being None. I added the lines

        print("DOING METRICS")
        print(self.font if self.font is not None else "FONT IS NONE")

before the line metrics = QFontMetrics(self.font) and the end of the output says:

DOING METRICS
<PyQt5.QtGui.QFont object at 0x7f75e6ef4900>
DOING METRICS
<PyQt5.QtGui.QFont object at 0x7f75e6ef4580>
DOING METRICS
<PyQt5.QtGui.QFont object at 0x7f75e6ef43c0>Traceback (most recent call last):
  File "/home/marian/.local/lib/python3.9/site-packages/grafatko/__init__.py", line 291, in mouseReleaseEvent
    pressed_vertices = self.graph.vertices_at_position(self.mouse.get_position())
  File "/home/marian/.local/lib/python3.9/site-packages/grafatko/graph.py", line 939, in vertices_at_position
    if vertex._get_weight_box(self.is_directed()).contains(*position):
  File "/home/marian/.local/lib/python3.9/site-packages/grafatko/graph.py", line 656, in _get_weight_box
    metrics = QFontMetrics(self.font)
TypeError: arguments did not match any overloaded call:
  QFontMetrics(QFont): argument 1 has unexpected type 'NoneType'
  QFontMetrics(QFont, QPaintDevice): argument 1 has unexpected type 'NoneType'
  QFontMetrics(QFontMetrics): argument 1 has unexpected type 'NoneType'

So self.font is not None, but "NoneType TypeError" is still thrown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants