Skip to content

Fix crashes when a Python grid cell editor overrides TryActivate - #3009

Merged
swt2c merged 1 commit into
wxWidgets:masterfrom
swt2c:issue_2899
Nov 3, 2026
Merged

swt2c merged 1 commit into
wxWidgets:masterfrom
swt2c:issue_2899

Conversation

@swt2c

@swt2c swt2c commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

The virtual handler for TryActivate couldn't copy the Python result into its return value, because wxGridActivationResult has const members and so no assignment operator. sip then called a NULL assign helper, which asserts in debug builds and is an access violation in release builds. The handler's %InstanceCode also kept a pointer to a stack local, so its default result pointed at a destroyed object.

Give TryActivate a virtual catcher that copy-constructs the result and returns it directly, reporting an error and returning DoNothing() when the Python method fails or returns the wrong type, and make the default result static.

Fixes #2899

The virtual handler for TryActivate couldn't copy the Python result into
its return value, because wxGridActivationResult has const members and so
no assignment operator. sip then called a NULL assign helper, which asserts
in debug builds and is an access violation in release builds. The handler's
%InstanceCode also kept a pointer to a stack local, so its default result
pointed at a destroyed object.

Give TryActivate a virtual catcher that copy-constructs the result and
returns it directly, reporting an error and returning DoNothing() when the
Python method fails or returns the wrong type, and make the default result
static.

Fixes wxWidgets#2899
@swt2c
swt2c merged commit a150fd6 into wxWidgets:master Nov 3, 2026
15 checks passed
@swt2c
swt2c deleted the issue_2899 branch November 3, 2026 04:01
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.

Python crash using custom property in property grid

1 participant