From 93cb1ef2ebd480acf9f49af9da0990aed71f49a5 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Mon, 12 May 2014 15:41:52 +0200 Subject: Fix crash while loading config due to incorrect tw_storage_path Change-Id: Ia5957efe616defa4272501cd8f31d26d394077bb Signed-off-by: Vojtech Bocek --- data.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'data.cpp') diff --git a/data.cpp b/data.cpp index 7be0b03e8..72018f9aa 100644 --- a/data.cpp +++ b/data.cpp @@ -280,7 +280,9 @@ error: fclose(in); string current = GetCurrentStoragePath(); TWPartition* Part = PartitionManager.Find_Partition_By_Path(current); - if (current != Part->Storage_Path && Part->Mount(false)) { + if(!Part) + Part = PartitionManager.Get_Default_Storage_Partition(); + if (Part && current != Part->Storage_Path && Part->Mount(false)) { LOGINFO("LoadValues setting storage path to '%s'\n", Part->Storage_Path.c_str()); SetValue("tw_storage_path", Part->Storage_Path); } else { @@ -586,11 +588,16 @@ void DataManager::SetDefaultValues() mConstValues.insert(make_pair("false", "0")); mConstValues.insert(make_pair(TW_VERSION_VAR, TW_VERSION_STR)); - mValues.insert(make_pair("tw_storage_path", make_pair("/", 1))); mValues.insert(make_pair("tw_button_vibrate", make_pair("80", 1))); mValues.insert(make_pair("tw_keyboard_vibrate", make_pair("40", 1))); mValues.insert(make_pair("tw_action_vibrate", make_pair("160", 1))); + TWPartition *store = PartitionManager.Get_Default_Storage_Partition(); + if(store) + mValues.insert(make_pair("tw_storage_path", make_pair(store->Storage_Path.c_str(), 1))); + else + mValues.insert(make_pair("tw_storage_path", make_pair("/", 1))); + #ifdef TW_FORCE_CPUINFO_FOR_DEVICE_ID printf("TW_FORCE_CPUINFO_FOR_DEVICE_ID := true\n"); #endif -- cgit v1.2.3