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

Cleanup session lifecycle #431

Merged
merged 6 commits into from
Sep 10, 2020
Merged

Cleanup session lifecycle #431

merged 6 commits into from
Sep 10, 2020

Conversation

amolenaar
Copy link
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

There was a lot of hopping around the code when dealing with file loading and session creation. This was only possible through the GtkApplication. This is inconvenient and not handy, since GtkApplication is not out core application: gaphor.application.Application is.

Issue Number: N/A

What is the new behavior?

This PR cleans up the code. Makes sure all file loading takes place through the app_file_manager and ensures session lifecycle can be completely handled in our code.

On application level there's also an event manager now, so session creation and application shutdown events can be propagated to the GtkApplication as well. Handlers in GtkApplication ensure that the main window is shown when a new session is created and make sure the Gtk main loop is ended when the Gaphor Application ends.

Does this PR introduce a breaking change?

  • Yes
  • No

Now Application works in line (sort of) of now a session works.
The loading behavior should now be consistent (e.g. replace model in
current session if it has a new model without modifications.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 9, 2020

Sourcery Code Quality Report (beta)

❌  Merging this PR will decrease code quality in the affected files by 0.03 out of 10.

Quality metrics Before After Change
Complexity 1.03 1.05 0.02 🔴
Method Length 31.91 33.32 1.41 🔴
Quality 9.13 9.10 -0.03 🔴
Other metrics Before After Change
Lines 787 847 60
Changed files Quality Before Quality After Quality Change
gaphor/application.py 9.21 9.18 -0.03 🔴
gaphor/event.py 9.62 9.63 0.01 🔵
gaphor/ui/init.py 8.63 8.46 -0.17 🔴
gaphor/ui/appfilemanager.py 9.45 9.29 -0.16 🔴
gaphor/ui/filemanager.py 8.68 8.70 0.02 🔵
gaphor/ui/macosshim.py 9.49 9.50 0.01 🔵
gaphor/ui/tests/test_lifecycle.py 9.45 9.36 -0.09 🔴

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

File Function Complexity Length Overall Recommendation
gaphor/ui/init.py run 12 173.90 5.32 Split out functionality

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!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

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.

Nice cleanup!

@danyeaw danyeaw added the chore Maintenance related PR label Sep 10, 2020
@danyeaw danyeaw merged commit 90da148 into master Sep 10, 2020
@danyeaw danyeaw deleted the cleanup-session-lifecycle branch September 10, 2020 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Maintenance related PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants