notify_send(ctx->notify, NT_CONTEXT, NT_CONTEXT_CLOSE, IP & ev_ctx);
if (ctx->mailbox)
- notify_observer_remove(ctx->mailbox->notify, ctx_mailbox_observer);
+ notify_observer_remove(ctx->mailbox->notify, ctx_mailbox_observer, IP ctx);
notify_free(&ctx->notify);
FREE(&ctx->pattern);
mutt_pattern_free(&ctx->limit_pattern);
if (ctx->mailbox)
- notify_observer_remove(ctx->mailbox->notify, ctx_mailbox_observer);
+ notify_observer_remove(ctx->mailbox->notify, ctx_mailbox_observer, IP ctx);
struct Notify *notify = ctx->notify;
memset(ctx, 0, sizeof(struct Context));
struct Notify *notify = *ptr;
// NOTIFY observers
- notify_observer_remove(notify, NULL);
+ notify_observer_remove(notify, NULL, 0);
FREE(ptr);
}
* notify_observer_remove - Remove an observer from an object
* @param notify Notification handler
* @param callback Function to call on a matching event, see ::observer_t
+ * @param data Private data to match specific callback
* @retval true If successful
*
* If callback is NULL, all the observers will be removed.
*/
-bool notify_observer_remove(struct Notify *notify, observer_t callback)
+bool notify_observer_remove(struct Notify *notify, observer_t callback, intptr_t data)
{
if (!notify)
return false;
struct ObserverNode *tmp = NULL;
STAILQ_FOREACH_SAFE(np, ¬ify->observers, entries, tmp)
{
- if (!callback || (np->observer->callback == callback))
+ if (!callback || ((np->observer->callback == callback) && (np->observer->data == data)))
{
STAILQ_REMOVE(¬ify->observers, np, ObserverNode, entries);
FREE(&np->observer);
bool notify_send(struct Notify *notify, int type, int subtype, intptr_t data);
bool notify_observer_add(struct Notify *notify, enum NotifyType type, int subtype, observer_t callback, intptr_t data);
-bool notify_observer_remove(struct Notify *notify, observer_t callback);
+bool notify_observer_remove(struct Notify *notify, observer_t callback, intptr_t data);
#endif /* MUTT_LIB_NOTIFY_H */