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 "clientlauncher.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "porting_android.h"
|
||||
#endif
|
||||
|
||||
/* mainmenumanager.h
|
||||
*/
|
||||
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());
|
||||
delete[] text;
|
||||
|
||||
#ifdef ANDROID
|
||||
porting::handleAndroidActivityEvents();
|
||||
#endif
|
||||
|
||||
try { // This is used for catching disconnects
|
||||
|
||||
guienv->clear();
|
||||
|
|
|
@ -68,6 +68,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "touchscreengui.h"
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "porting_android.h"
|
||||
#endif
|
||||
|
||||
extern Settings *g_settings;
|
||||
extern Profiler *g_profiler;
|
||||
|
||||
|
@ -1766,6 +1770,10 @@ void Game::run()
|
|||
|
||||
while (device->run() && !(*kill || g_gamecallback->shutdown_requested)) {
|
||||
|
||||
#ifdef ANDROID
|
||||
porting::handleAndroidActivityEvents();
|
||||
#endif
|
||||
|
||||
/* Must be called immediately after a device->run() call because it
|
||||
* uses device->getTimer()->getTime()
|
||||
*/
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
{
|
||||
shutdown_requested = true;
|
||||
#ifndef __ANDROID__
|
||||
device->closeDevice();
|
||||
porting::handleAndroidActivityEvents();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "filesys.h"
|
||||
#include "log.h"
|
||||
#include <sstream>
|
||||
#include <android_native_app_glue.h>
|
||||
|
||||
#ifdef GPROF
|
||||
#include "prof.h"
|
||||
|
@ -63,7 +64,7 @@ void android_main(android_app *app)
|
|||
|
||||
porting::cleanupAndroid();
|
||||
errorstream << "Shutting down minetest." << std::endl;
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
/* handler for finished message box input */
|
||||
|
@ -88,6 +89,17 @@ android_app* app_global;
|
|||
JNIEnv* jnienv;
|
||||
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)
|
||||
{
|
||||
if (jnienv == 0) {
|
||||
|
@ -163,6 +175,7 @@ void cleanupAndroid()
|
|||
#endif
|
||||
|
||||
JavaVM *jvm = app_global->activity->vm;
|
||||
if (jvm)
|
||||
jvm->DetachCurrentThread();
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ int getInputDialogState();
|
|||
*/
|
||||
std::string getInputDialogValue();
|
||||
|
||||
void handleAndroidActivityEvents();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue