|
16 | 16 |
|
17 | 17 | // App |
18 | 18 | #include "AppName.h" |
| 19 | +#include "CJsonWrapper.h" |
19 | 20 | #include "File.h" |
20 | 21 | #include "Hotkey.h" |
21 | 22 | #include "Log.h" |
22 | 23 | #include "Path.h" |
23 | 24 | #include "StringUtility.h" |
24 | 25 |
|
25 | | -// cJSON |
26 | | -#include <cJSON.h> |
27 | | - |
28 | 26 | // Windows |
29 | 27 | #include <Windows.h> |
30 | 28 | #include <shellapi.h> |
@@ -250,13 +248,13 @@ void Settings::addAutoTray(const std::string & executable, const std::string & w |
250 | 248 |
|
251 | 249 | bool Settings::parseJson(const std::string & json) |
252 | 250 | { |
253 | | - const cJSON * cjson = cJSON_Parse(json.c_str()); |
| 251 | + CJsonWrapper cjson(cJSON_Parse(json.c_str())); |
254 | 252 | if (!cjson) { |
255 | 253 | WARNING_PRINTF("failed to parse settings JSON:\n%s\n", cJSON_GetErrorPtr()); |
256 | 254 | return false; |
257 | 255 | } |
258 | 256 |
|
259 | | - DEBUG_PRINTF("parsed settings JSON:\n%s\n", cJSON_Print(cjson)); |
| 257 | + DEBUG_PRINTF("parsed settings JSON:\n%s\n", cjson.print().c_str()); |
260 | 258 |
|
261 | 259 | startWithWindows_ = getBool(cjson, settingKeys_[SK_StartWithWindows], startWithWindows_); |
262 | 260 | showWindowsInMenu_ = getBool(cjson, settingKeys_[SK_ShowWindowsInMenu], showWindowsInMenu_); |
@@ -300,7 +298,7 @@ bool Settings::fileExists(const std::string & fileName) |
300 | 298 |
|
301 | 299 | std::string Settings::constructJSON() |
302 | 300 | { |
303 | | - cJSON * cjson = cJSON_CreateObject(); |
| 301 | + CJsonWrapper cjson(cJSON_CreateObject()); |
304 | 302 | if (!cjson) { |
305 | 303 | WARNING_PRINTF("failed to create settings JSON object\n"); |
306 | 304 | return std::string(); |
@@ -385,11 +383,10 @@ std::string Settings::constructJSON() |
385 | 383 |
|
386 | 384 | if (fail) { |
387 | 385 | WARNING_PRINTF("failed to construct json settings\n"); |
388 | | - cJSON_Delete(cjson); |
389 | 386 | return std::string(); |
390 | 387 | } |
391 | 388 |
|
392 | | - return cJSON_Print(cjson); |
| 389 | + return cjson.print(); |
393 | 390 | } |
394 | 391 |
|
395 | 392 | bool Settings::autoTrayItemCallback(const cJSON * cjson, void * userData) |
|
0 commit comments