[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Tue May 13 00:44:48 CEST 2003
CVS commit by staikos:
slight refactoring, new method
M +22 -9 plugincollection.cpp 1.2
M +5 -0 plugincollection.h 1.2
--- kdeextragear-2/kst/kst/plugincollection.cpp #1.1:1.2
@@ -68,14 +68,27 @@ void PluginCollection::loadAllPlugins()
// FIXME: Optimize me. We currently parse the XML twice. This is suboptimal.
while ((fi = it.current()) != 0L) {
- if (_parser->parseFile(fi->fileName()) == 0) {
- if (!_plugins.contains(_parser->getData()._name)) {
- Plugin *p = PluginLoader::self()->loadPlugin(fi->fileName(),
- fi->fileName().replace(QRegExp(".kstxml$"), ".so"));
- if (p) {
- _plugins[_parser->getData()._name] = p;
+ loadPlugin(fi->fileName());
}
+}
+
+
+int PluginCollection::loadPlugin(const QString& xmlfile) {
+ if (_parser->parseFile(xmlfile) != 0) {
+ return -1; // can't parse
}
+
+ if (_plugins.contains(_parser->getData()._name)) {
+ return 0; // already loaded
}
+
+ QString sofile = xmlfile;
+ Plugin *p = PluginLoader::self()->loadPlugin(xmlfile,
+ sofile.replace(QRegExp(".kstxml$"), ".so"));
+ if (p) {
+ _plugins[_parser->getData()._name] = p;
+ return 0;
}
+
+return -2;
}
--- kdeextragear-2/kst/kst/plugincollection.h #1.1:1.2
@@ -37,4 +37,9 @@ public:
void unloadAllPlugins();
+ /**
+ * Returns 0 on success, nonzero on error.
+ */
+ int loadPlugin(const QString& xmlfile);
+
int count() const;
More information about the Kst
mailing list