What steps will reproduce the problem?
What is the expected output? What do you see instead?
Please provide any additional information below
File "/home/dhama/anaconda3/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 2013, in update_edit_menu
widget, textedit_properties = self.get_focus_widget_properties()
File "/home/dhama/anaconda3/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 2006, in get_focus_widget_properties
not_readonly = not widget.isReadOnly()
RuntimeError: wrapped C/C++ object of type CodeEditor has been deleted
pyflakes >=0.6.0 : 1.6.0 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pygments >=2.0 : 2.2.0 (OK)
pandas >=0.13.1 : 0.20.3 (OK)
numpy >=1.7 : 1.13.3 (OK)
sphinx >=0.6.6 : 1.6.3 (OK)
rope >=0.9.4 : 0.10.5 (OK)
jedi >=0.9.0 : 0.10.2 (OK)
psutil >=0.3 : 5.4.0 (OK)
nbconvert >=4.0 : 5.3.1 (OK)
sympy >=0.7.3 : 1.1.1 (OK)
cython >=0.21 : 0.26.1 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
IPython >=4.0 : 6.1.0 (OK)
pylint >=0.25 : 1.7.4 (OK)
Please describe step by step how you got this error so we can reproduce it in our side. If you fail to do that, we'll close this issue in a week from now.
@ccordoba12 As an OT aside (as I'm not sure how else to mention it), since this seems to be a stock response (great idea ofc), I might suggest a tweak to the following to maximize the chances of a positive response while minimizing the chance someone misinterprets it and gets rubbed the wrong way. (I hope _this_ suggestion doesn't get taken the wrong way, heh; I used to work as a copyeditor for an engineering magazine so it has been bugging me). Thus:
Please describe step by step how you got this error so we can reproduce it in our side. If _we don't hear from you,_ we'll _have to_ close this issue in a week from now. _Thanks._
Closed due to lack of response.
Okay @ccordoba12 , I managed to reproduce this by accident in Spyder 3.2.6 (and Python 3.6.4) on Windows, and isolated it to the following situation:
Error message will pop up with the above/below traceback after a minimal delay of around 500 ms. Doing step 1 and 2, but clicking elsewhere in the UI will not trigger it, even if one then clicks on any menu after clicking elsewhere, and neither will immediately using Alt + Letter to bring up the menus. However, if the keyboard is used in step 2 but not step 3 (i.e. closing all windows with Ctrl-Shift-W) _will_ still trigger it just fine so long as the menus are actually clicked on. Also, to clarify, there are apparently no ill effects other than the error message.
Therefore, it seems it might have to do with something that only happens on a mouseClick event vs. the menu access itself? Unfortunately, as this issue seems to occur within the Qt C++ API I'm not exactly familiar with how it should be handled; my C++ experience is limited to a few simple programs in my spare time and nothing GUI related, so at the very least if I were to try to fix this myself I'd need some clear...pointers (heh).
The updated traceback (with 3.2.6 line numbers):
File "C:Anaconda3libsite-packagesspyderappmainwindow.py", line 2027, in update_edit_menu
widget, textedit_properties = self.get_focus_widget_properties()
File "C:Anaconda3libsite-packagesspyderappmainwindow.py", line 2020, in get_focus_widget_properties
not_readonly = not widget.isReadOnly()
RuntimeError: wrapped C/C++ object of type CodeEditor has been deleted
Thanks @CAM-Gerlach for investigating and for finding a way to reproduce it. I can handle this one if you don't.
Thanks @jnsebgosselin . My naive suspicion is that something, possibly triggered by a mouseClick event to any menu object, triggers that code path that references some old CodeEditor object that was closed and gc'ed already. However, that really is just an uninformed guess; I'd be curious to see what is actually going on.
@ccordoba12 Is closing the split editors but one when all files are closed the expected behavior? That is what is causing this bug to happen. The references to the closed split editor are not cleaned properly in python when it is closed this way. So when the mainwindow tries to get hold of the closed split editor to refresh its Edit
menu, it fails because it has been deleted on the qt side.
I think split editors should not be closed when closing all files, either one-by-one or with the close all
action.
I think split editors should not be closed when closing all files, either one-by-one or with the close all action.
Agreed. Thanks for noticing the problem and helping us to fix it.
Alright. I'm going to fix this behavior then, which will take care of the bug.
For the records, this is also why split editors were closed when switching or opening a spyder project. So that is going to fix that also.
Nice! Two birds with one stone.
@ccordoba12 Just letting you know I'm working on this one, but it has proven to be more difficult than I had anticipated... so sorry for the delay with this one.
No worries, it's marked for 3.2.9 so there's no rush.
@jnsebgosselin, do you have time to address this one? It'd be handy to have it for 3.3.2 (which I hope to release next weekend).
Most helpful comment
Agreed. Thanks for noticing the problem and helping us to fix it.