diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2024-08-22 22:30:25 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2024-08-22 22:30:25 +0200 |
| commit | e38036e670d234b36053e03be92dd8f27acb16c0 (patch) | |
| tree | ad7ac56ca22db512fcb66254db77102fe113a4db /libs/samba/src/main/cpp/samba.cpp | |
| parent | 8f506f21cbf127832bf47f9ca1f6cb18bfe80089 (diff) | |
samba: Cleanup jni layer
Remember that jni::GlobalRef can be used on multiple threads so
we can't store the env, need to call AttachCurrentThread.
Fix AttachCurrentThread (g_vm was forgotten).
More consistent move and copy constructors in refs. Removed env()
method as it would only be valid for Param and Local anyway.
Diffstat (limited to 'libs/samba/src/main/cpp/samba.cpp')
| -rw-r--r-- | libs/samba/src/main/cpp/samba.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/samba/src/main/cpp/samba.cpp b/libs/samba/src/main/cpp/samba.cpp index 1d1d9d2..1e6b425 100644 --- a/libs/samba/src/main/cpp/samba.cpp +++ b/libs/samba/src/main/cpp/samba.cpp @@ -260,6 +260,12 @@ void RegisterSamba(JNIEnv* env) { g_DirEntryClass = dir_entry_clazz; } +void UnregisterSamba() { + g_CreateDirEntry = 0; + g_NativeSambaClass.reset(); + g_DirEntryClass.reset(); +} + jni::LocalRef<jobject> CreateDirEntry(JNIEnv* env, const std::string& name, const smb2_stat_64& stat) { auto j_name = jni::UTF8ToString(env, name); // Kotlin size casts Long to ULong @@ -292,3 +298,8 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) { return jni::JNI_VERSION; } + +void JNI_OnUnload(JavaVM *vm, void *reserved) { + // Not called on Android (or in general), but if it where, this would be the place to unregister. + UnregisterSamba(); +} |
