kreadconfig: keep references to QByteArray objects

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-31 23:35:53 +03:00
parent 04d7b0c309
commit 333aae94ed
2 changed files with 6 additions and 4 deletions

View file

@ -88,7 +88,7 @@ int main(int argc, char **argv)
KComponentData inst(&aboutData);
KGlobal::config();
KConfig *konfig = nullptr;
KConfig* konfig = nullptr;
bool configMustDeleted = false;
if (file.isEmpty()) {
konfig = KGlobal::config().data();
@ -118,14 +118,16 @@ int main(int argc, char **argv)
}
return retValue;
} else if (type == QLatin1String("path")) {
fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data());
const QByteArray path = cfgGroup.readPathEntry(key, dflt).toLocal8Bit();
fprintf(stdout, "%s\n", path.constData());
if (configMustDeleted) {
delete konfig;
}
return 0;
} else {
/* Assume it's a string... */
fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data());
const QByteArray string = cfgGroup.readEntry(key, dflt).toLocal8Bit();
fprintf(stdout, "%s\n", string.constData());
if (configMustDeleted) {
delete konfig;
}

View file

@ -67,7 +67,7 @@ int main(int argc, char **argv)
KComponentData inst(&aboutData);
KConfig *konfig = nullptr;
KConfig* konfig = nullptr;
if (file.isEmpty()) {
konfig = new KConfig(QString::fromLatin1("kdeglobals"), KConfig::NoGlobals);
} else {