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

Properly unsubscribe when property page is removed #2091

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented Feb 15, 2023

PR Type

What kind of change does this PR introduce?

  • Bug fix
  • Feature
  • Chore (refactoring, formatting, local variables, other cleanup)
  • Documentation content changes

What is the current behavior?

Event handlers "leak" in GTK 4.

Issue Number: N/A

What is the new behavior?

Add a function to unsubscribe watchers. It appeared handlers were not properly removed in GTK4, since in GTK4 widgets are not "destroyed", but only use reference counting.

Information

Added a function to gaphor.diagram.propertypages to unsubscribe automatically on widget destroy (gtk3) or unparent (gtk4).

@github-actions github-actions bot added the python Pull requests that update Python code label Feb 15, 2023
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 15, 2023

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.19%.

Quality metrics Before After Change
Complexity 2.99 ⭐ 2.98 ⭐ -0.01 👍
Method Length 47.97 ⭐ 47.66 ⭐ -0.31 👍
Working memory 3.95 ⭐ 3.97 ⭐ 0.02 👎
Quality 77.90% 78.09% 0.19% 👍
Other metrics Before After Change
Lines 1693 1726 33
Changed files Quality Before Quality After Quality Change
gaphor/C4Model/propertypages.py 86.86% ⭐ 87.23% ⭐ 0.37% 👍
gaphor/SysML/propertypages.py 78.47% ⭐ 78.52% ⭐ 0.05% 👍
gaphor/UML/actions/actionspropertypages.py 85.44% ⭐ 85.57% ⭐ 0.13% 👍
gaphor/UML/actions/activitypropertypage.py 78.00% ⭐ 78.04% ⭐ 0.04% 👍
gaphor/UML/classes/associationpropertypages.py 67.34% 🙂 67.37% 🙂 0.03% 👍
gaphor/UML/classes/classespropertypages.py 73.07% 🙂 73.13% 🙂 0.06% 👍
gaphor/UML/classes/dependencypropertypages.py 87.65% ⭐ 87.62% ⭐ -0.03% 👎
gaphor/UML/classes/enumerationpropertypages.py 61.94% 🙂 62.08% 🙂 0.14% 👍
gaphor/UML/profiles/metaclasspropertypage.py 77.95% ⭐ 78.02% ⭐ 0.07% 👍
gaphor/UML/states/propertypages.py 80.99% ⭐ 81.12% ⭐ 0.13% 👍
gaphor/diagram/propertypages.py 84.44% ⭐ 84.66% ⭐ 0.22% 👍
gaphor/diagram/general/generalpropertypages.py 75.45% ⭐ 76.64% ⭐ 1.19% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gaphor/UML/classes/classespropertypages.py OperationsPage.construct 10 🙂 270 ⛔ 42.35% 😞 Try splitting into smaller methods
gaphor/UML/classes/classespropertypages.py AttributesPage.construct 10 🙂 261 ⛔ 42.95% 😞 Try splitting into smaller methods
gaphor/UML/classes/associationpropertypages.py AssociationPropertyPage.construct 7 ⭐ 296 ⛔ 45.07% 😞 Try splitting into smaller methods
gaphor/UML/classes/enumerationpropertypages.py EnumerationPage.construct 10 🙂 208 ⛔ 47.57% 😞 Try splitting into smaller methods
gaphor/SysML/propertypages.py ItemFlowPropertyPage.construct 7 ⭐ 219 ⛔ 8 🙂 54.44% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Add a function to unsubscribe watchers. It appeared handlers were
not properly removed in GTK4, since in GTK4 widgets are not "destroyed",
but only use reference counting.
Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

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

This looks great! How did you figure out that GTK4 event handlers were leaking?

@amolenaar
Copy link
Member Author

I know something changed in the way widgets are destroyed. Initially I just made it work (not break), but forgot to come back and fix it for real.

@danyeaw danyeaw added the bug An issue in the application label Feb 17, 2023
@danyeaw danyeaw merged commit 202acb3 into main Feb 17, 2023
@danyeaw danyeaw deleted the fix-property-page-unsubscribe branch February 17, 2023 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue in the application python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants