From 2683ec18ead7ca906ba5f5aece7ee4686a964e31 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 24 Jun 2014 18:39:12 +0000 Subject: [PATCH] [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 --- PowerEditor/src/Parameters.cpp | 46 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 3b207f15..b72f8309 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -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: 1. if doLocalConf.xml, check nppInstalled/cloud/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; PathAppend(dropboxInfoJson, TEXT("Dropbox\\info.json")); - - 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) + try { + if (::PathFileExists(dropboxInfoJson.c_str())) { - Json::Value personalRoot = root.get("personal", 0); - std::string pathVal = personalRoot.get("path", "").asString(); + std::ifstream ifs(dropboxInfoJson.c_str(), std::ifstream::binary); - const size_t maxLen = 2048; - wchar_t dest[maxLen]; - mbstowcs(dest, pathVal.c_str(), maxLen); - if (::PathFileExists(dest)) + Json::Value root; + Json::Reader reader; + + bool parsingSuccessful = reader.parse(ifs, root); + if (parsingSuccessful) { - settingsPath4dropbox = dest; - _nppGUI._availableClouds |= DROPBOX_AVAILABLE; + Json::Value personalRoot = root.get("personal", 0); + 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 @@ -914,7 +916,7 @@ generic_string NppParameters::getCloudSettingsPath(CloudChoice cloudChoice) cloudSettingsPath = settingsPath4dropbox; 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 (!PathFileExists(cloudSettingsPath.c_str())) {