[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Tue Oct 19 21:42:39 CEST 2004


CVS commit by arwalker: 

Provide an error code in the debug message if a plugin fails to load.


  M +5 -3      plugincollection.cpp   1.20
  M +12 -13    pluginxmlparser.cpp   1.28


--- kdeextragear-2/kst/kst/plugincollection.cpp  #1.19:1.20
@@ -222,7 +222,9 @@ void PluginCollection::scanPlugins() {
     QFileInfoListIterator fit(*list);
     QFileInfo *fi;
+    int status;
 
     while ((fi = fit.current()) != 0L) {
-      if (_parser->parseFile(*it + fi->fileName()) == 0) {
+      status = _parser->parseFile(*it + fi->fileName());
+      if (status == 0) {
         // dupe? - prefer earlier installations
         if (_installedPluginNames.contains(_parser->data()._name)) {
@@ -239,5 +241,5 @@ void PluginCollection::scanPlugins() {
         }
       } else {
-        KstDebug::self()->log(i18n("Error parsing XML file '%1'; skipping.").arg(*it + fi->fileName()), KstDebug::Warning);
+        KstDebug::self()->log(i18n("Error [%2] parsing XML file '%1'; skipping.").arg(*it + fi->fileName()).arg(status), KstDebug::Warning);
       }
       ++fit;

--- kdeextragear-2/kst/kst/pluginxmlparser.cpp  #1.27:1.28
@@ -31,20 +31,19 @@ PluginXMLParser::~PluginXMLParser() {
 int PluginXMLParser::parseFile(const QString& filename) {
   QFile qf(filename);
+  int retVal = -1;
 
-  if (!qf.open(IO_ReadOnly)) {
-    return -1;
-  }
-
+  if (qf.open(IO_ReadOnly)) {
   QDomDocument doc(filename);
-  if (!doc.setContent(&qf)) {
-    qf.close();
-    return -2;
-  }
-
-  qf.close();
 
+    if (doc.setContent(&qf)) {
   _pluginData.clear();
+      retVal = parseDOM(doc);
+    } else {
+      retVal = -2;
+    }
+    qf.close();
+  }
 
-  return parseDOM(doc);
+  return retVal;
 }
 





More information about the Kst mailing list