Skip to content

Commit

Permalink
fix: Use ThreadScope::WithClassLoader to also load custom JNI Types (
Browse files Browse the repository at this point in the history
…mrousavy#2461)

* fix: Fix `ThreadScope` in `runAsync`

* fix: Use `&`

* Update JVisionCameraScheduler.cpp
  • Loading branch information
mrousavy authored Jan 30, 2024
1 parent 0a0cb69 commit c58c78a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ void JVisionCameraScheduler::dispatchAsync(const std::function<void()>& job) {

void JVisionCameraScheduler::scheduleTrigger() {
// 2.1 Open a JNI Thread scope because this might be called from a C++ background Thread
jni::ThreadScope scope;
// 2.2 schedule `triggerUI` to be called on the java thread
static auto method = _javaPart->getClass()->getMethod<void()>("scheduleTrigger");
method(_javaPart.get());
jni::ThreadScope::WithClassLoader([&]() {
// 2.2 schedule `triggerUI` to be called on the java thread
static auto method = _javaPart->getClass()->getMethod<void()>("scheduleTrigger");
method(_javaPart.get());
});
}

void JVisionCameraScheduler::trigger() {
Expand Down

0 comments on commit c58c78a

Please sign in to comment.