Fix folder browser on Android and Windows

This commit is contained in:
Henrik Rydgård committed 2023-03-22 19:25:35 +01:00
1 parent 49efa4499e
commit b7350f3cbf
7 files changed
+54 -39

No files matched your search

+11 -8
View File
@@ -16,19 +16,22 @@ const char *RequestTypeAsString(SystemRequestType type) {
bool RequestManager::MakeSystemRequest(SystemRequestType type, RequestCallback callback, const std::string &param1, const std::string &param2, int param3) {
int requestId = idCounter_++;
// NOTE: We need to register immediately, in order to support synchronous implementations.
{
std::lock_guard<std::mutex> guard(callbackMutex_);
callbackMap_[requestId] = callback;
}
INFO_LOG(SYSTEM, "Making system request %s: id %d, callback_valid %d", RequestTypeAsString(type), requestId, callback != nullptr);
if (!System_MakeRequest(type, requestId, param1, param2, param3)) {
{
std::lock_guard<std::mutex> guard(callbackMutex_);
callbackMap_.erase(requestId);
}
return false;
}
if (!callback) {
// We don't expect a response, this is a one-directional request. We're thus done.
return true;
}
std::lock_guard<std::mutex> guard(callbackMutex_);
INFO_LOG(SYSTEM, "Registering pending callback %d", requestId);
callbackMap_[requestId] = callback;
return true;
}