Summary: | Kst crashes on save if contour plot without colormap exists | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Rick Chern <rchern> |
Component: | general | Assignee: | Rick Chern <rchern> |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Rick Chern
2004-08-19 01:53:31 UTC
CVS commit by rchern: When saving, don't try to get the name from a null palette pointer. Also log a debug message when the palette cannot be found when loading, and don't bother creating a default palette if no colormap exists. CCMAIL: 87477-done@bugs.kde.org M +18 -9 kstimage.cpp 1.16 --- kdeextragear-2/kst/kst/kstimage.cpp #1.15:1.16 @@ -27,4 +27,6 @@ #include <math.h> +#include <qmessagebox.h> + KstImage::KstImage(QDomElement& e) : KstDataObject(e){ QString in_tag, in_matrixName, in_paletteName; @@ -63,11 +65,4 @@ KstImage::KstImage(QDomElement& e) : Kst } _inputMatrixLoadQueue.append(qMakePair(QString("THEMATRIX"), in_matrixName)); - KPalette *in_pal = new KPalette(in_paletteName); - //maybe the palette doesn't exist anymore. Generate a grayscale palette then. - if (in_pal->nrColors() <= 0) { - for (int i = 0; i < 256; i++) { - _pal->addColor(QColor(i,i,i)); - } - } setTagName(in_tag); @@ -77,5 +72,17 @@ KstImage::KstImage(QDomElement& e) : Kst _zLower = in_zLower; _zUpper = in_zUpper; + + if (_hasColorMap) { + KPalette *in_pal = new KPalette(in_paletteName); + //maybe the palette doesn't exist anymore. Generate a grayscale palette then. + if (in_pal->nrColors() <= 0) { + for (int i = 0; i < 256; i++) { + in_pal->addColor(QColor(i,i,i)); + } + KstDebug::self()->log(i18n("Unable to find palette %1. Using a 256 color grayscale palette instead.").arg(in_paletteName), + KstDebug::Warning); + } _pal = in_pal; + } if (!_hasColorMap) { @@ -175,5 +182,7 @@ void KstImage::save(QTextStream &ts) { ts << " <matrixtag>" << _matrix->tagName() << "</matrixtag>" << endl; ts << " <hascolormap>" << _hasColorMap << "</hascolormap>" <<endl; + if (_pal) { ts << " <palettename>" << _pal->name() << "</palettename>" << endl; + } ts << " <lowerthreshold>" << _zLower << "</lowerthreshold>" << endl; ts << " <upperthreshold>" << _zUpper << "</upperthreshold>" << endl; |