Skip to content

Conversation

@rozyczko
Copy link
Member

Description

Added Close Project action to the File menu. This action removes all loaded data, plots and content of all perspectives.
This effectively puts SasView in the "Just opened" state, with minor caveats of calculator window content and certain options.

Fixes #3312

How Has This Been Tested?

Local Win10

Review Checklist:

[if using the editor, use [x] in place of [ ] to check a box]

Documentation (check at least one)

  • There is nothing that needs documenting
  • [X ] Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)
    • Wheels installer (GH artifact) has been tested (installed and worked)

Licensing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

@rozyczko rozyczko changed the title initial commit Implemented Close Project functionality Nov 14, 2025
@wpotrzebowski
Copy link
Contributor

Just quickly looking, I am getting error
ERROR: Traceback (most recent call last): File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/generate.py", line 1178, in load_kernel_module __import__('sasmodels.models.'+model_name) File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/models/two_yukawa.py", line 97, in from sasmodels.TwoYukawa.CalTYSk import K_MIN, Z_MIN, Z_MIN_DIFF, CalTYSk ModuleNotFoundError: No module named 'sasmodels.TwoYukawa' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/sasview_model.py", line 112, in load_standard_models MODELS[name] = _make_standard_model(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/sasview_model.py", line 198, in _make_standard_model kernel_module = generate.load_kernel_module(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/generate.py", line 1186, in load_kernel_module kernel_module = load_custom_kernel_module(model_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/custom/__init__.py", line 60, in load_custom_kernel_module if need_reload(path): ^^^^^^^^^^^^^^^^^ File "/Volumes/SasView6 7/SasView6.app/Contents/Frameworks/sasmodels/custom/__init__.py", line 115, in need_reload return any(cache_time return any(cache_time
but it may be unrelated

@wpotrzebowski
Copy link
Contributor

It was triggered when I tried to "Close Project"

@rozyczko
Copy link
Member Author

I don't think it has anything to do with the changes?
No module named 'sasmodels.TwoYukawa' points to a difference between sasview and sasmodels version

Copy link
Contributor

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

The P(r) perspective needs to be fixed before I can approve.

Comment on lines +45 to +46
<addaction name="actionClose_Project"/>
<addaction name="separator"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Logically, this would make more sense to be above the Preferences option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I fully agree - closing and quitting actions are usually on the bottom of the list, cf. Window menu.
For File you choose to either Close Project or Quit - these two should belong to the same "category".

@krzywon
Copy link
Contributor

krzywon commented Nov 17, 2025

I think the issue @wpotrzebowski saw was related to #3664. This should now be resolved with the latest sasmodels changes. Note - I am not seeing this error locally, though I haven't tried the installer.

@rozyczko rozyczko requested a review from krzywon November 18, 2025 15:37
@krzywon
Copy link
Contributor

krzywon commented Nov 18, 2025

@rozyczko - I would give an updated review, but I don't see any new commits since yesterday.

@rozyczko
Copy link
Member Author

@rozyczko - I would give an updated review, but I don't see any new commits since yesterday.

sorry, did git commit, forgot to push it.

Copy link
Contributor

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

P(r) resetting works as expected now. I think the save on close project issue I found should be fixed, but otherwise, this looks ready to go.

"All unsaved changes will be lost if you don't save.",
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel,
QMessageBox.Cancel)
if reply == QMessageBox.Save:
Copy link
Contributor

Choose a reason for hiding this comment

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

If the saving project dialog is cancelled, the project reset still happens with no project saved, which may not be ideal.

Maybe if (reply == QMessageBox.Save and self.actionSave_Project()) or reply == QMessageBox.Discard:? This would require the save project to return something Truthy on success.

Copy link
Member Author

@rozyczko rozyczko Nov 18, 2025

Choose a reason for hiding this comment

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

Errr.. nope :) we have

        if reply == QMessageBox.Save:
         ...
        elif reply == QMessageBox.Discard:
         ....
        # else Cancel, do nothing

The else branch is just noop but with comment added

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think my original point was clear. Try the following steps:

  1. Open a project or do some work in SasView
  2. Choose File -> Close Project
  3. Click the 'Save' button
  4. In the resulting file browser dialog, click Cancel
  5. The result is no saved project, and all work cleared from SasView

I don't think users will appreciate all of their work being thrown away without warning.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! This makes sense. Indeed cancelling the "Save Project" does the wrong thing. thanks!

@rozyczko rozyczko merged commit 192f571 into main Nov 19, 2025
35 checks passed
@rozyczko rozyczko deleted the 3312-close-project branch November 19, 2025 16:11
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.

enhancement: close project

4 participants