Summary: | Crash when trying to change data sample ranges | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Andrew Walker <arwalker> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Andrew Walker
2006-01-20 03:16:59 UTC
Seems to be related or duplicate of #118696 I can't reproduce it. Is the datasource pointer null in updateTimeCombo? 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; + } + } } } } SVN commit 502061 by arwalker: CCBUG:120490 No longer assume a direct correspondence between the list box entries and the vector list entries. M +9 -6 kstchangenptsdialog_i.cpp --- trunk/extragear/graphics/kst/kst/kstchangenptsdialog_i.cpp #502060:502061 @@ -65,9 +65,9 @@ CurveList->clear(); KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); - /* insert vectors into ChangeNptsCurveList */ + // insert vectors into ChangeNptsCurveList for (uint i = 0; i < rvl.count(); i++) { - KstRVectorPtr vector = rvl[i]; // FIXME: broken + KstRVectorPtr vector = rvl[i]; if (vector) { vector->readLock(); CurveList->insertItem(vector->tagName(), -1); @@ -95,11 +95,12 @@ void KstChangeNptsDialogI::applyNptsChange() { KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); - for (uint i_vector = 0; i_vector < CurveList->count(); ++i_vector) { - if (CurveList->isSelected(i_vector)) { - KstRVectorPtr vector = rvl[i_vector]; // FIXME: broken + for (uint i = 0; i < CurveList->count(); ++i) { + if (CurveList->isSelected(i)) { + KstRVectorPtr vector = *(rvl.findTag(CurveList->text(i))); if (vector) { int f0, n; + vector->readLock(); if (_kstDataRange->isStartRelativeTime() && vector->dataSource()) { vector->dataSource()->readLock(); @@ -132,6 +133,7 @@ n = int(_kstDataRange->nValue()); } vector->readUnlock(); + vector->writeLock(); vector->changeFrames( (_kstDataRange->CountFromEnd->isChecked() ? -1 : f0), @@ -174,6 +176,7 @@ _kstDataRange->DoSkip->setChecked(vector->doSkip()); _kstDataRange->DoFilter->setChecked(vector->doAve()); _kstDataRange->updateEnables(); + vector->writeUnlock(); } } @@ -185,7 +188,7 @@ bool supportsTime = true; for (uint i = 0; i < cnt; ++i) { if (CurveList->isSelected(i)) { - KstRVectorPtr vector = rvl[i]; // FIXME: broken + KstRVectorPtr vector = *(rvl.findTag(CurveList->text(i))); if (vector) { vector->readLock(); KstDataSourcePtr ds = vector->dataSource(); Crash is now guarded against. |