[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Feb 24 19:46:47 CET 2011
SVN commit 1222546 by netterfield:
BUG:
Fix a crash in the label parser.
Fix some parse errors in the label parser (eg, x^y^z).
Fix a crash in csds.
Fix a potential crash in matrixes.
Fix a memory leak in labels.
M +11 -2 libkst/matrix.cpp
M +2 -0 libkstapp/labelitem.cpp
M +23 -19 libkstmath/csd.cpp
M +17 -3 libkstmath/labelparser.cpp
U libkstmath/psd.cpp
--- branches/work/kst/portto4/kst/src/libkst/matrix.cpp #1222545:1222546
@@ -556,9 +556,17 @@
if (reinit && _zSize < sz) {
// initialize new memory after old values
- int newMemStart = ((_nX - 1) * ySize) + _nY;
- memset(_z + newMemStart, 0, (sz - newMemStart)*sizeof(double));
+ for (int row=0; row < qMin(xSize, _nX); ++row) {
+ for (int col = qMin(ySize,_nY); col<ySize; col++) {
+ _z[row*ySize+col] = 0;
}
+ }
+ for (int row = qMin(xSize, _nX); row < xSize; row++) {
+ for (int col = 0; col < ySize; col++) {
+ _z[row*ySize+col] = 0;
+ }
+ }
+ }
_nX = xSize;
_nY = ySize;
@@ -589,6 +597,7 @@
_stepY = stepY;
_minX = minX;
_minY = minY;
+ resizeZ(nX*nY, true);
}
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #1222545:1222546
@@ -69,6 +69,8 @@
connect(_labelRc, SIGNAL(labelDirty()), this, SLOT(setDirty()));
connect(_labelRc, SIGNAL(labelDirty()), this, SLOT(triggerUpdate()));
+
+ delete parsed;
}
}
--- branches/work/kst/portto4/kst/src/libkstmath/csd.cpp #1222545:1222546
@@ -52,7 +52,7 @@
MatrixPtr outMatrix = store->createObject<Matrix>();
outMatrix->setProvider(this);
outMatrix->setSlaveName("SG");
- outMatrix->change(1, 1);
+ outMatrix->change(2, 2);
_outMatrix = _outputMatrices.insert(OUTMATRIX, outMatrix).value();
}
@@ -87,17 +87,6 @@
_frequency = 1.0;
}
- LabelInfo label_info;
-
- label_info.name = QString();
- label_info.quantity = i18n("Time");
- label_info.units = QString('s');
- _outMatrix->setXLabelInfo(label_info);
-
- label_info.quantity = i18n("Frequency");
- label_info.units = _rateUnits;
- _outMatrix->setYLabelInfo(label_info);
-
updateMatrixLabels();
}
@@ -357,25 +346,40 @@
}
void CSD::updateMatrixLabels(void) {
- QString label;
+
+ LabelInfo label_info;
+
switch (_outputType) {
default:
case 0: // amplitude spectral density (default) [V/Hz^1/2]
- label = i18n("ASD \\[%1/%2^{1/2} \\]").arg(_vectorUnits).arg(_rateUnits);
+ label_info.quantity = i18n("Amplitude Spectral Density");
+ label_info.units = QString("%1/%2^{1/2}").arg(_vectorUnits).arg(_rateUnits);
break;
case 1: // power spectral density [V^2/Hz]
- label = i18n("PSD \\[%1^2/%2\\]").arg(_vectorUnits).arg(_rateUnits);
+ label_info.quantity = i18n("Power Spectral Density");
+ label_info.units = QString("%1^2/%2").arg(_vectorUnits).arg(_rateUnits);
break;
case 2: // amplitude spectrum [V]
- label = i18n("Amplitude Spectrum \\[%1\\]").arg(_vectorUnits);
+ label_info.quantity = i18n("Amplitude Spectrum");
+ label_info.units = QString("%1").arg(_vectorUnits);
break;
case 3: // power spectrum [V^2]
- label = i18n("Power Spectrum \\[%1^2\\]").arg(_vectorUnits);
+ label_info.quantity = i18n("Power Spectrum");
+ label_info.units = QString("%1^2").arg(_vectorUnits);
break;
}
- label += " of " + _inputVectors[CSD_INVECTOR]->descriptiveName();
- //_outMatrix->setLabel(label); FIXME: csd lable
+ label_info.name = _inputVectors[CSD_INVECTOR]->descriptiveName();
+ _outMatrix->setTitleInfo(label_info);
+ label_info.name.clear();
+ label_info.units = _rateUnits;
+ label_info.quantity = i18n("Frequency");
+ _outMatrix->setYLabelInfo(label_info);
+
+ label_info.quantity = i18n("Time");
+ label_info.units = QString('s');
+ _outMatrix->setXLabelInfo(label_info);
+
}
QString CSD::_automaticDescriptiveName() const {
--- branches/work/kst/portto4/kst/src/libkstmath/labelparser.cpp #1222545:1222546
@@ -508,12 +508,17 @@
if (ctail->group) {
ctail = new Chunk(ctail, Chunk::None, false, true);
}
-
for (uint& i = start; i < cnt; ++i) {
QChar c = txt[i];
Chunk::VOffset dir = Chunk::Down;
switch (c.unicode()) {
case '\n':
+ if (ctail->vOffset != Chunk::None && (!ctail->text.isEmpty() || ctail->locked())) {
+ while (ctail->vOffset != Chunk::None && (!ctail->text.isEmpty() || ctail->locked())) {
+ ctail = ctail->prev;
+ }
+ ctail = new Chunk(ctail, Chunk::None, false, true);
+ }
if (!ctail->text.isEmpty() || ctail->locked()) {
if (ctail->vOffset != Chunk::None) {
ctail = new Chunk(ctail->prev, Chunk::None, false, true);
@@ -536,6 +541,15 @@
ctail = new Chunk(ctail, Chunk::None, false, true);
break;
case 0x5c: // \ /**/
+
+ if (ctail->vOffset != Chunk::None && (!ctail->text.isEmpty() || ctail->locked())) {
+ while (ctail->vOffset != Chunk::None && (!ctail->text.isEmpty() || ctail->locked())) {
+ ctail = ctail->prev;
+ }
+ ctail = new Chunk(ctail, Chunk::None, false, true);
+ }
+
+
if (ctail->vOffset != Chunk::None && !ctail->text.isEmpty()) {
ctail = new Chunk(ctail->prev, Chunk::None, false, true);
}
@@ -553,7 +567,7 @@
break;
case 0x5e: // ^
dir = Chunk::Up;
- case 0x5f: // _
+ case 0x5f: // _ (dir is set to Down at begining of loop)
if (ctail->text.isEmpty() && !ctail->group) {
setNormalChar(c, &ctail);
} else {
@@ -563,7 +577,7 @@
} else if (ctail->group) {
ctail = new Chunk(ctail, dir, false, true);
} else {
- return 0L; // parse error - x^y^z etc
+ ctail = new Chunk(ctail, dir, false, true);
}
} else {
ctail = new Chunk(ctail, dir, false, true);
More information about the Kst
mailing list