-
-
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: Fix extraneous reloading documents on project switching #15681
PR: Fix extraneous reloading documents on project switching #15681
Conversation
b4a398f
to
748966b
Compare
@ccordoba12, this is ready for review. |
c94208d
to
96e594e
Compare
96e594e
to
652b0e1
Compare
723b2c9
to
764eebf
Compare
So what happens when you switch projects? I mean, how the files of the project that is opened (after the current one is closed) are set in the editor? |
The editor.setup_open_files gets called with the sig_project_loaded.emit in the open_project method of the Projects plugin class. So basically, it gets called when a project gets closed, also when a project gets opened; but when one switches a project, it was called twice (once with the sig_project_closed and once with the sig_project_loaded), causing the Editor to reload the files in the first project before loading the files in the second project. So, I made a switch in sig_project_closed to distinguish between events where the project is being closed only, and events where the project is closed for switching to another project. In this way, the setup_open_files is always called, but only once. |
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 @mrclary for your help with this! I think by using sig_project_closed
with an additional signature, your PR can be made much simpler, so all my suggestions below are oriented towards that.
…ose emit. This causes existing project files to be reloaded before new project files are loaded.
…y called in open_project.
…s is already called in open_project.
…t is not actually created, so the active one is not closed and the emit signal is not sent. i.e. it relied on an unnecessary close emit. * This test is actually redundant since a successful creation of a project will call open_project which will send the close emit and is already tested.
… in open_project.
764eebf
to
01ab43f
Compare
@ccordoba12, thanks for the suggestions! I learned a lot from that. |
I'm really glad about 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.
Looks good to me now, thanks @mrclary!
Description of Changes
editor.setup_open_files
only when not switching projects.create_new_project
. This lead to multiple unnecessary calls tosig_project_closed.emit
andrestart_consoles
.root_path
is not set in the mocked dialogue window so a project is not actually created and the active project is not closed. This test is unnecessary sincecreate_new_project
should not sendsig_project_closed.emit
, which is sent inopen_project
(if switching projects) or theclose_project
and is already tested.Issue(s) Resolved
Fixes #14787
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:
@mrclary