Commit ec04df85 authored by Andrew Twyman's avatar Andrew Twyman

Merge pull request #178 from PSPDFKit-labs/izacus/fix_set_marshaling

Fix crash when marshaling sets to Java
parents 4ce26966 654a8a37
......@@ -411,13 +411,14 @@ namespace djinni
static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c)
{
assert(c.size() <= std::numeric_limits<jint>::max());
const auto& data = JniClass<SetJniInfo>::get();
auto j = LocalRef<jobject>(jniEnv, jniEnv->NewObject(data.clazz.get(), data.constructor));
assert(c.size() <= std::numeric_limits<jint>::max());
auto size = static_cast<jint>(c.size());
auto j = LocalRef<jobject>(jniEnv, jniEnv->NewObject(data.clazz.get(), data.constructor, size));
jniExceptionCheck(jniEnv);
for(const auto& ce : c)
{
auto je = T::fromCpp(jniEnv, ce);
auto je = T::Boxed::fromCpp(jniEnv, ce);
jniEnv->CallBooleanMethod(j, data.method_add, get(je));
jniExceptionCheck(jniEnv);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment