[Kst] extragear/graphics/kst/kst

Andrew Walker arwalker at sumusltd.com
Wed Jun 8 00:09:52 CEST 2005


SVN commit 423243 by arwalker:

No need to crash if there are no defined input vectors for a plugin. Code more defensively.

 M  +9 -2      kstplugindialog_i.cpp  


--- trunk/extragear/graphics/kst/kst/kstplugindialog_i.cpp #423242:423243
@@ -393,6 +393,8 @@
 
 
 bool KstPluginDialogI::saveInputs(KstPluginPtr plugin, KstSharedPtr<Plugin> p) {
+  bool rc = true;
+  
   KST::vectorList.lock().readLock();
   KST::scalarList.lock().readLock();
   KST::stringList.lock().readLock();
@@ -405,6 +407,9 @@
       KstVectorPtr v = *KST::vectorList.findTag(vs->selectedVector());
       if (v) {
         v->writeLock(); // to match with plugin->writeLock()
+      } else {
+        rc = false;
+        break;
       }
       if (plugin->inputVectors().contains((*it)._name) && plugin->inputVectors()[(*it)._name] != v) {
         plugin->inputVectors()[(*it)._name]->writeUnlock();
@@ -468,7 +473,8 @@
   KST::stringList.lock().readUnlock();
   KST::scalarList.lock().readUnlock();
   KST::vectorList.lock().readUnlock();
-  return true;
+  
+  return rc;
 }
 
 
@@ -590,7 +596,6 @@
     _tagName->setFocus();
     return false;
   }
-
   KstPluginPtr plugin;
   int pitem = PluginCombo->currentItem();
   if (pitem >= 0 && PluginCombo->count() > 0) {
@@ -599,6 +604,7 @@
       plugin = new KstPlugin;
       plugin->writeLock();
       if (!saveInputs(plugin, pPtr)) {
+        KMessageBox::sorry(this, i18n("One or more of the inputs was undefined."));
         plugin->writeUnlock();
         plugin = 0L;
         return false;
@@ -611,6 +617,7 @@
       }
       plugin->setTagName(tagName);
       if (!saveOutputs(plugin, pPtr)) {
+        KMessageBox::sorry(this, i18n("One or more of the outputs was undefined."));
         plugin->writeUnlock();
         plugin = 0L;
         return false;


More information about the Kst mailing list