Android: Ensure all global objects are destructed

Android doesn't automatically trigger global objects destruction, so we need to do it ourselves.

Test case:

struct TestGlobal {
 ~TestGlobal() { qDebug() << " ~TestGlobal";}
} global;

int main() {
  return  0;
}

Change-Id: I32507c1cffebafc9841e9707a8f6711dcbd36281
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
BogDan Vatra 2015-08-28 19:00:21 +03:00 committed by BogDan Vatra
parent 0a00782608
commit 4f7e0bdc4c

View File

@ -432,7 +432,6 @@ static void *startMainMethod(void */*data*/)
params[i] = static_cast<const char *>(m_applicationParams[i].constData());
int ret = m_main(m_applicationParams.length(), const_cast<char **>(params.data()));
Q_UNUSED(ret);
if (m_mainLibraryHnd) {
int res = dlclose(m_mainLibraryHnd);
@ -448,6 +447,8 @@ static void *startMainMethod(void */*data*/)
if (vm != 0)
vm->DetachCurrentThread();
// We must call exit() to ensure that all global objects will be destructed
exit(ret);
return 0;
}