Summary: | Crash when creating PSDs | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Andrew Walker <arwalker> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Andrew Walker
2005-03-23 00:50:31 UTC
CVS commit by staikos: Add PSDs to the memory check algorithm in the data wizard and also add a check for the malloc() in KstVector::KstVector, temporary until Kst2 when isValid() becomes KstObject-wide. We need this check for javascript too, even though it's an ugly hack and gives somewhat unexpected behaviour in the case that malloc fails BUG: 102222 M +11 -3 datawizard.ui.h 1.128 M +11 -0 kstpsd.cpp 1.29 M +7 -1 kstvector.cpp 1.102 --- kdeextragear-2/kst/kst/datawizard.ui.h #1.127:1.128 @@ -486,9 +486,17 @@ void DataWizard::finished() if (_kstDataRange->DoSkip->isChecked()) { + if (_radioButtonPlotPSD->isChecked()) { + memoryRequested += 3 * frames / _kstDataRange->Skip->value()*sizeof(double); + } else { memoryRequested += frames / _kstDataRange->Skip->value()*sizeof(double); + } + } else { + if (_radioButtonPlotPSD->isChecked()) { + memoryRequested += 3 * frames * ds->samplesPerFrame(field)*sizeof(double); } else { memoryRequested += frames * ds->samplesPerFrame(field)*sizeof(double); } } + } ++it; } --- kdeextragear-2/kst/kst/kstpsd.cpp #1.28:1.29 @@ -30,4 +30,5 @@ #include "dialoglauncher.h" #include "kstdatacollection.h" +#include "kstdebug.h" #include "kstpsd.h" #include "kstvectordefaults.h" @@ -156,4 +157,9 @@ void KstPSD::commonConstructor(const QSt KstVectorPtr ov = new KstVector(in_tag+"-freq", _PSDLen); + if (ov->length() != _PSDLen) { + _PSDLen = 1; + _Len = 1; + KstDebug::self()->log(i18n("Attempted to create a PSD that used all memory."), KstDebug::Error); + } KST::addVectorToList(ov); ov->setProvider(this); @@ -162,4 +168,9 @@ void KstPSD::commonConstructor(const QSt ov = new KstVector(in_tag+"-sv", _PSDLen); + if (ov->length() != _PSDLen) { + _PSDLen = 1; + _Len = 1; + KstDebug::self()->log(i18n("Attempted to create a PSD that used all memory."), KstDebug::Error); + } KST::addVectorToList(ov); ov->setProvider(this); --- kdeextragear-2/kst/kst/kstvector.cpp #1.101:1.102 @@ -72,5 +72,10 @@ KstVector::KstVector(const QString& name _v = static_cast<double*>(KST::malloc(size*sizeof(double))); + if (!_v) { // Malloc failed + _v = static_cast<double*>(KST::malloc(sizeof(double))); + _size = 1; + } else { _size = size; + } _is_rising = false; |