forked from mirrors/gio-qt
fix: 右键dock栏上的挂载图标,dock栏崩溃并且消失
对于无配置的Key,gSetting在调用gio函数的时候会崩溃,主要是g_settings_get_value内部断言造成的 Log: 无效gSetting配置导致程序崩溃 Bug: https://pms.uniontech.com/zentao/bug-view-65675.html Change-Id: Ifc5af2535a4a19a27920f24392f53cdda4526d65
This commit is contained in:
parent
a31da19cc6
commit
f98c1f6e0d
2 changed files with 33 additions and 1 deletions
6
debian/control
vendored
6
debian/control
vendored
|
@ -6,7 +6,8 @@ Build-Depends:
|
|||
debhelper (>= 9),
|
||||
cmake,
|
||||
pkg-config,
|
||||
qt5-default,
|
||||
qtbase5-dev,
|
||||
qt5-qmake,
|
||||
libglibmm-2.4-dev,
|
||||
doxygen,
|
||||
qttools5-dev-tools
|
||||
|
@ -17,15 +18,18 @@ Package: libgio-qt
|
|||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, libglibmm-2.4-1v5
|
||||
Description: Gio wrapper for Qt.
|
||||
A convenient way to bind gio with Qt5.
|
||||
|
||||
Package: libgio-qt-dev
|
||||
Architecture: any
|
||||
Section: libdevel
|
||||
Depends: libgio-qt, ${misc:Depends}, libglibmm-2.4-dev
|
||||
Description: Development package for libgio-qt.
|
||||
A convenient way to bind gio with Qt5.
|
||||
|
||||
Package: libgio-qt-doc
|
||||
Architecture: any
|
||||
Section: doc
|
||||
Depends: ${misc:Depends}
|
||||
Description: Gio wrapper for Qt (documentation)
|
||||
A convenient way to bind gio with Qt5.
|
||||
|
|
|
@ -185,8 +185,33 @@ public:
|
|||
GSettingsSchema* schema;
|
||||
gulong signalHandlerId;
|
||||
|
||||
bool strvHasString (gchar **haystack, const gchar *needle) const {
|
||||
if (needle == nullptr) return false;
|
||||
|
||||
for (guint n = 0; haystack != NULL && haystack[n] != NULL; n++) {
|
||||
if (g_strcmp0 (haystack[n], needle) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool inlcudeKey(const gchar* gkey) const {
|
||||
gchar **allKeys = g_settings_list_keys(settings);
|
||||
bool ret = strvHasString (allKeys, gkey);
|
||||
g_strfreev (allKeys);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVariant value(GSettings* gsettings, const QString& key) const {
|
||||
gchar* gkey = DGioPrivate::converToGChar(key.toUtf8());
|
||||
|
||||
if(!inlcudeKey(gkey)) {
|
||||
g_free(gkey);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
GVariant* variant = g_settings_get_value(gsettings, gkey);
|
||||
QVariant qvalue = qconf_types_to_qvariant(variant);
|
||||
g_variant_unref(variant);
|
||||
|
@ -198,6 +223,9 @@ public:
|
|||
bool trySet(const QString& key, const QVariant& value)
|
||||
{
|
||||
const gchar* gkey = key.toUtf8().constData();
|
||||
|
||||
if(!inlcudeKey(gkey)) return false;
|
||||
|
||||
bool success = false;
|
||||
|
||||
/* fetch current value to find out the exact type */
|
||||
|
|
Loading…
Reference in a new issue