当我关闭我的应用程序时,我不断收到这个。我知道它与 JsonCpp 有关,因为它仅在我使用 Json 值时发生。
我认为这与我如何创建 json 值有关,但由于没有任何教程,我不知道应该怎么做
我的代码目前是:
static Json::Value root; // will contains the root value after parsing.
unsigned int WindowSettings::WindowWidth = 800;
unsigned int WindowSettings::WindowHeight = 600;
bool WindowSettings::FullScreen = false;
unsigned short WindowSettings::AntiAliasing = 16;
bool WindowSettings::VSync = false;
short WindowSettings::FrameRateLimit = 60;
AspectRatios WindowSettings::AspectRatio = ar4p3;
Resolutions WindowSettings::Resolution = r800x600;
Json::Value WindowSettings::root = Json::Value();
void WindowSettings::remakeDefault()
{
root["WindowWidth"] = WindowWidth;
root["WindowHeight"] = WindowHeight;
root["FullScreen"] = FullScreen;
root["AntiAliasing"] = AntiAliasing;
root["VSync"] = VSync;
root["FrameRateLimit"] = FrameRateLimit;
root["AspectRatio"] = AspectRatio;
root["Resolution"] = Resolution;
saveToFile("conf.json");
}
bool WindowSettings::saveToFile(const std::string &fileName)
{
Json::FastWriter writer;
// Make a new JSON document for the configuration. Preserve original comments.
std::string outputConfig = writer.write( root );
std::ofstream myfile;
myfile.open (fileName.c_str(), std::ios::out | std::ios::trunc | std::ios::binary );
if (myfile.is_open())
{
myfile << outputConfig.c_str();
myfile.close();
}
return true;
}
当我不这样做时,我应该添加这不会发生:root["blah"] = foo;