[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepimlibs/kresources
From: Thomas McGuire <mcguire () kde ! org>
Date: 2008-09-08 21:47:54
Message-ID: 1220910474.176716.4232.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 858880 by tmcguire:
Properly fix the migrator crash.
When I wrote "this invalidates the existing pointers" I already had the feeling
that the previous solution wasn't that great...
M +6 -13 factory.cpp
M +7 -13 factory.h
M +4 -1 managerimpl.cpp
--- trunk/KDE/kdepimlibs/kresources/factory.cpp #858879:858880
@@ -75,23 +75,16 @@
return factory;
}
-Factory *Factory::recreateSelf( const QString &resourceFamily )
-{
- kDebug();
- Factory *factory = 0;
- factory = mSelves->value( resourceFamily, 0 );
- if ( factory ) {
- delete factory;
- mSelves->remove( resourceFamily );
- }
-
- return self( resourceFamily );
-}
-
Factory::Factory( const QString &resourceFamily ) :
d( new KRES::Factory::Private )
{
d->mResourceFamily = resourceFamily;
+ reloadConfig();
+}
+
+void Factory::reloadConfig()
+{
+ d->mTypeMap.clear();
const KService::List plugins =
KServiceTypeTrader::self()->query(
"KResources/Plugin",
--- trunk/KDE/kdepimlibs/kresources/factory.h #858879:858880
@@ -79,19 +79,6 @@
*/
static Factory *self( const QString &resourceFamily );
- /**
- * Deletes the factory for the given resource family and then
- * recreates it.
- * This can be useful when re-reading the configuration.
- *
- * All pointers to previous factories of the same family returned by self()
- * will become invalid.
- *
- * @return the new factory which was just created-
- * @since 4.2
- */
- static Factory *recreateSelf( const QString &resourceFamily );
-
~Factory();
/**
@@ -104,6 +91,13 @@
ConfigWidget *configWidget( const QString &type, QWidget *parent = 0 );
/**
+ * Reload the configuration. This reloads the plugin type map.
+ * Useful to call after resources have been added or removed.
+ * @since 4.2
+ */
+ void reloadConfig();
+
+ /**
Returns a pointer to a resource object or a null pointer
if resource type doesn't exist.
--- trunk/KDE/kdepimlibs/kresources/managerimpl.cpp #858879:858880
@@ -108,7 +108,10 @@
{
kDebug();
- d->mFactory = Factory::recreateSelf( d->mFamily );
+ if ( d->mFactory )
+ d->mFactory->reloadConfig();
+ else
+ d->mFactory = Factory::self( d->mFamily );
if ( !cfg ) {
createStandardConfig();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic