4
0
mirror of https://github.com/QuasarApp/qca.git synced 2025-05-14 11:29:33 +00:00

get rid of recursive mutex

svn path=/trunk/kdesupport/qca/; revision=655216
This commit is contained in:
Justin Karneges 2007-04-18 00:03:16 +00:00
parent 3967fe4447
commit 32718bb2d0
2 changed files with 40 additions and 3 deletions

@ -554,6 +554,41 @@ void saveProviderConfig(const QString &name)
writeConfig(name, conf);
}
QVariantMap getProviderConfig_internal(Provider *p)
{
QVariantMap conf;
QString name = p->name();
global->config_mutex.lock();
// try loading from persistent storage
conf = readConfig(name);
// if not, load the one from memory
if(conf.isEmpty())
conf = global->config.value(name);
global->config_mutex.unlock();
// if provider doesn't exist or doesn't have a valid config form,
// use the config we loaded
QVariantMap pconf = p->defaultConfig();
if(!configIsValid(pconf))
return conf;
// if the config loaded was empty, use the provider's config
if(conf.isEmpty())
return pconf;
// if the config formtype doesn't match the provider's formtype,
// then use the provider's
if(pconf["formtype"] != conf["formtype"])
return pconf;
// otherwise, use the config loaded
return conf;
}
QString globalRandomProvider()
{
QMutexLocker locker(global_random_mutex());

@ -38,6 +38,9 @@
namespace QCA {
// from qca_core.cpp
QVariantMap getProviderConfig_internal(Provider *p);
static ProviderManager *g_pluginman = 0;
static void logDebug(const QString &str)
@ -224,7 +227,7 @@ public:
p->init();
// load config
QVariantMap conf = getProviderConfig(p->name());
QVariantMap conf = getProviderConfig_internal(p);
if(!conf.isEmpty())
p->configChanged(conf);
}
@ -233,8 +236,7 @@ private:
PluginInstance *instance;
bool init_done;
// TODO: someday find a way to not have this recursive mutex?
ProviderItem(PluginInstance *_instance, Provider *_p) : m(QMutex::Recursive)
ProviderItem(PluginInstance *_instance, Provider *_p)
{
instance = _instance;
p = _p;