Skip to content

tcl/tk: Fix layer toolbar icon synchronization on left-click#508

Closed
Ahmed-Nematallah wants to merge 2 commits into
RTimothyEdwards:masterfrom
Ahmed-Nematallah:Ahmed-Nematallah-patch-2
Closed

tcl/tk: Fix layer toolbar icon synchronization on left-click#508
Ahmed-Nematallah wants to merge 2 commits into
RTimothyEdwards:masterfrom
Ahmed-Nematallah:Ahmed-Nematallah-patch-2

Conversation

@Ahmed-Nematallah
Copy link
Copy Markdown
Contributor

There is a bug where left-clicking a hidden layer in the toolbar successfully makes the layer visible in the layout but fails to update the toolbar icon to the "active" state.

The root cause is a positional argument mismatch in magic::toolupdate. When the Magic C-core issues a callback for a "see" command with two arguments, the third argument (layerlist) is passed as an empty string ("") rather than being omitted. This prevents the Tcl procedure from falling back to its hardcoded default of "none", causing the script to skip the logic that reassigns $yesno to "yes".

This patch changes the default value of $layerlist to "" and updates the conditional check to ensure the state and layer name are correctly reassigned regardless of how the C-core signals the update.

This pull request fixes Issue #507

There is a bug where left-clicking a hidden layer in the toolbar successfully makes the layer visible in the layout but fails to update the toolbar icon to the "active" state.

The root cause is a positional argument mismatch in magic::toolupdate. When the Magic C-core issues a callback for a "see" command with two arguments, the third argument (layerlist) is passed as an empty string ("") rather than being omitted. This prevents the Tcl procedure from falling back to its hardcoded default of "none", causing the script to skip the logic that reassigns $yesno to "yes".

This patch changes the default value of $layerlist to "" and updates the conditional check to ensure the state and layer name are correctly reassigned regardless of how the C-core signals the update.
@dlmiles dlmiles self-requested a review May 2, 2026 18:27
@dlmiles
Copy link
Copy Markdown
Collaborator

dlmiles commented May 2, 2026

Feedback comments inline review.

Comment thread tcltk/wrapper.tcl Outdated
if { $Winopts(${topname},toolbar) == 0 } { return }

if {$layerlist == "none"} {
if {$layerlist == ""} {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

consider if {$layerlist == "" || $layerlist == "none"} {

This seems more defensive programming, backwards compatible and manages both values in the same way. Unless a blank string "" has a specific and independent meaning than "none" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. In my testing with "see metal1", I observed an empty string being passed, which matches the default operands in most other Magic procedures. But it is understandable to keep backward compatibility.

(I did briefly wonder if someone might name a layer 'none', but that’s highly unlikely! 😬)

I guess the best approach is keeping the default argument as an empty string, checking for both, and adding a comment indicating you should not call a layer "none"

I'll update the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @dlmiles, I tested the new version and it works.

Added check for 'none' layer name to ensure backwards compatibility.
Copy link
Copy Markdown
Owner

@RTimothyEdwards RTimothyEdwards left a 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.

@RTimothyEdwards
Copy link
Copy Markdown
Owner

Pulled and merged to the opencircuitdesign.com database. The github version will update overnight.

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.

3 participants