Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.7.3, 5.0.0 Beta 1
-
None
-
Known for windows. not checked for others
Description
An .ini file once being read by QSettings stays in its cache for an indefinite time. This is wrong because further readings don't allow to apply different codec for the contents.
QSetting caches it's values are not deleted even out its scope. More elaborated in the following code.
QString v,v1; // Starting a Scope for QSetting { QSettings settings("test1.ini", QSettings::IniFormat); // the following line populates some internal QSettings cache that lives long after the // settings instance is destroyed. v = settings.value("lang").toString(); //The value for v is unreadable since the original value is encoded in "UTF-8" } //Creating a new QSetting in order to access values with a different codec QSettings settings1("test1.ini", QSettings::IniFormat); // the following line doesn't affect anything because the value we'll need is already in cache // and the value is not updated with the setting of the codec settings1.setIniCodec("UTF-8"); // Hence the following value is same as v and is not displayed correctly according to the correct //codec used in the ini file. v1 = settings1.value("lang").toString();