[sword-svn] r3231 - trunk/bindings/java-jni/jni

scribe at crosswire.org scribe at crosswire.org
Wed May 14 10:30:08 MST 2014


Author: scribe
Date: 2014-05-14 10:30:08 -0700 (Wed, 14 May 2014)
New Revision: 3231

Modified:
   trunk/bindings/java-jni/jni/Android.mk
   trunk/bindings/java-jni/jni/swordstub.cpp
Log:
fixed progress reporting to check to be sure we've been given a progress
reporter before attempting to report

Modified: trunk/bindings/java-jni/jni/Android.mk
===================================================================
--- trunk/bindings/java-jni/jni/Android.mk	2014-05-14 17:30:00 UTC (rev 3230)
+++ trunk/bindings/java-jni/jni/Android.mk	2014-05-14 17:30:08 UTC (rev 3231)
@@ -36,6 +36,9 @@
 		   -DEXCLUDEBZIP2 \
 		   -DEXCLUDEXZ \
 		   -DOS_ANDROID
+
+#LOCAL_CFLAGS	+= -g
+
 LOCAL_SRC_FILES := ../../../src/modules/comments/zcom/zcom.cpp \
 ../../../src/modules/comments/rawfiles/rawfiles.cpp \
 ../../../src/modules/comments/rawcom4/rawcom4.cpp \

Modified: trunk/bindings/java-jni/jni/swordstub.cpp
===================================================================
--- trunk/bindings/java-jni/jni/swordstub.cpp	2014-05-14 17:30:00 UTC (rev 3230)
+++ trunk/bindings/java-jni/jni/swordstub.cpp	2014-05-14 17:30:08 UTC (rev 3231)
@@ -66,6 +66,10 @@
 		last = 0xffffffff;
 	}
         virtual void update(unsigned long totalBytes, unsigned long completedBytes) {
+
+		// assert we have a callback
+		if (!callback) return;
+
 		if (completedBytes != last) {
 			last = completedBytes;
 			jclass cls = env->GetObjectClass(callback);
@@ -92,6 +96,10 @@
 */
 	}
         virtual void preStatus(long totalBytes, long completedBytes, const char *message) {
+
+		// assert we have a callback
+		if (!callback) return;
+
 		jclass cls = env->GetObjectClass(callback);
 		jmethodID mid = env->GetMethodID(cls, "preStatus", "(JJLjava/lang/String;)V");
 		if (mid != 0) {
@@ -1194,6 +1202,9 @@
 void percentUpdate(char percent, void *userData) {
 	struct pu *p = (struct pu *)userData;
 
+	// assert we've actually been given a progressReporter
+	if (!p->progressReporter) return;
+
 	if (percent != p->last) {
 		p->last = percent;
 		jclass cls = p->env->GetObjectClass(p->progressReporter);
@@ -1511,14 +1522,16 @@
 
 	int error = installMgr->installModule(mgr, 0, module->getName(), is);
 
-	jclass cls = env->GetObjectClass(progressReporter);
-	jmethodID mid = env->GetMethodID(cls, "preStatus", "(JJLjava/lang/String;)V");
-	if (mid != 0) {
-		jstring msg = env->NewStringUTF("Complete");
-		env->CallVoidMethod(progressReporter, mid, (jlong)0, (jlong)0, msg);
-		env->DeleteLocalRef(msg);
+	if (progressReporter) {
+		jclass cls = env->GetObjectClass(progressReporter);
+		jmethodID mid = env->GetMethodID(cls, "preStatus", "(JJLjava/lang/String;)V");
+		if (mid != 0) {
+			jstring msg = env->NewStringUTF("Complete");
+			env->CallVoidMethod(progressReporter, mid, (jlong)0, (jlong)0, msg);
+			env->DeleteLocalRef(msg);
+		}
+		env->DeleteLocalRef(cls);
 	}
-	env->DeleteLocalRef(cls);
 
 	return error;
 }




More information about the sword-cvs mailing list