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

PR: Remove lambdas in Qt slots #19471

Merged
merged 6 commits into from
Sep 20, 2022
Merged

Conversation

impact27
Copy link
Contributor

@impact27 impact27 commented Sep 16, 2022

Description of Changes

Remove unnecessary lambdas from signals

A lambda prevents qt from keeping a reference to the object, leading to:

RuntimeError: wrapped C/C++ object of type xxxx has been deleted
  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)

Issue(s) Resolved

Fixes #19393

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:

@ccordoba12 ccordoba12 changed the title remove lambdas in qt messages PR: Remove lambdas in Qt slots Sep 16, 2022
Copy link
Member

@ccordoba12 ccordoba12 left a 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 help with this!

@@ -1053,6 +1053,7 @@ def update_margins(self, margin):
"""
self.get_widget().update_margins(margin)

@Slot()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this (see below).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't this this one should be removed, isn't it called from a signal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example in the ipythonconsole plugin on_initialize

@@ -113,7 +113,7 @@ def on_initialize(self):
self.create_action(
BreakpointsActions.ListBreakpoints,
_("List breakpoints"),
triggered=lambda: self.switch_to_plugin(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling this directly, please emit sig_switch_to_plugin_requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work because sig_switch_to_plugin_requested is connected to MainWindow.switch_to_plugin not to SpyderDockablePlugin.switch_to_plugin

spyder/plugins/pylint/main_widget.py Outdated Show resolved Hide resolved
@ccordoba12 ccordoba12 added this to the v5.4.0 milestone Sep 17, 2022
@ccordoba12
Copy link
Member

Also, please rebase or merge with 5.x to get the fix to our Mac app on PR #19485.

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now, thanks @impact27!

@ccordoba12 ccordoba12 merged commit cf6cf6f into spyder-ide:5.x Sep 20, 2022
ccordoba12 added a commit that referenced this pull request Sep 20, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants