Skip to content

Fix project switching bug - #68

Open
lisham2000 wants to merge 2 commits into
nion-software:masterfrom
lisham2000:axes-update
Open

lisham2000 wants to merge 2 commits into
nion-software:masterfrom
lisham2000:axes-update

Conversation

@lisham2000

@lisham2000 lisham2000 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes https://github.com/nion-software/nion-internal/issues/366

Does not currently fix scan axis additional rotation but does fix a bug that occurred giving a traceback when axes were present project switching bug. Swaps all ui functions to being selected display item only

@lisham2000
lisham2000 requested review from Ion-e and KRLango September 17, 2026 14:47

@KRLango KRLango left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few changes on the project switching. The scoping change looks good to me though.

except (AttributeError, RuntimeError):
return None

fallback_window: Facade.DocumentWindow | None = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The name fallback_window needs some explanation as to why this is the window that should be used as the fallback.

if window.target_display is not None:
try:
target_display = window.target_display
window.target_data_item

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What are you trying to achieve with this line?

target_display = window.target_display
window.target_data_item
except (AttributeError, RuntimeError):
# Workspace/project changes can temporarily expose PopupWindow objects.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would an explicit check for a popup window be better rather than relying on exceptions?

# Workspace/project changes can temporarily expose PopupWindow objects.
continue

if fallback_window is None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will always select the first window that passes the previous checks. A comment for why this one is correct should be added.


if target_display is not None:
return target_display.data_item
except (AttributeError, RuntimeError):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would checking the type of the window or getattr calls be better here rather than using exceptions as flow control?

This branch has not been deployed

No deployments
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.

2 participants