Skip to content

Create a separate receiver object for each signal/callable connect - #365

Open
usiems wants to merge 2 commits into
mainfrom
fix_signal_to_callable_connects_2
Open

Create a separate receiver object for each signal/callable connect#365
usiems wants to merge 2 commits into
mainfrom
fix_signal_to_callable_connects_2

Conversation

@usiems

@usiems usiems commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This way we can't run out of slot IDs.
This fixes #362

This also enables us to associate the receiver with the instance object of the callable (if it is a method of a QObject-derived class) instead of the sender, so that it is associated with the correct thread, which is important for the AutoConnection used.
In a way this also fixes the problem in #363, because now the receiver object should always live in the same thread as the self object of the callable. The connection to a callable doesn't use the actual slot defined by a slot decorator, but the effect should be largely the same.

Note that this might change the behavior of signal/callable connections when threads are used, so users need to test if their uses still work for them.

This way we can't run out of slot IDs.
This fixes #362
This also enables us to associate the receiver with the instance object
of the callable (if it is a method of a QObject-derived class) instead
of the sender, so that it is associated with the correct thread, which
is important for the AutoConnection used.
In a way this also fixes the problem in #363

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
@usiems
usiems force-pushed the fix_signal_to_callable_connects_2 branch from f78e9bf to 3390891 Compare August 28, 2026 14:31
Comment thread src/PythonQt.cpp Outdated
Comment thread src/PythonQt.cpp
Comment thread src/PythonQt.cpp Outdated
Comment thread src/PythonQt.cpp Outdated
Comment thread src/PythonQtSignalReceiver.h Outdated
Comment thread src/PythonQtSignalReceiver.h Outdated

@mrbean-bremen mrbean-bremen 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.

Looks good as far as I can see (though I may miss some possible implications)

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.

Can't connect and disconnect Python callables to signals indefinitely

2 participants