Skip to content

Fix cross-thread access to package objects during Python script evaluation in wizards#651

Open
marvinoe21 wants to merge 7 commits intomasterfrom
fix/python-wizard-eval-thread-affinity
Open

Fix cross-thread access to package objects during Python script evaluation in wizards#651
marvinoe21 wants to merge 7 commits intomasterfrom
fix/python-wizard-eval-thread-affinity

Conversation

@marvinoe21
Copy link
Copy Markdown
Collaborator

@marvinoe21 marvinoe21 commented Mar 26, 2026

This PR fixes a thread-affinity issue in Python scripting wizards. Package objects were cloned on the GUI thread and added to the Python context, while script evaluation was executed asynchronously on a different thread. When a script accessed one of these package objects, Qt could report thread-related assertion messages.

The fix moves wizard script evaluation to a dedicated worker thread and temporarily moves the exposed package objects to that thread for the duration of the evaluation. After the script finishes, the objects are moved back to the GUI thread. Live code completion is temporarily disabled while a script is running, because completion introspection could otherwise access the package objects from the GUI thread and trigger the same issue. As part of the cleanup, the old GtpyScriptRunnable was removed.

Fixes #650

@marvinoe21 marvinoe21 modified the milestones: 1.9.0, 2.0.0 Mar 26, 2026
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.

Unsafe cross-thread access to package objects during Python script evaluation in wizards

1 participant