Fix improper shutdown
This commit is contained in:
parent
45f1e07320
commit
9e9ef7af64
|
@ -34,6 +34,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "fontengine.h"
|
#include "fontengine.h"
|
||||||
#include "clientlauncher.h"
|
#include "clientlauncher.h"
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include "porting_android.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* mainmenumanager.h
|
/* mainmenumanager.h
|
||||||
*/
|
*/
|
||||||
gui::IGUIEnvironment *guienv = NULL;
|
gui::IGUIEnvironment *guienv = NULL;
|
||||||
|
@ -191,6 +195,10 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
|
||||||
device->setWindowCaption((narrow_to_wide("MultiCraft") + L" [" + text + L"]").c_str());
|
device->setWindowCaption((narrow_to_wide("MultiCraft") + L" [" + text + L"]").c_str());
|
||||||
delete[] text;
|
delete[] text;
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
porting::handleAndroidActivityEvents();
|
||||||
|
#endif
|
||||||
|
|
||||||
try { // This is used for catching disconnects
|
try { // This is used for catching disconnects
|
||||||
|
|
||||||
guienv->clear();
|
guienv->clear();
|
||||||
|
|
|
@ -68,6 +68,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "touchscreengui.h"
|
#include "touchscreengui.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include "porting_android.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern Settings *g_settings;
|
extern Settings *g_settings;
|
||||||
extern Profiler *g_profiler;
|
extern Profiler *g_profiler;
|
||||||
|
|
||||||
|
@ -1766,6 +1770,10 @@ void Game::run()
|
||||||
|
|
||||||
while (device->run() && !(*kill || g_gamecallback->shutdown_requested)) {
|
while (device->run() && !(*kill || g_gamecallback->shutdown_requested)) {
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
porting::handleAndroidActivityEvents();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Must be called immediately after a device->run() call because it
|
/* Must be called immediately after a device->run() call because it
|
||||||
* uses device->getTimer()->getTime()
|
* uses device->getTimer()->getTime()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -138,7 +138,7 @@ public:
|
||||||
{
|
{
|
||||||
shutdown_requested = true;
|
shutdown_requested = true;
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
device->closeDevice();
|
porting::handleAndroidActivityEvents();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <android_native_app_glue.h>
|
||||||
|
|
||||||
#ifdef GPROF
|
#ifdef GPROF
|
||||||
#include "prof.h"
|
#include "prof.h"
|
||||||
|
@ -63,7 +64,7 @@ void android_main(android_app *app)
|
||||||
|
|
||||||
porting::cleanupAndroid();
|
porting::cleanupAndroid();
|
||||||
errorstream << "Shutting down minetest." << std::endl;
|
errorstream << "Shutting down minetest." << std::endl;
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handler for finished message box input */
|
/* handler for finished message box input */
|
||||||
|
@ -88,6 +89,17 @@ android_app* app_global;
|
||||||
JNIEnv* jnienv;
|
JNIEnv* jnienv;
|
||||||
jclass nativeActivity;
|
jclass nativeActivity;
|
||||||
|
|
||||||
|
void handleAndroidActivityEvents()
|
||||||
|
{
|
||||||
|
int ident;
|
||||||
|
int events;
|
||||||
|
struct android_poll_source *source;
|
||||||
|
|
||||||
|
while ( (ident = ALooper_pollOnce(0, NULL, &events, (void**)&source)) >= 0)
|
||||||
|
if (source)
|
||||||
|
source->process(porting::app_global, source);
|
||||||
|
}
|
||||||
|
|
||||||
jclass findClass(std::string classname)
|
jclass findClass(std::string classname)
|
||||||
{
|
{
|
||||||
if (jnienv == 0) {
|
if (jnienv == 0) {
|
||||||
|
@ -163,7 +175,8 @@ void cleanupAndroid()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JavaVM *jvm = app_global->activity->vm;
|
JavaVM *jvm = app_global->activity->vm;
|
||||||
jvm->DetachCurrentThread();
|
if (jvm)
|
||||||
|
jvm->DetachCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExternalStorageDir(JNIEnv* lJNIEnv)
|
void setExternalStorageDir(JNIEnv* lJNIEnv)
|
||||||
|
|
|
@ -76,6 +76,7 @@ int getInputDialogState();
|
||||||
*/
|
*/
|
||||||
std::string getInputDialogValue();
|
std::string getInputDialogValue();
|
||||||
|
|
||||||
|
void handleAndroidActivityEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue