fix dangling string crash on modpopup

This commit is contained in:
matcool 2024-11-15 11:56:46 -03:00
parent ecec11fa93
commit 9834cb2a22

View file

@ -51,11 +51,16 @@ protected:
} }
void onRequest(Request::Event* event) { void onRequest(Request::Event* event) {
if (event->getValue() && event->getValue()->isOk() && event->getValue()->inspect([](auto&& value) { return value.has_value(); })) { if (auto* res = event->getValue(); res && res->isOk()) {
m_loading->removeFromParent(); auto value = std::move(*res).unwrap();
m_textarea->setString(event->getValue()->unwrap()->c_str()); if (value) {
m_loading->removeFromParent();
std::string str = std::move(value).value();
m_textarea->setString(str.c_str());
return;
}
} }
else if (!event->getProgress()) { if (!event->getProgress()) {
m_loading->removeFromParent(); m_loading->removeFromParent();
m_textarea->setString(m_noneText.c_str()); m_textarea->setString(m_noneText.c_str());
} }