Skip to content

Commit

Permalink
fix: 更好的解决双击关闭按钮闪退问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Jan 21, 2025
1 parent 536935a commit f6a8e73
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Magpie/XamlWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ class XamlWindowT : public WindowBaseT<T> {
}
case WM_DESTROY:
{
// 防止双击关闭按钮时崩溃。崩溃发生在 XAML Islands 内部,Win10 和 Win11 上都可以复现。
EnableWindow(this->Handle(), FALSE);
// 确保关闭过程中 _content 已经为空
_content = nullptr;

_xamlSourceNative2 = nullptr;
// 必须手动重置 Content,否则会内存泄露,使 RootPage 无法析构
Expand All @@ -386,8 +386,6 @@ class XamlWindowT : public WindowBaseT<T> {
_isMaximized = false;
_isLightTheme = true;

_content = nullptr;

Destroyed.Invoke();

LRESULT ret = base_type::_MessageHandler(msg, wParam, lParam);
Expand Down

0 comments on commit f6a8e73

Please sign in to comment.