Skip to content

Commit 5b0af38

Browse files
zty199deepin-bot[bot]
authored andcommitted
fix: crash when calling DGioSettings::setValue
Though whether key is actually existed has been judged in DGioSettingsPrivate::trySet, when calling g_settings_get_value, 'gkey' still seems to be empty or NULL. Not sure what happened when converted from QString to gchar* Log: Use DGioPrivate::convertToGChar to replace QString::toUtf8().constData() in DGioSettingsPrivate::trySet, just like DGioSettingsPrivate::value
1 parent c22fc13 commit 5b0af38

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

gio-qt/source/dgiosettings.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,12 @@ class DGioSettingsPrivate
205205

206206
bool trySet(const QString& key, const QVariant& value)
207207
{
208-
const gchar* gkey = key.toUtf8().constData();
208+
gchar* gkey = DGioPrivate::converToGChar(key.toUtf8());
209209

210-
if(!inlcudeKey(gkey)) return false;
210+
if(!inlcudeKey(gkey)) {
211+
g_free(gkey);
212+
return false;
213+
}
211214

212215
bool success = false;
213216

@@ -221,6 +224,7 @@ class DGioSettingsPrivate
221224
}
222225

223226
g_variant_unref(cur);
227+
g_free(gkey);
224228

225229
return success;
226230
}

0 commit comments

Comments
 (0)