diff options
author | Armin Berres <armin.berres@basyskom.de> | 2010-06-29 13:01:01 +0200 |
---|---|---|
committer | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-07-16 16:21:23 +0300 |
commit | 46819ee4b6a7a950e903534a9c5baaf54671b047 (patch) | |
tree | dba49bffbfa0aa83a31424440a93ba87e226fb57 /src/corelib | |
parent | 76dbe9c8329df8fd6e1cd4c5bddba8f5fc2a27a0 (diff) |
Fixes: NB#172648 - Slow startup performance when using MGConfItem
RevBy: Tomas Junnonen
Details:
gconf_client_add_dir() is just called with an actual
directory instead of key now and tweaked to preload
the content of the directory.
update_value() is called after gconf_client_add_dir().
This way the preloaded values can be used.
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/core/mgconfitem.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/corelib/core/mgconfitem.cpp b/src/corelib/core/mgconfitem.cpp index 9573fece..0adf4e4f 100644 --- a/src/corelib/core/mgconfitem.cpp +++ b/src/corelib/core/mgconfitem.cpp @@ -29,6 +29,11 @@ #include <gconf/gconf-client.h> struct MGConfItemPrivate { + MGConfItemPrivate() : + notify_id(0), + have_gconf(false) + {} + QString key; QVariant value; guint notify_id; @@ -357,16 +362,21 @@ MGConfItem::MGConfItem(const QString &key, QObject *parent) { priv = new MGConfItemPrivate; priv->key = key; - priv->notify_id = 0; withClient(client) { - update_value(false); QByteArray k = convertKey(priv->key); GError *error = NULL; - gconf_client_add_dir(client, k.data(), GCONF_CLIENT_PRELOAD_ONELEVEL, &error); + + int index = k.lastIndexOf('/'); + if (index > 0) { + QByteArray dir = k.left(index); + gconf_client_add_dir(client, dir.data(), GCONF_CLIENT_PRELOAD_ONELEVEL, &error); + } else { + gconf_client_add_dir(client, k.data(), GCONF_CLIENT_PRELOAD_NONE, &error); + } + if(error) { mWarning("MGConfItem") << error->message; g_error_free(error); - priv->have_gconf = false; return; } priv->notify_id = gconf_client_notify_add(client, k.data(), @@ -378,6 +388,7 @@ MGConfItem::MGConfItem(const QString &key, QObject *parent) priv->have_gconf = false; return; } + update_value(false); } priv->have_gconf = true; } |