-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Close memory leaks of CodeEditor and ShellWidget #18781
Conversation
Hey @impact27, this is great! Thanks a lot for taking the time to fix these memory leaks! Could you move your branch to
|
7247f3c
to
d65dab1
Compare
0749a64
to
4f07bda
Compare
@ccordoba12 This is ready for review. The failures are unrelated to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @impact27 for your hard work on this one!
code_editor = main_window.editor.get_focus_widget() | ||
# Show an error in the editor | ||
code_editor.set_text("aaa") | ||
del code_editor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to delete this CodeEditor instance at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise a reference is kept which leads to leaking a CodeEditor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am checking the number of CodeEditor with a reference below, this would add one. Del only deletes the local ref, not the object itself (unless this is the last ref)
@@ -309,7 +309,7 @@ def document_did_close(self, params): | |||
if id(codeeditor) == id(editor): | |||
idx = i | |||
break | |||
if idx > 0: | |||
if idx >= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary to add the equal sign here? Just asking because I don't understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was an error in the code. If no CodeEdotor are found, the index should be -1, so you can check with index >=0 (and not >0 which leads to a leak)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comment for you @impact27, then this should be ready.
more better
fix test simpler tests
fix test
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com> Update test_mainwindow.py Update main.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @impact27 for your hard work on this one!
Description of Changes
Issue(s) Resolved
Fixes #18764
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: