diff -uNr gmic-2.6.7/src/CImg.h gmic-2.6.7.mod/src/CImg.h --- gmic-2.6.7/src/CImg.h 2019-06-28 09:56:12.000000000 +0300 +++ gmic-2.6.7.mod/src/CImg.h 2019-06-29 18:45:02.595895578 +0300 @@ -3249,6 +3249,7 @@ bool is_blue_first; bool is_shm_enabled; bool byte_order; + bool pending_cancel; #ifdef cimg_use_xrandr XRRScreenSize *resolutions; @@ -3275,7 +3276,12 @@ ~X11_attr() { /* if (events_thread) { +#ifndef __ANDROID__ pthread_cancel(*events_thread); +#else + cimg::X11_attr::ref().pending_cancel = true; + pthread_join(*events_thread, NULL); +#endif delete events_thread; } pthread_cond_destroy(&wait_event); @@ -9914,8 +9920,12 @@ static void* _events_thread(void *arg) { // Thread to manage events for all opened display windows Display *const dpy = cimg::X11_attr::ref().display; XEvent event; +#ifndef __ANDROID__ pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,0); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); +#else + cimg::X11_attr::ref().pending_cancel = false; +#endif if (!arg) for ( ; ; ) { cimg_lock_display(); bool event_flag = XCheckTypedEvent(dpy,ClientMessage,&event); @@ -9928,7 +9938,12 @@ if (!cimg::X11_attr::ref().wins[i]->_is_closed && event.xany.window==cimg::X11_attr::ref().wins[i]->_window) cimg::X11_attr::ref().wins[i]->_handle_events(&event); cimg_unlock_display(); +#ifndef __ANDROID__ pthread_testcancel(); +#else + if (cimg::X11_attr::ref().pending_cancel) + return 0; +#endif cimg::sleep(8); } return 0; @@ -68470,8 +68485,8 @@ _cimg_test_temporary_path("D:\\Temp"); _cimg_test_temporary_path("D:"); #else - _cimg_test_temporary_path("/tmp"); - _cimg_test_temporary_path("/var/tmp"); + _cimg_test_temporary_path("/data/data/com.termux/files/usr/tmp"); + _cimg_test_temporary_path("/data/data/com.termux/files/usr/var/tmp"); #endif if (!path_found) { *s_path = 0;