Skip to content

Commit

Permalink
fix: Fix missing OnEvent callbacks with IrisMethodChannel used by mul…
Browse files Browse the repository at this point in the history
…tiple packages
  • Loading branch information
littleGnAl committed Oct 10, 2024
1 parent 56c024e commit afd47b4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/iris_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,32 @@ class DartMessageHandlerManager : public DartMessageHandlerBase

std::mutex message_handler_mutex_;
std::unique_ptr<DartMessageHandlerManager> dartMessageHandlerManager_ = nullptr;
int init_dart_api_times_ = 0;

// Initialize `dart_api_dl.h`
EXPORT intptr_t InitDartApiDL(void *data)
{
std::lock_guard<std::mutex> lock(message_handler_mutex_);
if (!dartMessageHandlerManager_)
int ret = 0;
if (init_dart_api_times_ == 0 && !dartMessageHandlerManager_)
{
dartMessageHandlerManager_ = std::make_unique<DartMessageHandlerManager>();
ret = dartMessageHandlerManager_->InitDartApiDL(data);
}

return dartMessageHandlerManager_->InitDartApiDL(data);
++init_dart_api_times_;

return ret;
}

EXPORT void Dispose()
{
std::lock_guard<std::mutex> lock(message_handler_mutex_);
dartMessageHandlerManager_.reset();
--init_dart_api_times_;
if (init_dart_api_times_ == 0)
{
dartMessageHandlerManager_.reset();
}
}

EXPORT void OnEvent(EventParam *param)
Expand Down

0 comments on commit afd47b4

Please sign in to comment.