Skip to content

Commit

Permalink
fix: 修复关闭窗口时的潜在崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Dec 3, 2024
1 parent beced2d commit c4cff28
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Magpie.App/ProfileViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,9 @@ fire_and_forget ProfileViewModel::_LoadIcon(FrameworkElement const& rootPage) {
std::wstring iconPath;
SoftwareBitmap iconBitmap{ nullptr };

if (_isProgramExist) {
auto weakThis = get_weak();
auto weakThis = get_weak();

if (_isProgramExist) {
const bool preferLightTheme = rootPage.ActualTheme() == ElementTheme::Light;
const bool isPackaged = _data->isPackaged;
const std::wstring path = _data->pathRule;
Expand Down Expand Up @@ -809,6 +809,10 @@ fire_and_forget ProfileViewModel::_LoadIcon(FrameworkElement const& rootPage) {
SoftwareBitmapSource imageSource;
co_await imageSource.SetBitmapAsync(iconBitmap);

if (!weakThis.get()) {
co_return;
}

MUXC::ImageIcon imageIcon;
imageIcon.Source(imageSource);

Expand Down

0 comments on commit c4cff28

Please sign in to comment.