Graphcanvas crashes Leo

81 views
Skip to first unread message

lewis

unread,
Oct 22, 2016, 12:11:49 AM10/22/16
to leo-editor
Crash leo completely using the Graph tab enabled via the graphcanvas plugin.

Select a node in the graph display, select the colour block icon ('set the background colour of the selected node') Leo instantly crashes.
However if I first select the node in the graph pane, drag it around to reposition it in the pane, then select the colour block, the colour change panel launches as expected and I can change colours.

And further - I just discovered a crash occurs if you just select any icons in lower icon bar (select/locate/remove/shapes/colour block/ text colour or Clear formatting)

Here is the console:

Leo 5.4-b1, Sat Oct 22 09:30:16 2016
Git commit: a3718c36
Python 3.5.2, PyQt version 5.7.0
Windows 10 AMD64 (build 10.0.14393) SP0
reading settings in N:\leo\DServe_Eff_Filters.leo
wrote recent file: C:\Users\lewis\.leo\.leoRecentFiles.txt
reading settings in N:\leo\DServe_Eff_Filters.leo
Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 163, in <lambda>
    u.btnColor.clicked.connect(lambda checked: o.setColor())
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1291, in setColor
    newcolor = QtWidgets.QColorDialog.getColor(color)
TypeError: getColor(initial: Union[QColor, Qt.GlobalColor, QGradient] = Qt.white, parent: QWidget = None, title: str = '', options: Union[QColorDialog.ColorDialogOptions, QColorDialog.ColorDialogOption] = QColorDialog.ColorDialogOptions()): argument 1 has unexpected type 'str'


Regards
Lewis

lewis

unread,
Oct 22, 2016, 12:20:37 AM10/22/16
to leo-editor
Here is the console traceback after selecting a 'Node shape' icon button:

[snip]

Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 175, in <lambda>
    u.btnImage.clicked.connect(lambda checked: o.setNode(nodeImage))
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1185, in setNode
    node = self.node[self.lastNodeItem]
KeyError: None
[end]

Edward K. Ream

unread,
Oct 22, 2016, 9:50:21 AM10/22/16
to leo-editor
On Friday, October 21, 2016 at 11:11:49 PM UTC-5, lewis wrote:
Crash leo completely using the Graph tab enabled via the graphcanvas plugin.

Naturally I read this just after releasing 5.4 final ;-)  I'll fix it asap.

EKR

Terry Brown

unread,
Oct 22, 2016, 11:23:41 AM10/22/16
to leo-e...@googlegroups.com
Although this is a problem with graphcanvas it seems to me that
exceptions recently became much more likely to hard crash Leo. I.e.
they're no longer being caught and reported by Leo they way they were
4-5? weeks ago. I've seen a lot of traceback and crash to console that
I wasn't seeing before. Probably worth working out what changed.

Cheers -Terry

Edward K. Ream

unread,
Oct 22, 2016, 11:37:05 AM10/22/16
to leo-editor
On Sat, Oct 22, 2016 at 10:23 AM, 'Terry Brown' via leo-editor <leo-e...@googlegroups.com> wrote:

Although this is a problem with graphcanvas it seems to me that
exceptions recently became much more likely to hard crash Leo.
​...​
Probably worth working out what changed.

​Perhaps this was the culprit. Maybe the supposed fix did more harm than good.

EKR

Edward K. Ream

unread,
Oct 22, 2016, 11:44:45 AM10/22/16
to leo-editor
On Fri, Oct 21, 2016 at 11:11 PM, lewis <lewi...@operamail.com> wrote:
Crash leo completely using the Graph tab enabled via the graphcanvas plugin.

Everything works for me with Python 3.5.2, PyQt version 4.8.7. Maybe the problem is with PyQt 5.7...

Furthermore, exceptions are caught properly.​
 
​ I have not ever seen Leo quit since the new exception-handling code was put in.

EKR​

Edward K. Ream

unread,
Oct 22, 2016, 11:48:00 AM10/22/16
to leo-editor
On Sat, Oct 22, 2016 at 10:44 AM, Edward K. Ream <edre...@gmail.com> wrote:
 
Everything works for me with Python 3.5.2, PyQt version 4.8.7. Maybe the problem is with PyQt 5.7...

Furthermore, exceptions are caught properly.​

​For example, just now Leo did catch this exception properly,

Traceback (most recent call last):
  File "c:\leo.repo\leo-editor\leo\plugins\graphcanvas.py", line 177, in <lambda>
    u.btnExport.clicked.connect(lambda checked: o.exportGraph())
  File "c:\leo.repo\leo-editor\leo\plugins\graphcanvas.py", line 1279, in exportGraph
    selectedFilter="Images (*.png)",
TypeError: QFileDialog.getSaveFileName(QWidget parent=None, str caption='', str directory='', str filter='', QFileDialog.Options options=0): 'selectedFilter' is not a valid keyword argument

Again, I have not ever seen the behavior that Terry describes.

EKR

Terry Brown

unread,
Oct 22, 2016, 11:48:36 AM10/22/16
to leo-e...@googlegroups.com
On Sat, 22 Oct 2016 10:37:00 -0500
"Edward K. Ream" <edre...@gmail.com> wrote:

> On Sat, Oct 22, 2016 at 10:23 AM, 'Terry Brown' via leo-editor <
> leo-e...@googlegroups.com> wrote:
>
> Although this is a problem with graphcanvas it seems to me that
> > exceptions recently became much more likely to hard crash Leo.
> > ​
> >
> ​...​
>
> > ​
> > Probably worth working out what changed.
>
> ​Perhaps this
> <https://groups.google.com/d/msg/leo-editor/CFZ9L4-fVUc/Ft751CaoAwAJ>was
> the culprit. Maybe the supposed fix did more harm than good.

The diff:

https://github.com/leo-editor/leo-editor/commit/a794384

hard to see how, I was aware of that and had it in the back of my mind,
but it looks sensible. Unless gs.es_exception() raises exceptions
again, and previously the code touched above was wrapped in a
try/except higher up the call chain.

Cheers -Terry

Terry Brown

unread,
Oct 22, 2016, 11:54:32 AM10/22/16
to leo-e...@googlegroups.com
On Sat, 22 Oct 2016 10:47:57 -0500
Yep, my observation is equivocal, I /have/ in the past few weeks thought
"huh, wouldn't have expected that to crash to console", but I've also
been working on the QtDock stuff, fingers in places where exceptions
might not be expected to be caught. OTOH graphcanvas hasn't changed,
so it's either some specific sensitivity in Lewis's setup (or just
that combination of Py / Qt versions that will soon hit others), or
something weird like a change in exception handling.

Cheers -Terry

Edward K. Ream

unread,
Oct 22, 2016, 11:54:50 AM10/22/16
to leo-editor
On Sat, Oct 22, 2016 at 10:48 AM, 'Terry Brown' via leo-editor <leo-e...@googlegroups.com> wrote:

> <https://groups.google.com/d/msg/leo-editor/CFZ9L4-fVUc/Ft751CaoAwAJ>was
> the culprit. Maybe the supposed fix did more harm than good.

​Well, it doesn't seem likely.  And besides, Python tracebacks have never been likely to crash Leo, except during startups.

Imo, hard crashes indicate installation problems. My best guess is that there is a problem with PyQt 5.7.

EKR

Chris George

unread,
Oct 22, 2016, 12:29:39 PM10/22/16
to leo-e...@googlegroups.com

Here is what I get.



Leo 5.4, Sat Oct 22 07:05:03 2016
Git commit: ff9c33da
Python 3.5.2, PyQt version 5.6.0
linux



Traceback (most recent call last):
  File "/working/leo/leo-editor/leo/plugins/graphcanvas.py", line 163, in <lambda>
    u.btnColor.clicked.connect(lambda checked: o.setColor())
  File "/working/leo/leo-editor/leo/plugins/graphcanvas.py", line 1286, in setColor

    node = self.node[self.lastNodeItem]
KeyError: None


Chris


--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscribe@googlegroups.com.
To post to this group, send email to leo-e...@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

lewis

unread,
Oct 22, 2016, 9:02:42 PM10/22/16
to leo-editor
Can anyone confirm if they have the same issues running windows, Python 3.5.2, PyQt version 5.7.0 ?

Chris - is your linux PyQt5.6 system traceback a full crash?

Thanks
Lewis

Chris George

unread,
Oct 22, 2016, 9:26:34 PM10/22/16
to leo-e...@googlegroups.com
I clicked the button to color the background and Leo was gone. The Traceback is from the console.

Chris

--

Terry Brown

unread,
Oct 22, 2016, 11:06:50 PM10/22/16
to leo-e...@googlegroups.com
On Sat, 22 Oct 2016 18:02:41 -0700 (PDT)
lewis <lewi...@operamail.com> wrote:

> Can anyone confirm if they have the same issues running windows,
> Python 3.5.2, PyQt version 5.7.0 ?

I see the traceback in the console, but Leo doesn't crash. But
thinking more clearly (not a morning person) I realize it must be
heightened sensitivity in your Python / Qt version (5.7 is sort of
bleeding edge?) rather than some change in Leo's exception handling,
seeing people running the new(ish) exception handling aren't getting
the full crash.

Cheers -Terry

Terry Brown

unread,
Oct 22, 2016, 11:12:53 PM10/22/16
to leo-e...@googlegroups.com
On Sat, 22 Oct 2016 22:06:48 -0500
"'Terry Brown' via leo-editor" <leo-e...@googlegroups.com> wrote:

> On Sat, 22 Oct 2016 18:02:41 -0700 (PDT)
> lewis <lewi...@operamail.com> wrote:
>
> > Can anyone confirm if they have the same issues running windows,
> > Python 3.5.2, PyQt version 5.7.0 ?
>
> I see the traceback in the console, but Leo doesn't crash. But

Doh, famous last words, now I am seeing the full crash, not sure why I
wasn't before.

Kind of feels like a git bisection might be informative. The actual
bug in graph canvas isn't hard to fix, but still wondering why this has
suddenly started happening.

Cheers -Terry

Terry Brown

unread,
Oct 22, 2016, 11:34:34 PM10/22/16
to leo-e...@googlegroups.com
On Sat, 22 Oct 2016 22:12:50 -0500
"'Terry Brown' via leo-editor" <leo-e...@googlegroups.com> wrote:

> On Sat, 22 Oct 2016 22:06:48 -0500
> "'Terry Brown' via leo-editor" <leo-e...@googlegroups.com> wrote:
>
> > On Sat, 22 Oct 2016 18:02:41 -0700 (PDT)
> > lewis <lewi...@operamail.com> wrote:
> >
> > > Can anyone confirm if they have the same issues running windows,
> > > Python 3.5.2, PyQt version 5.7.0 ?
> >
> > I see the traceback in the console, but Leo doesn't crash. But
>
> Doh, famous last words, now I am seeing the full crash, not sure why I
> wasn't before.
>
> Kind of feels like a git bisection might be informative. The actual
> bug in graph canvas isn't hard to fix, but still wondering why this
> has suddenly started happening.

Gah, confused. Just went back to May 26 2015, seeing the full crash
there. Hard to believe it hasn't been seen before, but then that
pre-dates any changes to exception handling. And I'm using
Python 2.7.12, PyQt version 5.5.1

So, doesn't seem like there's much to do that fix the bug and see what
happens.

... fix pushed - let me know if it still happens.

Cheers -Terry

> Cheers -Terry
>
> > thinking more clearly (not a morning person) I realize it must be
> > heightened sensitivity in your Python / Qt version (5.7 is sort of
> > bleeding edge?) rather than some change in Leo's exception handling,
> > seeing people running the new(ish) exception handling aren't getting
> > the full crash.
> >
> > Cheers -Terry
> >
> > > Chris - is your linux PyQt5.6 system traceback a full crash?
> > >
> > > Thanks
> > > Lewis
> > >
> > > On Sunday, 23 October 2016 03:29:39 UTC+11, Chris George
> > > wrote:
> [...]
> > >
> >
>

lewis

unread,
Oct 23, 2016, 12:59:51 AM10/23/16
to leo-editor
Running Git commit: d7a90c09 with Python 3.5.2, PyQt version 5.7.0
Now the graph pane doesn't display any graphs for the file I tested with.  Good news is I can't crash Leo

Regards
Lewis

On Sunday, 23 October 2016 14:34:34 UTC+11, Terry Brown wrote:

....

lewis

unread,
Oct 23, 2016, 3:51:36 AM10/23/16
to leo-editor
Terry,

I have to press the 'Node' button to make the parent node visible in the graph pane, then press the 'Recur' button to make the child nodes visible. I save the file, close and restart Leo and the graph pane is still not visible unless I repeat the process above.
I'm not quite sure why I now need to do this; graphs used to be visible by default.

Update: managed to crash Leo by selecting the node in the graph pane, drag it around to reposition it in the pane, then select the colour block. Crash.

Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 163, in <lambda>
    u.btnColor.clicked.connect(lambda checked: o.setColor())
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1298, in setColor

    newcolor = QtWidgets.QColorDialog.getColor(color)
TypeError: getColor(initial: Union[QColor, Qt.GlobalColor, QGradient] = Qt.white, parent: QWidget = None, title: str = '', options: Union[QColorDialog.ColorDialogOptions, QColorDialog.ColorDialogOption] = QColorDialog.ColorDialogOptions()): argument 1 has unexpected type 'str'

Regards
Lewis

Edward K. Ream

unread,
Oct 23, 2016, 6:06:48 AM10/23/16
to leo-editor
On Sat, Oct 22, 2016 at 11:29 AM, Chris George <techn...@gmail.com> wrote:

Traceback (most recent call last):
  File "/working/leo/leo-editor/leo/plugins/graphcanvas.py", line 163, in <lambda>
    u.btnColor.clicked.connect(lambda checked: o.setColor())
  File "/working/leo/leo-editor/leo/plugins/graphcanvas.py", line 1286, in setColor
    node = self.node[self.lastNodeItem]
KeyError: None

​LeoPluginsController.callTagHandler catches all exceptions, but plugins can still throw uncaught exceptions, as in this example.

As a matter of style, I much prefer dict.get(aKey) rather than dict[aKey], because the former never throws KeyError.

Please file a bug report against the graphcanvas plugin.

Edward

lewis

unread,
Oct 23, 2016, 8:20:09 AM10/23/16
to leo-editor
See issue #326

lewis

unread,
Oct 23, 2016, 5:27:20 PM10/23/16
to leo-editor
Pressing the 'Export' button (Export the graph as a PNG) crashes Leo.

Here is the traceback:

Git commit: ec8c3088

Python 3.5.2, PyQt version 5.7.0
Windows 10 AMD64 (build 10.0.14393) SP0
reading settings in N:\leo\DServe_Eff_Filters.leo
reading settings in N:\leo\workbook.leo

Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 179, in <lambda>
    u.btnExport.clicked.connect(lambda checked: o.exportGraph())
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1286, in exportGraph
    selectedFilter="Images (*.png)",
TypeError: getSaveFileName(parent: QWidget = None, caption: str = '', directory: str = '', filter: str = '', initialFilter: str = '', options: Union[QFileDialog.Options, QFileDialog.Option] = 0): 'selectedFilter' is not a valid keyword argument

The other buttons are now stable.

Regards
Lewis

Terry Brown

unread,
Oct 23, 2016, 6:26:17 PM10/23/16
to leo-e...@googlegroups.com
On Sun, 23 Oct 2016 14:27:19 -0700 (PDT)
lewis <lewi...@operamail.com> wrote:

> Pressing the 'Export' button (Export the graph as a PNG) crashes Leo.

Gah, ok, try f78504f

Cheers -Terry

> Here is the traceback:
>
> *Git commit: ec8c3088Python 3.5.2, PyQt version 5.7.0Windows 10 AMD64
> (build 10.0.14393) SP0reading settings in
> N:\leo\DServe_Eff_Filters.leoreading settings in
> N:\leo\workbook.leoTraceback (most recent call last): File
> "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 179, in
> <lambda> u.btnExport.clicked.connect(lambda checked:
> o.exportGraph()) File
> "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1286, in
> exportGraph selectedFilter="Images (*.png)",TypeError:
> getSaveFileName(parent: QWidget = None, caption: str = '', directory:
> str = '', filter: str = '', initialFilter: str = '', options:
> Union[QFileDialog.Options, QFileDialog.Option] = 0): 'selectedFilter'
> is not a valid keyword argument*The other buttons are now stable *.*
> Regards
> Lewis

lewis

unread,
Oct 24, 2016, 5:24:16 AM10/24/16
to leo-editor
Hi Terry,

Good news, I successfully exported a PNG file, and more than once! Your work on this plugin is appreciated.
For this test please note I have switched to a laptop running PyQt5.6.0

However later when I used the 'Clear formatting' button I managed to crash Leo. Here is the console:

Leo 5.4, Mon Oct 24 09:25:33 2016
Git commit: f78504fc
Python 3.5.2, PyQt version 5.6.0
Windows Vista x86 (build 6.0.6002) SP2
reading settings in N:\leo\DServe_Eff_Filters.leo
Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 167, in <lambda>
    u.btnClearFormatting.clicked.connect(lambda checked: o.clearFormatting())
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1341, in clearFormatting
    item.bg.setBrush(QtGui.QBrush(QtGui.QColor(200,240,200)))
AttributeError: 'QGraphicsPixmapItem' object has no attribute 'setBrush'

Later I will repeat the testing back on my win10 desktop and report the progress.

Regards
Lewis

Terry Brown

unread,
Oct 24, 2016, 10:01:29 PM10/24/16
to leo-editor
On Mon, 24 Oct 2016 02:24:16 -0700 (PDT)
lewis <lewi...@operamail.com> wrote:

> Hi Terry,
>
> Good news, I successfully exported a PNG file, and more than once!
> Your work on this plugin is appreciated.
> For this test please note I have switched to a laptop running
> PyQt5.6.0
>
> However later when I used the 'Clear formatting' button I managed to
> crash Leo. Here is the console:

Ok, thanks, fixed that in 68548f0.

There's definitely something change with exception handling. Or
something related.

python launchLeo.py ~/.leo/del.leo

starts Leo, del.leo is my testing outline. This is Python 2.7.12, PyQt
version 5.5.1. Prior to my fix in 68548f0, I get Lewis's crash to console.

python3 launchLeo.py ~/.leo/del.leo

seg-faults without starting (splash is displayed)

But using the script I usually use to start Leo, it runs with
Python 3.5.2, PyQt version 5.5.1 and while I see Lewis's traceback in
the console, Leo doesn't crash. That's what I'm talking about when I
say I think Leo's recently become more crashable by these kind of bugs.

But it's not something you can pin down with git bisect, I think it's
probably also related to Python and Qt versions, particularly the
recent(ish) jump from Qt 4 to 5 for Python 2.7 deployments.

Cheers -Terry

> *Leo 5.4, Mon Oct 24 09:25:33 2016*
> *Git commit: f78504fc*
> *Python 3.5.2, PyQt version 5.6.0*
> *Windows Vista x86 (build 6.0.6002) SP2*
> *reading settings in N:\leo\DServe_Eff_Filters.leo*
> *Traceback (most recent call last):*
> * File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 167, in
> <lambda>*
> * u.btnClearFormatting.clicked.connect(lambda checked:
> o.clearFormatting())*
> * File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1341, in
> clearFormatting*
> * item.bg.setBrush(QtGui.QBrush(QtGui.QColor(200,240,200)))*
> *AttributeError: 'QGraphicsPixmapItem' object has no attribute
> 'setBrush'*

lewis

unread,
Oct 24, 2016, 10:23:00 PM10/24/16
to leo-editor
I have another traceback from the laptop running PyQt5.6.0 which I haven't sent yet because 1. I couldn't confirm the menu action which caused the crash and, 2. I wasn't able to repeat it.
Would you like to me to post the Git commit: f78504fc  trace here anyway?  I 'm currently at work so it will be few hours.

Lewis

lewis

unread,
Oct 25, 2016, 5:44:43 AM10/25/16
to leo-editor
Terry,

Here is the other crash trace. A few points to consider:
I don't know which graphcanvas button caused it. It's unique - I wasn't able to repeat the crash, and I have no similar traceback on other PC/leo versions.
It occured on a very recent older commit

Leo 5.4, Mon Oct 24 09:25:33 2016
Git commit: f78504fc
Python 3.5.2, PyQt version 5.6.0
Windows Vista x86 (build 6.0.6002) SP2
reading settings in N:\leo\DServe_Eff_Filters.leo
Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 173, in <lambda>
    u.btnTable.clicked.connect(lambda checked: o.setNode(nodeTable))
  File "N:\git\leo-editor\leo\plugins\graphcanvas.py", line 1198, in setNode
    self.releaseNode(self.nodeItem[node])
KeyError: <VNode 646cfb0 Spring>

Hope it is helpful.

Lewis

Edward K. Ream

unread,
Oct 25, 2016, 7:36:06 AM10/25/16
to leo-editor
On Mon, Oct 24, 2016 at 9:01 PM, 'Terry Brown' via leo-editor <leo-e...@googlegroups.com> wrote:

There's definitely something change with exception handling.  Or
something related.
​...

python3 launchLeo.py ~/.leo/del.leo

seg-faults without starting (splash is displayed)

​Python exception handling will not catch segfaults.  So this isn't something that has changed in Leo.  ​
 

But it's not something you can pin down with git bisect, I think it's
probably also related to Python and Qt versions, particularly the
recent(ish) jump from Qt 4 to 5 for Python 2.7 deployments.

​I agree.

Edward
Reply all
Reply to author
Forward
0 new messages