async: add Promise and use it for AsyncDialogBox

This commit is contained in:
Vaxry 2025-04-27 00:03:32 +01:00
parent 4f868a1f3c
commit 0302bfdc22
No known key found for this signature in database
GPG key ID: 665806380871D640
7 changed files with 208 additions and 36 deletions

View file

@ -169,7 +169,14 @@ void CANRManager::SANRData::runDialog(const std::string& title, const std::strin
appClass.empty() ? "unknown" : appClass),
std::vector<std::string>{"Terminate", "Wait"});
dialogBox->open([dialogWmPID, this](std::string result) {
dialogBox->open()->then([dialogWmPID, this](SP<CPromiseResult<std::string>> r) {
if (r->hasError()) {
Debug::log(ERR, "CANRManager::SANRData::runDialog: error spawning dialog");
return;
}
const auto& result = r->result();
if (result.starts_with("Terminate"))
::kill(dialogWmPID, SIGKILL);
else if (result.starts_with("Wait"))