From 8323333c448ea892fc903f3fe75ae344cee7c14a Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 7 Aug 2023 17:16:04 +0200 Subject: [PATCH] Fix SuggestionIterator hasNext. --- lib/src/main/cpp/libzim/suggestion_iterator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/main/cpp/libzim/suggestion_iterator.cpp b/lib/src/main/cpp/libzim/suggestion_iterator.cpp index 9fe6cd8..8211fc2 100644 --- a/lib/src/main/cpp/libzim/suggestion_iterator.cpp +++ b/lib/src/main/cpp/libzim/suggestion_iterator.cpp @@ -42,13 +42,13 @@ METHOD0(void, dispose) } CATCH_EXCEPTION() METHOD0(jboolean, hasNext) { - NATIVE_TYPE next(*THIS); - next++; + // THIS is the next item to return. So we have to check it with end auto end = getPtr(env, thisObj, "nativeHandleEnd"); - return next == *end; + return *THIS != *end; } CATCH_EXCEPTION(false) METHOD0(jobject, next) { + zim::SuggestionItem item = **THIS; (*THIS)++; return BUILD_WRAPPER("org/kiwix/libzim/SuggestionItem", item);