Skip to content

Commit

Permalink
chore: 添加断言和注释
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Dec 16, 2024
1 parent 79174ef commit a4fb90f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/Magpie/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static void IncreaseTimerResolution() noexcept {
// 来自 https://github.com/CommunityToolkit/Microsoft.Toolkit.Win32/blob/6fb2c3e00803ea563af20f6bc9363091b685d81f/Microsoft.Toolkit.Win32.UI.XamlApplication/XamlApplication.cpp#L140
// 参见 https://github.com/microsoft/microsoft-ui-xaml/issues/7260#issuecomment-1231314776
static void FixThreadPoolCrash() noexcept {
assert(!GetModuleHandle(L"Windows.UI.Xaml.dll"));
LoadLibraryEx(L"twinapi.appcore.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
LoadLibraryEx(L"threadpoolwinrt.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
}
Expand Down Expand Up @@ -143,6 +144,7 @@ bool App::Initialize(const wchar_t* arguments) {
return false;
}

// 延迟注册 DependencyProperty,见 FixThreadPoolCrash
SettingsCard::RegisterDependencyProperties();
SettingsExpander::RegisterDependencyProperties();
SettingsGroup::RegisterDependencyProperties();
Expand Down
14 changes: 7 additions & 7 deletions src/Magpie/ContentDialogHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ using namespace Windows::UI::Xaml::Controls;

namespace Magpie {

//static weak_ref<ContentDialog> activeDialog{ nullptr };
static weak_ref<ContentDialog> activeDialog{ nullptr };

IAsyncOperation<ContentDialogResult> ContentDialogHelper::ShowAsync(ContentDialog dialog) {
//assert(activeDialog == nullptr);
assert(activeDialog == nullptr);

//activeDialog = dialog;
activeDialog = dialog;
ContentDialogResult result = co_await dialog.ShowAsync();
//activeDialog = nullptr;
activeDialog = nullptr;
co_return result;
}

bool ContentDialogHelper::IsAnyDialogOpen() noexcept {
return false;//activeDialog != nullptr;
return activeDialog != nullptr;
}

void ContentDialogHelper::CloseActiveDialog() {
/*if (activeDialog == nullptr) {
if (activeDialog == nullptr) {
return;
}

if (auto dialog = activeDialog.get()) {
dialog.Hide();
}*/
}
}

}

0 comments on commit a4fb90f

Please sign in to comment.