From 20161a2449961789a696144307135c8e5ce3277b Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Thu, 24 May 2018 21:11:55 +0300 Subject: [PATCH 1/4] Ignore visual studio 2015 cache folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ec62f9c05..a10b00460 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,5 @@ VCMI_VS11.opensdf /test/RD /VCMI_VS11.VC.opendb /AI/FuzzyLite.lib -/deps \ No newline at end of file +/deps +.vs/ From ee033e9c9cc4acce9dea23794e4b00b4f1a2c89d Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Fri, 25 May 2018 22:08:14 +0300 Subject: [PATCH 2/4] fix android build --- client/CServerHandler.cpp | 7 +++++++ client/widgets/TextControls.cpp | 4 ++-- lib/CAndroidVMHelper.cpp | 6 +++++- lib/CAndroidVMHelper.h | 2 ++ lib/CMakeLists.txt | 8 ++++---- server/CVCMIServer.cpp | 7 +++++++ 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index a1507f46e..0503257e1 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -22,6 +22,8 @@ #ifndef VCMI_ANDROID #include "../lib/Interprocess.h" +#else +#include "../lib/CAndroidVMHelper.h" #endif #include "../lib/CConfigHandler.h" #include "../lib/CGeneralTextHandler.h" @@ -44,6 +46,10 @@ template class CApplyOnLobby; +#ifdef VCMI_ANDROID +extern std::atomic_bool androidTestServerReadyFlag; +#endif + class CBaseForLobbyApply { public: @@ -151,6 +157,7 @@ void CServerHandler::startLocalServerAndConnect() #ifdef VCMI_ANDROID CAndroidVMHelper envHelper; envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true); + envHelper.Detach(); #else threadRunLocalServer = std::make_shared(&CServerHandler::threadRunServer, this); //runs server executable; #endif diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index 7646f9392..1f4f12b86 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -633,12 +633,12 @@ void CTextInput::notifyAndroidTextInputChanged(std::string & text) auto fun = [&text](JNIEnv * env, jclass cls, jmethodID method) { auto jtext = env->NewStringUTF(text.c_str()); - env->CallStaticObjectMethod(cls, method, jtext); + env->CallStaticVoidMethod(cls, method, jtext); env->DeleteLocalRef(jtext); }; CAndroidVMHelper vmHelper; vmHelper.callCustomMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "notifyTextInputChanged", - "(Ljava/lang/String;)V", fun); + "(Ljava/lang/String;)V", fun, true); } #endif //VCMI_ANDROID diff --git a/lib/CAndroidVMHelper.cpp b/lib/CAndroidVMHelper.cpp index dc0e2b6f9..f4365e1bc 100644 --- a/lib/CAndroidVMHelper.cpp +++ b/lib/CAndroidVMHelper.cpp @@ -42,8 +42,12 @@ CAndroidVMHelper::CAndroidVMHelper() detachInDestructor = false; } } - CAndroidVMHelper::~CAndroidVMHelper() +{ + Detach(); +} + +void CAndroidVMHelper::Detach() { if(envPtr && detachInDestructor) { diff --git a/lib/CAndroidVMHelper.h b/lib/CAndroidVMHelper.h index 48e77d1ae..2c859ddc9 100644 --- a/lib/CAndroidVMHelper.h +++ b/lib/CAndroidVMHelper.h @@ -29,6 +29,8 @@ public: ~CAndroidVMHelper(); + void Detach(); + JNIEnv * get(); jclass findClassloadedClass(const std::string & name); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b5de47afd..1120eccd3 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -168,10 +168,10 @@ set_source_files_properties(${CMAKE_BINARY_DIR}/Version.cpp ) set(lib_HEADERS - ${CMAKE_HOME_DIRECTORY}/include/vstd/CLoggerBase.h - ${CMAKE_HOME_DIRECTORY}/include/vstd/ContainerUtils.h - ${CMAKE_HOME_DIRECTORY}/include/vstd/RNG.h - ${CMAKE_HOME_DIRECTORY}/include/vstd/StringUtils.h + ../include/vstd/CLoggerBase.h + ../include/vstd/ContainerUtils.h + ../include/vstd/RNG.h + ../include/vstd/StringUtils.h StdInc.h ../Global.h diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index fb86032ca..18e7b1c86 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -170,10 +170,17 @@ void CVCMIServer::run() #endif startAsyncAccept(); + +#ifndef VCMI_ANDROID if(shm) { shm->sr->setToReadyAndNotify(port); } +#else + CAndroidVMHelper vmHelper; + vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "onServerReady"); + vmHelper.Detach(); +#endif } while(state == EServerState::LOBBY || state == EServerState::GAMEPLAY_STARTING) From dcbcff41dc0f0ce8e82c50b4d580022a61e771b6 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 26 May 2018 14:50:49 +0300 Subject: [PATCH 3/4] apply review comments for CAndroidVMHelper --- client/CServerHandler.cpp | 7 ++++--- lib/CAndroidVMHelper.cpp | 5 ----- lib/CAndroidVMHelper.h | 2 -- server/CVCMIServer.cpp | 1 - 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index 0503257e1..f41076b50 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -155,9 +155,10 @@ void CServerHandler::startLocalServerAndConnect() th->update(); #ifdef VCMI_ANDROID - CAndroidVMHelper envHelper; - envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true); - envHelper.Detach(); + { + CAndroidVMHelper envHelper; + envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true); + } #else threadRunLocalServer = std::make_shared(&CServerHandler::threadRunServer, this); //runs server executable; #endif diff --git a/lib/CAndroidVMHelper.cpp b/lib/CAndroidVMHelper.cpp index f4365e1bc..075bf71dd 100644 --- a/lib/CAndroidVMHelper.cpp +++ b/lib/CAndroidVMHelper.cpp @@ -43,11 +43,6 @@ CAndroidVMHelper::CAndroidVMHelper() } } CAndroidVMHelper::~CAndroidVMHelper() -{ - Detach(); -} - -void CAndroidVMHelper::Detach() { if(envPtr && detachInDestructor) { diff --git a/lib/CAndroidVMHelper.h b/lib/CAndroidVMHelper.h index 2c859ddc9..48e77d1ae 100644 --- a/lib/CAndroidVMHelper.h +++ b/lib/CAndroidVMHelper.h @@ -29,8 +29,6 @@ public: ~CAndroidVMHelper(); - void Detach(); - JNIEnv * get(); jclass findClassloadedClass(const std::string & name); diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 18e7b1c86..b2f97ecf2 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -179,7 +179,6 @@ void CVCMIServer::run() #else CAndroidVMHelper vmHelper; vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "onServerReady"); - vmHelper.Detach(); #endif } From eeb700cc7df3893266475266d407b3dff3d19741 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 26 May 2018 16:19:23 +0300 Subject: [PATCH 4/4] try fix CI --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 334fa470d..1536f7227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,8 @@ matrix: env: VCMI_PLATFORM='mac' addons: + apt: + update: true coverity_scan: project: name: vcmi/vcmi