QCustomPlot Discussion and Comments

QCPColorMapData::fill broken (fix included)Return to overview

QCPColorMapData::fill uses memset to fill a data will the fill value, but this doesn't work as memset takes an int parameter. The implicit cast of double -> int will only rarely be correct.

--- a/source/thirdparty/qcustomplot/qcustomplot.cpp
+++ b/source/thirdparty/qcustomplot/qcustomplot.cpp
@@ -26230,7 +26230,8 @@ void QCPColorMapData::clearAlpha()
 void QCPColorMapData::fill(double z)
 {
   const int dataCount = mValueSize*mKeySize;
-  memset(mData, z, dataCount*sizeof(*mData));
+  for(size_t i = 0; i < dataCount; i++)
+    mData[i] = z;
   mDataBounds = QCPRange(z, z);
   mDataModified = true;
 }

*a data array with