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

TypeErrror on Windows with some traitsui / mayavi tools #1853

Open
max3-2 opened this issue Mar 3, 2022 · 3 comments
Open

TypeErrror on Windows with some traitsui / mayavi tools #1853

max3-2 opened this issue Mar 3, 2022 · 3 comments

Comments

@max3-2
Copy link

max3-2 commented Mar 3, 2022

Hi,

let me link this from mayavi, I did not get any answer there and I feel this might be related: enthought/mayavi#1127

In short, using mayavi works (examples, custom scripts) but when accessing the tree to change any property, the following occurs and crashes the current window:

Traceback (most recent call last):
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\pyface\ui\qt4\action\action_item.py", line 184, in _qt4_on_triggered
    self.controller.perform(action, action_event)
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\traitsui\qt4\tree_editor.py", line 1189, in perform
    self.ui.do_undoable(self._perform, action)
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\traitsui\ui.py", line 655, in do_undoable
    action(*args, **kw)
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\traitsui\qt4\tree_editor.py", line 1192, in _perform
    node, object, nid = self._data
TypeError: cannot unpack non-iterable NoneType object

Any help to pinpoint me for a fix? Seems to be that self._data is None which is not supposed to happen...?

@max3-2
Copy link
Author

max3-2 commented Mar 4, 2022

Let me follow up here: Deletion of elements is not possible too. A window pops up and disappears so quickly I cant make out what it says. I think I traced it back a bit:

self._data in is modified in class SimpleEditor(Editor) of tree_editor.py in ll952 _on_context_menu which is called on each right click. self_datais set valid and then just at the end of the method it is set toNone` which happens before performing an action, leading to the error above.

If I remove self_data from the statement beginning line 1007 it seems to work again, albeit the deletion of elements. Don't see any other issues in a very quick test

Any ideas on this?

@corranwebster
Copy link
Contributor

corranwebster commented Mar 4, 2022

Thanks for the report. Unfortunately I can't currently replicate the behaviour in pure TraitsUI (on Mac, with PyQt 5.14.2).

Indeed, self._data should not be None when the method is called.

However the lines in 1007 onwards shouldn't be called until after all menu interactions are done: I think that the exec_ on 1004 should be blocking; and I don't think there is any threading or asynchronous stuff going on.

The standard execution flow should be something like:

exec_ -> ...user interaction selects menu item... -> _qt4_on_triggered -> perform -> do_undoable -> _perform

with no opportunity to resume execution after the exec_ until _perform is done. So I'm not entirely sure how we're getting to this state. Adding a few print statements or logging calls may help you confirm

Can you install TraitsUI from the main branch and see if it still occurs? Also, can you try with a different version of PyQt5 or PySide2, as it is possible that this is hitting some bug at that level.

Also it is possible that Mayavi is doing something nonstandard in its tree view widget which may override this analysis.

@max3-2
Copy link
Author

max3-2 commented Mar 4, 2022

I added some prints around the reset and as soon as I interact, both are called on appearance of the menu. This is, however logical since at the other issue @prabhuramachandran came through and explained that my event loop was not running. So this obviously stops exec_() from blocking and the error occurs. So from traitsui I guess this is a no error.
Thanks for the quick help though!

Oh and btw:

I can't currently replicate the behaviour in pure TraitsUI

Can you produce a MWE just to test TraitsUI?

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