mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
fix crash when missing base directory method
This commit is contained in:
parent
91c68f525b
commit
c1a0969af7
1 changed files with 13 additions and 0 deletions
|
@ -45,6 +45,17 @@ CCPoint cocos::getMousePos() {
|
|||
}
|
||||
|
||||
namespace {
|
||||
void clearJNIException() {
|
||||
// this is a silly workaround to not crash when the method is not found.
|
||||
// cocos figured this out half a year later...
|
||||
auto vm = JniHelper::getJavaVM();
|
||||
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) == JNI_OK) {
|
||||
env->ExceptionClear();
|
||||
}
|
||||
}
|
||||
|
||||
ghc::filesystem::path getBaseDir() {
|
||||
JniMethodInfo t;
|
||||
std::string path = "/storage/emulated/0/Android/data/com.geode.launcher/files";
|
||||
|
@ -54,6 +65,8 @@ namespace {
|
|||
t.env->DeleteLocalRef(t.classID);
|
||||
path = JniHelper::jstring2string(str);
|
||||
t.env->DeleteLocalRef(str);
|
||||
} else {
|
||||
clearJNIException();
|
||||
}
|
||||
|
||||
return ghc::filesystem::path(path);
|
||||
|
|
Loading…
Reference in a new issue