From 995ad90a59277237f58df6458677ff79369e90a2 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 1 Jul 2020 16:39:35 +0200 Subject: [PATCH] Add new thread safe suggestion API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous API were using an internal vector to store the suggestions search results. The new API takes a vector as out argument. So user can call the functions without having to protect the search. We should change the android API to reflect the change but it is a bit more complex to do at JNI level. As android do not call it multithreaded we are safe for now. And we need the new API asap for kiwix-desktop. So we keep the same API on android for now, the new api will be made in next version. --- src/wrapper/java/kiwixreader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wrapper/java/kiwixreader.cpp b/src/wrapper/java/kiwixreader.cpp index 978199a..36be34a 100644 --- a/src/wrapper/java/kiwixreader.cpp +++ b/src/wrapper/java/kiwixreader.cpp @@ -355,9 +355,12 @@ Java_org_kiwix_kiwixlib_JNIKiwixReader_searchSuggestions(JNIEnv* env, unsigned int cCount = jni2c(count, env); try { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" if (READER->searchSuggestionsSmart(cPrefix, cCount)) { retVal = JNI_TRUE; } +#pragma GCC diagnostic pop } catch (std::exception& e) { LOG("Unable to get search results for pattern: %s", cPrefix.c_str()); LOG(e.what()); @@ -377,11 +380,14 @@ Java_org_kiwix_kiwixlib_JNIKiwixReader_getNextSuggestion(JNIEnv* env, std::string cUrl; try { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" if (READER->getNextSuggestion(cTitle, cUrl)) { setStringObjValue(cTitle, titleObj, env); setStringObjValue(cUrl, urlObj, env); retVal = JNI_TRUE; } +#pragma GCC diagnostic pop } catch (std::exception& e) { LOG("Unable to get next suggestion"); LOG(e.what());