[BUG_FIXED] Fix a crash bug on Notepad++ start up.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1253 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-06-24 18:39:12 +00:00
parent e959002a69
commit 2683ec18ea

View File

@ -805,7 +805,7 @@ bool NppParameters::reloadLang()
} }
/* /*
Spec for settings on cloud (dropbox, drive...) Spec for settings on cloud (dropbox, oneDrive and googleDrive)
ON LOAD: ON LOAD:
1. if doLocalConf.xml, check nppInstalled/cloud/choice 1. if doLocalConf.xml, check nppInstalled/cloud/choice
2. check the validity of 3 cloud and get the npp_cloud_folder according the choice. 2. check the validity of 3 cloud and get the npp_cloud_folder according the choice.
@ -850,34 +850,36 @@ generic_string NppParameters::getCloudSettingsPath(CloudChoice cloudChoice)
generic_string dropboxInfoJson = tmp; generic_string dropboxInfoJson = tmp;
PathAppend(dropboxInfoJson, TEXT("Dropbox\\info.json")); PathAppend(dropboxInfoJson, TEXT("Dropbox\\info.json"));
try {
if (::PathFileExists(dropboxInfoJson.c_str())) if (::PathFileExists(dropboxInfoJson.c_str()))
{
std::ifstream ifs(dropboxInfoJson.c_str(), std::ifstream::binary);
Json::Value root;
Json::Reader reader;
bool parsingSuccessful = reader.parse(ifs, root);
if (parsingSuccessful)
{ {
Json::Value personalRoot = root.get("personal", 0); std::ifstream ifs(dropboxInfoJson.c_str(), std::ifstream::binary);
std::string pathVal = personalRoot.get("path", "").asString();
const size_t maxLen = 2048; Json::Value root;
wchar_t dest[maxLen]; Json::Reader reader;
mbstowcs(dest, pathVal.c_str(), maxLen);
if (::PathFileExists(dest)) bool parsingSuccessful = reader.parse(ifs, root);
if (parsingSuccessful)
{ {
settingsPath4dropbox = dest; Json::Value personalRoot = root.get("personal", 0);
_nppGUI._availableClouds |= DROPBOX_AVAILABLE; std::string pathVal = personalRoot.get("path", "").asString();
const size_t maxLen = 2048;
wchar_t dest[maxLen];
mbstowcs(dest, pathVal.c_str(), maxLen);
if (::PathFileExists(dest))
{
settingsPath4dropbox = dest;
_nppGUI._availableClouds |= DROPBOX_AVAILABLE;
}
} }
} }
} catch (...) {
//printStr(TEXT("JsonCpp exception captured"));
} }
// //
// TODO: check if one drive is present // TODO: check if OneDrive is present
// //
// Get value from registry // Get value from registry
@ -914,7 +916,7 @@ generic_string NppParameters::getCloudSettingsPath(CloudChoice cloudChoice)
cloudSettingsPath = settingsPath4dropbox; cloudSettingsPath = settingsPath4dropbox;
PathAppend(cloudSettingsPath, TEXT("Notepad++")); PathAppend(cloudSettingsPath, TEXT("Notepad++"));
// The folder %userprofile%\Dropbox\Notepad++ should exist. // The folder cloud_folder\Notepad++ should exist.
// if it doesn't, it means this folder was removed by user, we create it anyway // if it doesn't, it means this folder was removed by user, we create it anyway
if (!PathFileExists(cloudSettingsPath.c_str())) if (!PathFileExists(cloudSettingsPath.c_str()))
{ {