[Tizen.System.Session] Ensure no-op (un)registration works correctly - #7848
Merged
Merged
Conversation
The C# bindings coalesce multiple C# callbacks into one C callback,
which is registered with the first C# callback and unregistered with the
last C# callback. These operations should only happen on non-null<>null
edges, otherwise there might be multiple registrations, or we can
attempt unregistering when there is no registration.
However C# delegate removal and combination operators is actually more
flexible than expected, in particular C# accepts nulls in both cases.
Additionally, removal allows unregistering callbacks that are not
registered, which is a no-op. These cases mean that some operations can
start from a null and end in a null. In this case, we will call C
callback (un)registration incorrectly.
This commit adds null checks:
- registrations check if the callback being registered is non-null,
- if it is a non-null, the result will always be non-null,
- if it is a null, it is safe to return because adding a null does not
do anything,
- unregistrations check if the existing callback list is non-null,
- it being non-null is enough to eliminate null<>null edges,
- if it is a null, it is safe to return because there is nothing to
unregister anyway.
mbloch1
approved these changes
Sep 16, 2026
Member
|
🤖 [AI Review] Reviewed — no findings. Scope checked:
No 🔴 critical issues, no 🟡 suggestions to flag. Automated review — final merge decision rests with human reviewers. |
chanwoochoi
approved these changes
Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
The C# bindings coalesce multiple C# callbacks into one C callback, which is registered with the first C# callback and unregistered with the last C# callback. These operations should only happen on non-null<>null edges, otherwise there might be multiple registrations, or we can attempt unregistering when there is no registration.
However C# delegate removal and combination operators is actually more flexible than expected, in particular C# accepts nulls in both cases. Additionally, removal allows unregistering callbacks that are not registered, which is a no-op. These cases mean that some operations can start from a null and end in a null. In this case, we will call C callback (un)registration incorrectly.
This commit adds null checks:
API Changes
None