[Kst] [Bug 142702] Cross power spectrum has useless default names for output vectors

netterfield at astro.utoronto.ca netterfield at astro.utoronto.ca
Wed Mar 28 17:44:42 CEST 2007


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=142702         
netterfield astro utoronto ca changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From netterfield astro utoronto ca  2007-03-28 17:44 -------
SVN commit 647523 by netterfield:

BUG: 142702
Fixes default names, fixes the math, and fixes a possible dangling lock
in a corner case.

approved by George.


 M  +22 -4     crosspowerspectrum.cpp  
 M  +7 -7      crossspectrumdialog_i.cpp  


--- trunk/extragear/graphics/kst/src/plugins/crossspectrum/crosspowerspectrum.cpp #647522:647523
 @ -196,22 +196,40  @
 
 
 void CrossPowerSpectrum::setReal(const QString &name) {
+  QString tname;
+  if (name.isEmpty()) {
+    tname = i18n("the real part of a complex number", "real");
+  } else {
+    tname = name;
+  }
   KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
-  KstVectorPtr v = new KstVector(KstObjectTag(name, tag()), 0, this, false);
+  KstVectorPtr v = new KstVector(KstObjectTag(tname, tag()), 0, this, false);
   _outputVectors.insert(REAL, v);
 }
 
 
 void CrossPowerSpectrum::setImaginary(const QString &name) {
+  QString tname;
+  if (name.isEmpty()) {
+    tname = i18n("the imaginary part of a complex number", "imaginary");
+  } else {
+    tname = name;
+  }
   KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
-  KstVectorPtr v = new KstVector(KstObjectTag(name, tag()), 0, this, false);
+  KstVectorPtr v = new KstVector(KstObjectTag(tname, tag()), 0, this, false);
   _outputVectors.insert(IMAGINARY, v);
 }
 
 
 void CrossPowerSpectrum::setFrequency(const QString &name) {
+  QString tname;
+  if (name.isEmpty()) {
+    tname = i18n("frequency");
+  } else {
+    tname = name;
+  }
   KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
-  KstVectorPtr v = new KstVector(KstObjectTag(name, tag()), 0, this, false);
+  KstVectorPtr v = new KstVector(KstObjectTag(tname, tag()), 0, this, false);
   _outputVectors.insert(FREQUENCY, v);
 }
 
 @ -357,7 +375,7  @
     real->value()[0] += ( a[0]*b[0] );
     real->value()[xps_len-1] += ( a[1]*b[1] );
     for (i_samp=1; i_samp<xps_len-1; i_samp++) {
-      real->value()[i_samp]+= ( a[i_samp*2] * b[i_samp*2] -
+      real->value()[i_samp]+= ( a[i_samp*2] * b[i_samp*2] +
                                    a[i_samp*2+1] * b[i_samp*2+1] );
       imaginary->value()[i_samp]+= ( -a[i_samp*2] * b[i_samp*2+1] +
                                    a[i_samp*2+1] * b[i_samp*2] );
--- trunk/extragear/graphics/kst/src/plugins/crossspectrum/crossspectrumdialog_i.cpp #647522:647523
 @ -80,12 +80,6  @
   //called upon clicking 'ok' in 'new' mode
   //return false if the specified objects can't be made, otherwise true
 
-  //Need to create a new object rather than use the one in KstDataObject pluginList
-  CrossPowerSpectrumPtr cps = kst_cast<CrossPowerSpectrum>(KstDataObject::createPlugin("Cross Power Spectrum"));
-  Q_ASSERT(cps); //should never happen...
-
-  cps->writeLock();
-
   QString tagName = _tagName->text();
 
   if (tagName != defaultTag && KstData::self()->dataTagNameNotUnique(tagName, true, this)) {
 @ -93,6 +87,12  @
     return false;
   }
 
+  //Need to create a new object rather than use the one in KstDataObject pluginList
+  CrossPowerSpectrumPtr cps = kst_cast<CrossPowerSpectrum>(KstDataObject::createPlugin("Cross Power Spectrum"));
+  Q_ASSERT(cps); //should never happen...
+
+  cps->writeLock();
+
   if (tagName == defaultTag) {
     tagName = KST::suggestPluginName("crosspowerspectrum");
   }
 @ -111,7 +111,7  @
   cps->setFrequency(_w->_frequency->text());
 
   if (!cps || !cps->isValid()) {
-    KMessageBox::sorry(this, i18n("There is an error in the linefit you entered."));
+    KMessageBox::sorry(this, i18n("There is an error in the crosspowerspectrum you entered."));
     return false;
   }


More information about the Kst mailing list