-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tray Icon PR followup #10938
Tray Icon PR followup #10938
Changes from 1 commit
2c2a880
fdd14b3
b94e199
dd8d07e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,9 +92,13 @@ AppHost::AppHost() noexcept : | |
|
||
AppHost::~AppHost() | ||
{ | ||
if (_window->IsQuakeWindow()) | ||
if (_windowManager.IsMonarch()) | ||
{ | ||
_windowManager.RequestHideTrayIcon(); | ||
_DestroyTrayIcon(); | ||
} | ||
else if (_window->IsQuakeWindow()) | ||
{ | ||
_HideTrayIconRequested(); | ||
} | ||
|
||
// destruction order is important for proper teardown here | ||
|
@@ -656,9 +660,6 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s | |
{ | ||
_setupGlobalHotkeys(); | ||
|
||
// The monarch is just going to be THE listener for inbound connections. | ||
_listenForInboundConnections(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this change. Otherwise I'd approve this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh this was originally removed as part of this defapp bug fix #10823, and my bad merge left it in 😥. In short, the fix made it so that instead of making the monarch receive default terminal handoffs by default, the monarch should first figure out which peasant (or itself) should handle a default terminal handoff and tell that window to receive the connection. |
||
|
||
if (_windowManager.DoesQuakeWindowExist() || | ||
_window->IsQuakeWindow() || | ||
(_logic.GetAlwaysShowTrayIcon() || _logic.GetMinimizeToTray())) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad idea;
_HideTrayIconRequested
is a coroutine that takes an implicit reference tothis
, and you're dispatching it out of the destructor. By the time theresume_backround
resumes you,this
will have been destroyed.This needs to be restructured such that (1) the destructor never uses anything that requires a living
this
to persist after the destructor returns and (2) it is as small as possible 😄(Also, there's no guarantee that AppHost will be destructed.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a regular instance in
wWinMain
. It should be destroyed properly unless the appabort()
s, right?We could make a
_HideTrayIconRequestedAsync
and have_HideTrayIconRequested
run synchronously.BTW
_HideTrayIconRequested
accesses settings from a background thread which is a race condition... I think I should add thread asserts to CascadiaSettings. 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That does assume that main exits normally. If we were more like a standard UWP Xaml application, we would actually ExitProcess/TerminateProcess when the window was destroyed. The fact that we do not makes us uncommon in the world of Xaml, and is the cause for some of our "this object was already disposed of!" error traces on shutdown in debug mode. 😄
(Because of that, we've entertained the idea multiple times of switching -- it would clear up almost all of our on-exit crashes that originate deep inside Windows.UI.Xaml.dll!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm then I guess an alternative might be to do this particular Tray Icon cleanup in something like
LastTabClosed
?