[PR #17199] Add nullptr checks to shared_ptr conversions #31157

Closed
opened 2026-01-31 09:45:28 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17199

State: closed
Merged: Yes


We use if (auto self = weakSelf.get()) in a lot of places.
That assigns the value to self and then checks if it's truthy.
Sometimes we need to add a "is (app) closing" check because XAML,
so we wrote something akin to if (self = ...; !closing).

But that's wrong because the correct if (foo) is the same as
if (void; foo) and not if (foo; void) and that meant that
we didn't check for self's truthiness anymore.

This issue became apparent now, because we added a new kind of
delayed callback invocation (which is a lot cheaper).
This made the lack of a nullptr check finally obvious.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/17199 **State:** closed **Merged:** Yes --- We use `if (auto self = weakSelf.get())` in a lot of places. That assigns the value to `self` and then checks if it's truthy. Sometimes we need to add a "is (app) closing" check because XAML, so we wrote something akin to `if (self = ...; !closing)`. But that's wrong because the correct `if (foo)` is the same as `if (void; foo)` and not `if (foo; void)` and that meant that we didn't check for `self`'s truthiness anymore. This issue became apparent now, because we added a new kind of delayed callback invocation (which is a lot cheaper). This made the lack of a `nullptr` check finally obvious.
claunia added the pull-request label 2026-01-31 09:45:28 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31157