Skip to content

Commit

Permalink
~
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed Apr 25, 2024
1 parent 155b4dc commit 00f2651
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions nativeLibs/djvuModule/jni/djvu.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,13 @@ JNI_FN(DjvuDocument_openFile)(JNIEnv *env, jclass type, jstring jfileName, jlong
const char *fileName = jfileName;
#endif

int failed = 0;
LOGI("Opening document: %s", fileName);
ddjvu_document_t *doc = ddjvu_document_create_by_filename_utf8(context, fileName, 0);
if (!doc) {
failed = handle_error_if_present(env, context) ||
record_jni_error(env, "Djvu file not found or corrupted!");
}

LOGI("Start decoding document: %p", doc);

ddjvu_status_t r;
while (!failed && (r = ddjvu_document_decoding_status(doc)) < DDJVU_JOB_OK) {
int failed = 0;
while (doc && (r = ddjvu_document_decoding_status(doc)) < DDJVU_JOB_OK) {
failed = handle_ddjvu_messages_and_wait(env, context);
}

Expand All @@ -114,8 +110,8 @@ JNI_FN(DjvuDocument_openFile)(JNIEnv *env, jclass type, jstring jfileName, jlong
*docInfo = pageNum;
#endif
} else {
if (!failed) {
failed = handle_error_if_present(env, context);
if (!failed && (doc == NULL || r == DDJVU_JOB_FAILED)) {
failed = handle_ddjvu_messages_and_wait(env, context);
}
LOGE("Error during document opening: %p, status=%d, failed=%d", doc, r, failed);
ddjvu_document_release(doc);
Expand Down

0 comments on commit 00f2651

Please sign in to comment.