diff --git a/loader/src/platform/mac/LoaderImpl.mm b/loader/src/platform/mac/LoaderImpl.mm index 34bc0ead..68c8cede 100644 --- a/loader/src/platform/mac/LoaderImpl.mm +++ b/loader/src/platform/mac/LoaderImpl.mm @@ -98,7 +98,12 @@ CFDataRef msgPortCallback(CFMessagePortRef port, SInt32 messageID, CFDataRef dat std::string cdata(reinterpret_cast(CFDataGetBytePtr(data)), CFDataGetLength(data)); - std::string reply = geode::ipc::processRaw(port, cdata).dump(); + auto res = geode::ipc::processRaw(port, cdata).dump(); + if (!res) { + log::warn("Failed to process IPC message: {}", res.unwrapErr()); + } + std::string reply = res.unwrapOr(""); + return CFDataCreate(NULL, (UInt8 const*)reply.data(), reply.size()); } diff --git a/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index b68def89..ea863c9d 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -78,7 +78,7 @@ namespace { @interface FileDialog : NSObject +(Result>) filePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult; -+(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult))onCompletion; ++(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult&&))onCompletion; @end @implementation FileDialog @@ -152,10 +152,10 @@ namespace { } } -+(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult))onCompletion { ++(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult&&))onCompletion { dispatch_async(dispatch_get_main_queue(), ^{ auto result = [self filePickerWithMode:mode options:options multiple:mult]; - onCompletion(result); + onCompletion(std::move(result)); }); } @@ -164,7 +164,7 @@ namespace { GEODE_DLL Task> file::pick(file::PickMode mode, file::FilePickOptions const& options) { using RetTask = Task>; return RetTask::runWithCallback([mode, options](auto resultCallback, auto progress, auto cancelled) { - [FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult result) { + [FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult&& result) { if (cancelled()) { resultCallback(RetTask::Cancel()); } else { @@ -182,11 +182,11 @@ GEODE_DLL Task> file::pick(file::PickMode mode, fi GEODE_DLL Task>> file::pickMany(file::FilePickOptions const& options) { using RetTask = Task>>; return RetTask::runWithCallback([options](auto resultCallback, auto progress, auto cancelled) { - [FileDialog dispatchFilePickerWithMode: file::PickMode::OpenFile options:options multiple:true onCompletion: ^(FileResult result) { + [FileDialog dispatchFilePickerWithMode: file::PickMode::OpenFile options:options multiple:true onCompletion: ^(FileResult&& result) { if (cancelled()) { resultCallback(RetTask::Cancel()); } else { - resultCallback(result); + resultCallback(std::move(result)); } }]; });