當我關閉我的應用程序時,我總是收到這個消息。 我知道它與JsonCpp有關,因爲它僅在使用Json值時發生。與JSonCpp的純虛函數調用
我認爲它是與我是如何創建的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;
....沒有'root [「blah」] = foo' ?! – sehe