[Kst] [Bug 120490] Crash when trying to change data sample ranges
Andrew Walker
arwalker at sumusltd.com
Fri Jan 20 22:16:37 CET 2006
------- 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=120490
------- Additional Comments From arwalker sumusltd com 2006-01-20 22:16 -------
SVN commit 500673 by arwalker:
CCBUG:120490 Prevent crash due to invalid pointers. The numerous 'FIXME: broken' comments should be addressed before shipping 1.2 as the associated code does appaer to be incorrectly written.
M +79 -63 kstchangenptsdialog_i.cpp
--- trunk/extragear/graphics/kst/kst/kstchangenptsdialog_i.cpp #500672:500673
@ -55,6 +55,7 @
bool KstChangeNptsDialogI::updateChangeNptsDialog() {
QStringList qsl;
+ int inserted = 0;
for (uint i_vector = 0; i_vector < CurveList->count(); i_vector++) {
if (CurveList->isSelected(i_vector)) {
@ -62,15 +63,20 @
}
}
CurveList->clear();
+
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
/* insert vectors into ChangeNptsCurveList */
for (uint i = 0; i < rvl.count(); i++) {
- rvl[i]->readLock();
- CurveList->insertItem(rvl[i]->tagName(), -1);
- if (qsl.contains(rvl[i]->tagName())) {
- CurveList->setSelected(i, true);
+ KstRVectorPtr vector = rvl[i]; // FIXME: broken
+ if (vector) {
+ vector->readLock();
+ CurveList->insertItem(vector->tagName(), -1);
+ if (qsl.contains(vector->tagName())) {
+ CurveList->setSelected(inserted, true);
+ }
+ inserted++;
+ vector->readUnlock();
}
- rvl[i]->readUnlock();
}
return !qsl.isEmpty();
}
@ -92,45 +98,49 @
for (uint i_vector = 0; i_vector < CurveList->count(); ++i_vector) {
if (CurveList->isSelected(i_vector)) {
KstRVectorPtr vector = rvl[i_vector]; // FIXME: broken
- int f0, n;
- vector->readLock();
- if (_kstDataRange->isStartRelativeTime() && vector->dataSource()) {
- vector->dataSource()->readLock();
- f0 = vector->dataSource()->sampleForTime(_kstDataRange->f0Value());
- vector->dataSource()->readUnlock();
- } else if (_kstDataRange->isStartAbsoluteTime() && vector->dataSource()) {
- vector->dataSource()->readLock();
- f0 = vector->dataSource()->sampleForTime(_kstDataRange->f0DateTimeValue());
- vector->dataSource()->readUnlock();
- } else {
- f0 = int(_kstDataRange->f0Value());
- }
+ if (vector) {
+ int f0, n;
+ vector->readLock();
+ if (_kstDataRange->isStartRelativeTime() && vector->dataSource()) {
+ vector->dataSource()->readLock();
+ f0 = vector->dataSource()->sampleForTime(_kstDataRange->f0Value());
+ vector->dataSource()->readUnlock();
+ } else if (_kstDataRange->isStartAbsoluteTime() && vector->dataSource()) {
+ vector->dataSource()->readLock();
+ f0 = vector->dataSource()->sampleForTime(_kstDataRange->f0DateTimeValue());
+ vector->dataSource()->readUnlock();
+ } else {
+ f0 = int(_kstDataRange->f0Value());
+ }
- if (_kstDataRange->isRangeRelativeTime() && vector->dataSource()) {
- KstDataSourcePtr ds = vector->dataSource();
- ds->readLock();
- double nValStored = _kstDataRange->nValue();
- if (_kstDataRange->CountFromEnd->isChecked()) {
- int frameCount = ds->frameCount(vector->field());
- double msCount = ds->relativeTimeForSample(frameCount - 1);
- n = frameCount - 1 - ds->sampleForTime(msCount - nValStored);
+ if (_kstDataRange->isRangeRelativeTime() && vector->dataSource()) {
+ KstDataSourcePtr ds = vector->dataSource();
+ if (ds) {
+ ds->readLock();
+ double nValStored = _kstDataRange->nValue();
+ if (_kstDataRange->CountFromEnd->isChecked()) {
+ int frameCount = ds->frameCount(vector->field());
+ double msCount = ds->relativeTimeForSample(frameCount - 1);
+ n = frameCount - 1 - ds->sampleForTime(msCount - nValStored);
+ } else {
+ double fTime = ds->relativeTimeForSample(f0);
+ n = ds->sampleForTime(fTime + nValStored) - ds->sampleForTime(fTime);
+ }
+ ds->readUnlock();
+ }
} else {
- double fTime = ds->relativeTimeForSample(f0);
- n = ds->sampleForTime(fTime + nValStored) - ds->sampleForTime(fTime);
+ n = int(_kstDataRange->nValue());
}
- ds->readUnlock();
- } else {
- n = int(_kstDataRange->nValue());
+ vector->readUnlock();
+ vector->writeLock();
+ vector->changeFrames(
+ (_kstDataRange->CountFromEnd->isChecked() ? -1 : f0),
+ (_kstDataRange->ReadToEnd->isChecked() ? -1 : n),
+ _kstDataRange->Skip->value(),
+ _kstDataRange->DoSkip->isChecked(),
+ _kstDataRange->DoFilter->isChecked());
+ vector->writeUnlock();
}
- vector->readUnlock();
- vector->writeLock();
- vector->changeFrames(
- (_kstDataRange->CountFromEnd->isChecked() ? -1 : f0),
- (_kstDataRange->ReadToEnd->isChecked() ? -1 : n),
- _kstDataRange->Skip->value(),
- _kstDataRange->DoSkip->isChecked(),
- _kstDataRange->DoFilter->isChecked());
- vector->writeUnlock();
}
}
@ -145,25 +155,27 @
}
KstRVectorPtr vector = rvl[index];
- vector->writeLock();
+ if (vector) {
+ vector->writeLock();
- _kstDataRange->_startUnits->setCurrentItem(0);
- _kstDataRange->_rangeUnits->setCurrentItem(0);
+ _kstDataRange->_startUnits->setCurrentItem(0);
+ _kstDataRange->_rangeUnits->setCurrentItem(0);
- /* fill the vector range entries */
- _kstDataRange->CountFromEnd->setChecked(vector->countFromEOF());
- _kstDataRange->setF0Value(vector->reqStartFrame());
+ /* fill the vector range entries */
+ _kstDataRange->CountFromEnd->setChecked(vector->countFromEOF());
+ _kstDataRange->setF0Value(vector->reqStartFrame());
- /* fill number of frames entries */
- _kstDataRange->ReadToEnd->setChecked(vector->readToEOF());
- _kstDataRange->setNValue(vector->reqNumFrames());
+ /* fill number of frames entries */
+ _kstDataRange->ReadToEnd->setChecked(vector->readToEOF());
+ _kstDataRange->setNValue(vector->reqNumFrames());
- /* fill in frames to skip box */
- _kstDataRange->Skip->setValue(vector->skip());
- _kstDataRange->DoSkip->setChecked(vector->doSkip());
- _kstDataRange->DoFilter->setChecked(vector->doAve());
- _kstDataRange->updateEnables();
- vector->writeUnlock();
+ /* fill in frames to skip box */
+ _kstDataRange->Skip->setValue(vector->skip());
+ _kstDataRange->DoSkip->setChecked(vector->doSkip());
+ _kstDataRange->DoFilter->setChecked(vector->doAve());
+ _kstDataRange->updateEnables();
+ vector->writeUnlock();
+ }
}
@ -174,14 +186,18 @
for (uint i = 0; i < cnt; ++i) {
if (CurveList->isSelected(i)) {
KstRVectorPtr vector = rvl[i]; // FIXME: broken
- vector->readLock();
- KstDataSourcePtr ds = vector->dataSource();
- vector->readUnlock();
- ds->readLock();
- supportsTime = ds->supportsTimeConversions();
- ds->readUnlock();
- if (!supportsTime) {
- break;
+ if (vector) {
+ vector->readLock();
+ KstDataSourcePtr ds = vector->dataSource();
+ vector->readUnlock();
+ if (ds) {
+ ds->readLock();
+ supportsTime = ds->supportsTimeConversions();
+ ds->readUnlock();
+ if (!supportsTime) {
+ break;
+ }
+ }
}
}
}
More information about the Kst
mailing list