From 9d130870362ef66bd56d6ff981796295b7f5bea2 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 15 Dec 2018 16:35:37 +0100 Subject: [PATCH] fix recurseve mutex on Android --- android/src/main/cpp/main.cpp | 6 ++++-- src/app_layout.cpp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/android/src/main/cpp/main.cpp b/android/src/main/cpp/main.cpp index 3591e67..840aef0 100755 --- a/android/src/main/cpp/main.cpp +++ b/android/src/main/cpp/main.cpp @@ -16,6 +16,7 @@ */ //BEGIN_INCLUDE(all) +#include #include #include #include @@ -51,6 +52,7 @@ typedef void (*fnDebugMessageCallback)(GLDEBUGPROC callback, const void* userPar EGLDisplay g_display = EGL_NO_DISPLAY; EGLContext g_context = EGL_NO_CONTEXT; +std::recursive_mutex mutex; jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) { @@ -124,7 +126,7 @@ int GetUnicodeChar(struct android_app* app, int eventType, int keyCode, int meta void android_async_lock(struct engine* engine) { - pthread_mutex_lock(&engine->app->mutex); + mutex.lock(); eglMakeCurrent(engine->display, engine->surface, engine->surface, engine->context); } @@ -136,7 +138,7 @@ void android_async_swap(struct engine* engine) void android_async_unlock(struct engine* engine) { eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - pthread_mutex_unlock(&engine->app->mutex); + mutex.unlock(); } struct locker diff --git a/src/app_layout.cpp b/src/app_layout.cpp index 285daab..b1865d8 100644 --- a/src/app_layout.cpp +++ b/src/app_layout.cpp @@ -388,6 +388,7 @@ void App::init_menu_file() b->on_click = [this](Node*) { App::I.pick_image([this](std::string path){ Image img; + async_start(); img.load_file(path); if (img.width == img.height / 6 || img.width == img.height * 2) { @@ -400,6 +401,8 @@ void App::init_menu_file() m->m_source_image = std::move(img); Canvas::set_mode(Canvas::kCanvasMode::Transform); } + async_redraw(); + async_end(); }); popup->mouse_release(); popup->destroy();