[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Fri May 23 22:15:09 CEST 2003


CVS commit by staikos: 

- avoid a crash by leaking memory until we can fix the architecture properly
- detect errors when trying to create a new plugin


  M +1 -1      kstplugin.cpp   1.17
  M +13 -15    kstplugindialog_i.cpp   1.22


--- kdeextragear-2/kst/kst/kstplugin.cpp  #1.16:1.17
@@ -80,5 +80,5 @@ KstPlugin::~KstPlugin() {
     v->decUsage();
     if (v->getUsage() == 0) {
-      delete v;
+      //delete v; -- causes crashes because we have no way to remove from the doc list
     }
   }

--- kdeextragear-2/kst/kst/kstplugindialog_i.cpp  #1.21:1.22
@@ -257,4 +257,9 @@ bool KstPluginDialogI::saveOutputs(KstPl
 
     QLineEdit *li = static_cast<QLineEdit*>(field);
+
+    if (li->text().isEmpty() || doc->dataTagNameNotUnique(li->text())) {
+      return false;
+    }
+
     if ((*it)._type == Plugin::Data::IOValue::TableType) {
       KstSlaveVector *v = 0L, *oldV = plugin->outputVectors().atS(vcnt++);
@@ -307,5 +312,5 @@ void KstPluginDialogI::new_I() {
       do {
         tmpTagName = i18n("P%1-%2").arg(++i).arg(_pluginList[pitem]);
-      } while (doc->dataTagNameNotUnique(tmpTagName));
+      } while (doc->dataTagNameNotUnique(tmpTagName, false));
       tagName = tmpTagName;
     }
@@ -319,8 +324,8 @@ void KstPluginDialogI::new_I() {
   }
 
-  // Save the input vectors and scalars
-  saveInputs(plugin);
-  // Save the output vectors and scalars
-  saveOutputs(plugin);
+  if (!saveInputs(plugin) || !saveOutputs(plugin)) {
+    delete plugin;
+    return;
+  }
 
   doc->pluginList.append(KSharedPtr<KstPlugin>(plugin));
@@ -442,8 +447,7 @@ void KstPluginDialogI::delete_I() {
   if (tag.isEmpty()) {
     KMessageBox::sorry(0L, i18n("You need to select an active plugin to delete."));
-    return;
-  }
-
+  } else {
   doc->removeDataObject(tag);
+  }
 }
 
@@ -481,10 +485,5 @@ QString scalarLabelTemplate, vectorLabel
     }
 
-    QLabel *label;
-    if (input) {
-      label = new QLabel(labellabel, parent, "Input label");
-    } else {
-      label = new QLabel(labellabel, parent, "Output label");
-    }
+    QLabel *label = new QLabel(labellabel, parent, input ? "Input label" : "Output label");
 
     QWidget *widget = 0L;
@@ -552,5 +551,4 @@ void KstPluginDialogI::pluginChanged(int
     // Add a separator
     QFrame* line = new QFrame(_frameWidget);
-    line->setFrameShape(QFrame::HLine);
     line->setFrameShadow(QFrame::Sunken);
     line->setFrameShape(QFrame::HLine);




More information about the Kst mailing list