Skip to content

Minor: typo "Slop" -> "Slot" and missing [[nodiscard]] on Signal::subscribe() #1159

Description

@dingxiaoxv

In include/behaviortree_cpp/utils/signal.h:

  1. Doc comment typo: "Signal/Slop implementation" should be "Signal/Slot implementation" (line 11).

  2. Signal::subscribe() returns a Subscriber (a shared_ptr that is the only strong
    reference keeping the subscription alive; subscribers_ only holds a weak_ptr).
    If the caller discards the return value, the shared_ptr refcount drops to zero
    immediately, the weak_ptr expires, and the subscription is silently dropped before
    it can ever fire. Marking it [[nodiscard]] would catch this footgun at compile time:

    [[nodiscard]] Subscriber subscribe(CallableFunction func)

Happy to send a PR for both if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions