Skip to content

Commit

Permalink
use C++ API directly instead of C wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Mar 5, 2025
1 parent e950006 commit f978583
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/CxxFlutterSwift/CxxFlutterSwift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ void FlutterDesktopMessengerSetCallbackBlock(
std::lock_guard<std::mutex> guard(flutterSwiftCallbacksMutex);
if (callbackBlock != nullptr) {
flutterSwiftCallbacks[channel] = _Block_copy(callbackBlock);
FlutterDesktopMessengerSetCallback(
messenger, channel, FlutterDesktopMessageCallbackThunk, callbackBlock);
messenger->GetEngine()->message_dispatcher()->SetMessageCallback(
channel, FlutterDesktopMessageCallbackThunk, callbackBlock);
} else {
auto savedCallbackBlock = flutterSwiftCallbacks[channel];
flutterSwiftCallbacks.erase(channel);
_Block_release(savedCallbackBlock);
FlutterDesktopMessengerSetCallback(messenger, channel, nullptr, nullptr);
messenger->GetEngine()->message_dispatcher()->SetMessageCallback(
channel, nullptr, nullptr);
}
}

Expand All @@ -106,8 +107,8 @@ void FlutterDesktopPluginRegistrarSetDestructionHandlerBlock(
FlutterDesktopOnPluginRegistrarDestroyedBlock callbackBlock) {
std::lock_guard<std::mutex> guard(flutterSwiftRegistrarCallbacksMutex);
flutterSwiftRegistrarCallbacks[registrar] = _Block_copy(callbackBlock);
FlutterDesktopPluginRegistrarSetDestructionHandler(
registrar, FlutterDesktopOnPluginRegistrarDestroyedBlockThunk);
registrar->engine->SetPluginRegistrarDestructionCallback(
FlutterDesktopOnPluginRegistrarDestroyedBlockThunk);
}

void FlutterDesktopEngineSetView(FlutterDesktopEngineRef engineRef,
Expand Down

0 comments on commit f978583

Please sign in to comment.