[fix] METEOR GUI: closing "Create or load project" window causes error#3303
Conversation
The initial window only allows to create or load... but if you press
Alt+F4 on Ubuntu 24.04, you can still close the window. We could re-open
it, but let's make it a hidden shortcut that the suggested new project name
is fine, and automatically create a directory.
This avoids such error:
2025-12-15 18:37:27,928 ERROR main:422: Traceback (most recent call last):
File "/home/piel/.local/lib/python3.12/site-packages/wx/core.py", line 3425, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/piel/development/odemis/src/odemis/gui/cont/tabs/tab_bar_controller.py", line 102, in _on_tab_change
tab.Show()
File "/home/piel/development/odemis/src/odemis/gui/cont/tabs/cryo_chamber_tab.py", line 1032, in Show
if ret:
^^^
UnboundLocalError: cannot access local variable 'ret' where it is not associated with a value
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where closing the "Create or load project" dialog window (e.g., via Alt+F4) causes an UnboundLocalError because the variable ret was never assigned a value before being checked. The fix adds an else clause to handle dialog closure by automatically creating a new project directory with the suggested name.
- Added else clause to handle dialog closure (lines 1030-1033)
- Automatically creates new project directory when dialog is closed
- Sets
ret = Trueto break out of the while loop and continue execution
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthroughThe CryoChamberTab.Show method now auto-creates a new project directory when the project dialog is closed without selection (neither Load nor Create button clicked). Previously, closing the dialog would dismiss it without triggering any project creation. The method now calls _create_new_dir() and sets ret = True to proceed through the post-creation workflow when this dismissal occurs. Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/odemis/gui/cont/tabs/cryo_chamber_tab.py (1)
1031-1031: Improve comment professionalism.The comment "The user cannot be bothered" has a slightly dismissive tone. Consider rephrasing for clarity and professionalism.
- # The user cannot be bothered => create a new project automatically + # Dialog was closed without selection; auto-create a default project
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/odemis/gui/cont/tabs/cryo_chamber_tab.py(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Linting
src/odemis/gui/cont/tabs/cryo_chamber_tab.py
[error] 1-1: PNG metadata check failed: file contains forbidden metadata chunks.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: CodeQL analysis (python)
- GitHub Check: Agent
- GitHub Check: build (ubuntu-22.04)
- GitHub Check: build (ubuntu-24.04)
The initial window only allows to create or load... but if you press
Alt+F4 on Ubuntu 24.04, you can still close the window. We could re-open
it, but let's make it a hidden shortcut that the suggested new project name
is fine, and automatically create a directory.
This avoids such error: