Merge pull request #2714 from trashkalmar/migration-crash-fix

[new downloader][android] fix: Crash on migration.
This commit is contained in:
Dmitry Yunitsky 2016-04-04 14:12:06 +03:00
commit b8fea7b8c4

View file

@ -112,11 +112,15 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeNeedMigrate(JNIEnv * env, j
static void FinishMigration(JNIEnv * env)
{
ASSERT(g_migrationListener);
env->DeleteGlobalRef(g_migrationListener);
g_migrationListener = nullptr;
}
static void OnPrefetchComplete(bool keepOldMaps)
{
ASSERT(g_migrationListener);
g_framework->Migrate(keepOldMaps);
JNIEnv * env = jni::GetEnv();
@ -128,6 +132,8 @@ static void OnPrefetchComplete(bool keepOldMaps)
static void OnMigrationError(NodeErrorCode error)
{
ASSERT(g_migrationListener);
JNIEnv * env = jni::GetEnv();
static jmethodID const callback = jni::GetMethodID(env, g_migrationListener, "onError", "(I)V");
env->CallVoidMethod(g_migrationListener, callback, static_cast<jint>(error));
@ -143,7 +149,8 @@ static void MigrationStatusChangedCallback(TCountryId const & countryId, bool ke
switch (attrs.m_status)
{
case NodeStatus::OnDisk:
OnPrefetchComplete(keepOldMaps);
if (!attrs.m_groupNode)
OnPrefetchComplete(keepOldMaps);
break;
case NodeStatus::Undefined: