Skip to content

Commit

Permalink
don't use withUnsafeBytes(of:), seems to not work properly on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed May 3, 2024
1 parent e47e617 commit 1820a05
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/FlutterSwift/Messenger/FlutterDesktopMessenger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public actor FlutterDesktopMessenger: FlutterBinaryMessenger {
) throws {
precondition(isAvailable)

guard withUnsafeBytes(of: message, { bytes in
let message = [UInt8](message ?? Data())

guard message.withUnsafeBytes({ bytes in
// run on main actor, so don't need to take lock
FlutterDesktopMessengerSendWithReplyBlock(
messenger,
Expand Down Expand Up @@ -101,12 +103,13 @@ public actor FlutterDesktopMessenger: FlutterBinaryMessenger {
}

// FIXME: do we need to take a lock here? doesn't look like other platforms do
withUnsafeBytes(of: response) {
let response = [UInt8](response ?? Data())
response.withUnsafeBytes {
FlutterDesktopMessengerSendResponse(
messenger,
handle,
$0.baseAddress,
response?.count ?? 0
response.count
)
}
}
Expand Down

0 comments on commit 1820a05

Please sign in to comment.